Skip to content
Snippets Groups Projects
Commit 532569b2 authored by Graham Solie's avatar Graham Solie
Browse files

Merge remote-tracking branch 'origin/master'

parents 51a873e5 74c29066
No related branches found
No related tags found
No related merge requests found
Showing
with 81 additions and 112 deletions
......@@ -50,7 +50,6 @@
<Compile Include="Assets\Scripts\BackToMainScreen.cs" />
<Compile Include="Assets\Scripts\BananaMovement.cs" />
<Compile Include="Assets\Scripts\CameraMovement.cs" />
<Compile Include="Assets\Scripts\CurrentWeapon.cs" />
<Compile Include="Assets\Scripts\DecisionTree.cs" />
<Compile Include="Assets\Scripts\DrinkingPots.cs" />
<Compile Include="Assets\Scripts\EnemyAI.cs" />
......
......@@ -3,6 +3,9 @@ using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
// Both arena portraits are drawn here
// Player and Enemy stats are required to get head image
public class ArenaPortraits : MonoBehaviour {
private setAppearance appearance;
......@@ -83,12 +86,15 @@ public class ArenaPortraits : MonoBehaviour {
enemyHead.sprite = setEnemyAppearance.head;
enemyHead.color = setEnemyAppearance.color;
}
// When player is dead, this is called to display victory box
public void displayEarnings(){
rewardsPanel.SetActive (true);
earnings.text = reward.ToString ();
}
// Give reward to player
// Used when the "collect" button pushed
public void getReward(){
Money moneyScript = GameObject.Find("Canvas").GetComponent<Money>();
moneyScript.increaseCoins (reward);
......
using UnityEngine;
using System.Collections;
public class CurrentWeapon : MonoBehaviour {
public WeaponStats currentWeapon;
private SpriteRenderer spriteRenderer;
// Use this for initialization
void Start () {
spriteRenderer = GetComponent<SpriteRenderer> ();
updateWeapon ();
}
// Update is called once per frame
void Update () {
updateWeapon ();
}
void updateWeapon(){
if (currentWeapon.image == null) {
Debug.Log ("A weapon image was not set properly! (it's NULL)");
}
else {
spriteRenderer.sprite = currentWeapon.image;
}
}
}
fileFormatVersion: 2
guid: 463fe277ebdc9334b95afd20284fc5d9
timeCreated: 1478648605
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -24,14 +24,11 @@ public class EnemyCollision : MonoBehaviour {
if (col.tag == "currentWeapon") { // Enemy hits with slash attack
isHit = true;
enemyStats.Damage (playerStats.getDamageOutput());
// stats.knockback()
StartCoroutine (ExecuteAfterTime (1));
}
if (col.tag == "playerKick") { // Enemy hits with kick attack
isHit = true;
enemyStats.Damage (2);
// stats.shieldBreak()
// Check if shielding in other script
StartCoroutine (ExecuteAfterTime (0.2f));
}
}
......
......@@ -13,10 +13,8 @@ public class PlayerCollision : MonoBehaviour {
enemyStats = GameObject.Find ("Enemy").GetComponent<EnemyAI> ();
playerStats = GameObject.Find ("Player").GetComponent<PlayerStats> ();
}
/*
* All player interactions handled here
*/
// All player interactions handled here
void OnTriggerEnter2D(Collider2D col){
if (isHit == true) { // If hit recently, don't register hits
return;
......@@ -34,29 +32,24 @@ public class PlayerCollision : MonoBehaviour {
dmg = enemyStats.getDamageOutput ();
}
playerStats.Damage (dmg);
// player.knockback
StartCoroutine (ExecuteAfterTime (1));
}
if (col.tag == "enemyKick") { // Enemy hits with kick attack
Debug.Log ("player hit by kick");
isHit = true;
playerStats.Damage (2);
// player . shield broke
// Check if shielding in other script
StartCoroutine (ExecuteAfterTime (1));
}
if (col.tag == "projectile") {
Debug.Log ("Player hit by projectile!");
isHit = true;
playerStats.Damage (5);
playerStats.Damage (10);
StartCoroutine (ExecuteAfterTime (0.5f));
}
}
}
/*
* After parameter time, sets player hitable again
*/
// After parameter time, sets player hitable again
IEnumerator ExecuteAfterTime(float time){
yield return new WaitForSeconds (time);
isHit = false;
......
......@@ -29,7 +29,7 @@ public class PlayerMovement : MonoBehaviour
Movement(h, i);
FlipPlayer(h);
RotatePlayerZaxis(h);
//RotatePlayerZaxis(h);
attack();
block();
Drink();
......@@ -47,7 +47,10 @@ public class PlayerMovement : MonoBehaviour
}
}
/*
* Attack method for the player.
* Animations are handled here. See PlayerCollision.cs for interactions
*/
private void attack() {
attackSpeedCooldown -= Time.deltaTime;
if (Input.GetKeyDown(KeyCode.Space) && attackSpeedCooldown <= 0) {
......@@ -60,6 +63,9 @@ public class PlayerMovement : MonoBehaviour
}
}
/*
* Block method for the player.
*/
private void block()
{
if (Input.GetKeyDown(KeyCode.E))
......@@ -78,6 +84,9 @@ public class PlayerMovement : MonoBehaviour
}
/*
* Drink method for the player.
*/
private void Drink() {
//Can only drink the respected potion if the respected potion exists
if (Input.GetKeyDown(KeyCode.Alpha1) && PlayerStats.strengthPotions >= 1) {
......@@ -136,8 +145,9 @@ public class PlayerMovement : MonoBehaviour
//faces the characters body in the appropriate direction
/*
* faces the characters body in the appropriate direction
*/
private void FlipPlayer(float horizontal)
{
if (horizontal > 0 && !LookRight || horizontal < 0 && LookRight)
......@@ -150,37 +160,6 @@ public class PlayerMovement : MonoBehaviour
myAnimator.SetBool("block", false);
}
}
//keeps the character from falling over
private void RotatePlayerZaxis(float horizonal)
{
Vector3 myRotation = gameObject.transform.rotation.eulerAngles;
Vector3 Pos = transform.localPosition;
//if the player does not need to be climbing up an angle, the character will be fixed upright
if (Pos.x < -4f || Pos.x > 5f)
{
transform.localRotation = Quaternion.Euler(0, 0, 0);
}
else
{
//allows the character to rotate but not past 90 degrees either direction when climbing
if (myRotation.z > 90)
{
myRotation.z = Mathf.Clamp(0, 0, 0);
transform.rotation = Quaternion.Euler(myRotation);
}
if (myRotation.z < -90)
{
myRotation.z = Mathf.Clamp(0, 0, 0);
transform.rotation = Quaternion.Euler(myRotation);
}
}
}
}
......@@ -75,7 +75,9 @@ public class PlayerStats : MonoBehaviour {
stamina += Time.deltaTime; // refill stamina bar if not full
}
}
/*
* Send damage to player
*/
public void Damage(int amount) {
if (amount - defense > 0) {
curHealth -= amount - defense;
......@@ -87,10 +89,17 @@ public class PlayerStats : MonoBehaviour {
}
}
/*
* Check if player is dead
*/
public bool isPlayerDead(){
return isDead;
}
/*
* Use all players stats to calculate a slash damage output
* Sent to enemy, the enemy then applies damage reduction and subtracts it's health
*/
public int getDamageOutput(){
int final = Random.Range (currentWeapon.damageMin, currentWeapon.damageMax);
final += strength;
......@@ -117,7 +126,7 @@ public class PlayerStats : MonoBehaviour {
}
//leave time for a death animation and a defeat message, then load the main scene
yield return new WaitForSeconds(4.0f);
SceneManager.LoadScene("GameOver"); // ** will have to change this with more towns
SceneManager.LoadScene("GameOver");
}
public void ChangeHealthBarp(int damage) {
......@@ -129,28 +138,34 @@ public class PlayerStats : MonoBehaviour {
}
}
/*
* Update the current weapon sprite
*/
private void updateWeapon() {
GameObject weapon = GameObject.FindWithTag("currentWeapon"); // Get player weapon from scene
SpriteRenderer spriteRenderer = weapon.GetComponent<SpriteRenderer> ();
if (currentWeapon != null) {
if (currentWeapon != null) {// If current not assigned, set default
spriteRenderer.sprite = currentWeapon.image; // Set correct image of current weapon
}
else {
currentWeapon = defaultWeapon;
spriteRenderer.sprite = defaultWeapon.image; // Incase somethings wrong with currentWeapon
spriteRenderer.sprite = defaultWeapon.image;
}
}
/*
* Update the current shield sprite
*/
private void updateShield() {
GameObject armour = GameObject.FindWithTag("currentShield"); // Get player shield
SpriteRenderer spriteRenderer = armour.GetComponent<SpriteRenderer>();
if (currentShield != null) {
if (currentShield != null) { // If current not assigned, set default
spriteRenderer.sprite = currentShield.image; // Set correct image of current shield
}
else {
currentShield = defaultShield;
spriteRenderer.sprite = defaultShield.image; // Incase somethings wrong with currentShield
spriteRenderer.sprite = defaultShield.image;
}
}
......@@ -167,7 +182,7 @@ public class PlayerStats : MonoBehaviour {
public static float getHealth() {
return curHealth;
}
public void setWeapon(WeaponStats newWeapon) {
currentWeapon = newWeapon;
updateWeapon();
......@@ -278,6 +293,7 @@ public class PlayerStats : MonoBehaviour {
created = true;
}
// The default stats incase creation skipped
private void setDefaultStats(){
setName ("No Name");
setVitality (5);
......
......@@ -3,6 +3,10 @@ using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
/*
* A countdown timer for the Prefight scene
* Will atuomatically proceed to arena when ready
*/
public class Prefight : MonoBehaviour {
public int time;
......@@ -15,8 +19,7 @@ public class Prefight : MonoBehaviour {
player = GameObject.Find("ShopPlayer").GetComponent<PlayerStats>();
enemy = GameObject.Find("Enemy").GetComponent<setEnemyAppearance>();
}
// Update is called once per frame
void Update () {
playerName.text = PlayerStats.playerName;
enemyName.text = setEnemyAppearance.enemyName;
......
......@@ -28,6 +28,7 @@ public class ChooseCharLook : MonoBehaviour {
updateLooks ();
}
// Called every time something is changed
public void updateLooks(){
playerLooks.setFace(faceOptions[curFace]);
playerLooks.setHead(headOptions[curHead]);
......@@ -36,6 +37,7 @@ public class ChooseCharLook : MonoBehaviour {
playerLooks.creationDone ();
}
// Next face option, user must click next button
public void nextFace(){
if (curFace >= faceOptions.Length-1) {
curFace = 0;
......@@ -50,6 +52,7 @@ public class ChooseCharLook : MonoBehaviour {
updateLooks ();
}
// Next head option, user must click next button
public void nextHead(){
if (curHead >= headOptions.Length-1) {
curHead = 0;
......@@ -64,6 +67,7 @@ public class ChooseCharLook : MonoBehaviour {
updateLooks ();
}
// Next legs option, user must click next button
public void nextLegs(){
if (curLegs >= legOptions.Length - 1) {
curLegs = 0;
......@@ -84,16 +88,17 @@ public class ChooseCharLook : MonoBehaviour {
updateLooks();
}
// Sets red in r,g,b color for player using slider
public void setRed(float newValue){
red = (newValue);
playerLooks.addColor (red, green, blue);
}
// Sets green in r,g,b color for player using slider
public void setGreen(float newValue){
green = (newValue);
playerLooks.addColor (red, green, blue);
}
// Sets blue in r,g,b color for player using slider
public void setBlue(float newValue){
blue = (newValue);
playerLooks.addColor (red, green, blue);
......
......@@ -5,22 +5,24 @@ using System.Collections;
// This is used for character creation only
public class ChooseCharStats : MonoBehaviour {
public Text vitText;
public Text strText;
public Text defText;
public Text agiText;
public Text lucText;
public Text unalocText;
public Text vitText; // Vitality display text
public Text strText; // Strength display text
public Text defText; // Defense display text
public Text agiText; // Agility display text
public Text lucText; // luc display text
public Text unalocText; // unallocated points display text
// Actual stats stats assigned to player when creation done
public static string playerName;
private int vitality;
private int strength;
private int defense;
private int defense;
private int agility;
private int luck;
public static int unallocated;
private PlayerStats stats;
private PlayerStats stats; // For after creation finished, need to send stats to player
// Use this for initialization
void Start () {
vitality = 5;
......@@ -34,6 +36,7 @@ public class ChooseCharStats : MonoBehaviour {
setStats ();
}
// Set all stats when done pressed
public void setStats(){
stats.setName (playerName);
stats.setVitality (vitality);
......@@ -44,6 +47,7 @@ public class ChooseCharStats : MonoBehaviour {
stats.wasCreated ();
}
// Called everytime a stat in char creation is changed
private void updateScore(){
unalocText.text = "Unallocated: " + unallocated.ToString ();
vitText.text = "Vitality: " + vitality.ToString ();
......@@ -121,11 +125,13 @@ public class ChooseCharStats : MonoBehaviour {
setStats();
}
// Called everytime character entered
public void change_name(string newName){
playerName = newName;
}
// Incrementing each field, used by + buttons
//
public void inc_vit(){
if (unallocated > 0) {
unallocated--;
......@@ -167,7 +173,8 @@ public class ChooseCharStats : MonoBehaviour {
}
}
//Decrementing each field, used by - buttons
// Decrementing each field, used by - buttons
//
public void dec_str(){
if (strength > 1) {
strength--;
......
......@@ -3,6 +3,8 @@ using System.Collections;
// Made specifically for the player object
// This is used anywhere ingame aswell as in character creation
// It sets the players appearance based on chosen options
// If nothing chosen, goes to default
public class setAppearance : MonoBehaviour {
private static Sprite curFace;
......
......@@ -56,6 +56,7 @@ public class setEnemyAppearance : MonoBehaviour {
//portrait = GameObject.Find ("Canvas").GetComponent<ArenaPortraits> ();
//portrait.enemyPortrait();
}
// Setters for randomizer
public void setFace(Sprite newFace){
face = newFace;
}
......
No preview for this file type
No preview for this file type
File deleted
File deleted
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment