Skip to content
Snippets Groups Projects
Commit 1d35a0e8 authored by Mitchel Kovacs's avatar Mitchel Kovacs
Browse files

healthbar implemented, players now take damage

parent 7aa09961
No related branches found
No related tags found
No related merge requests found
Showing
with 92 additions and 88 deletions
No preview for this file type
......@@ -19,7 +19,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_4_1;UNITY_5_4;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_EDITOR_RETINA;ENABLE_RETINA_GUISTYLES;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;INCLUDE_PUBNUB;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE</DefineConstants>
<DefineConstants>DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_4_0;UNITY_5_4;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_EDITOR_RETINA;ENABLE_RETINA_GUISTYLES;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;INCLUDE_PUBNUB;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
......@@ -47,6 +47,7 @@
<ItemGroup>
<Compile Include="Assets\Scripts\ArenaCombatControl.cs" />
<Compile Include="Assets\Scripts\CameraMovement.cs" />
<Compile Include="Assets\Scripts\CharacterLook.cs" />
<Compile Include="Assets\Scripts\CharacterStats.cs" />
<Compile Include="Assets\Scripts\Collisions.cs" />
<Compile Include="Assets\Scripts\CreateWeapon.cs" />
......@@ -55,14 +56,13 @@
<Compile Include="Assets\Scripts\EnemyAI.cs" />
<Compile Include="Assets\Scripts\EnemyHealth.cs" />
<Compile Include="Assets\Scripts\EnterDoor.cs" />
<Compile Include="Assets\Scripts\MainMenu.cs" />
<Compile Include="Assets\Scripts\PlayerHealth.cs" />
<Compile Include="Assets\Scripts\PlayerMovement.cs" />
<Compile Include="Assets\Scripts\ShopMenu.cs" />
<Compile Include="Assets\Scripts\WeaponShopButton.cs" />
<Compile Include="Assets\Scripts\WeaponStats.cs" />
<Compile Include="Assets\Scripts\characterCreation\ChooseCharLook.cs" />
<Compile Include="Assets\Scripts\characterCreation\ChooseCharStats.cs" />
<Compile Include="Assets\Scripts\characterCreation\chooseCharLook.cs" />
<Compile Include="Assets\Scripts\characterCreation\setAppearance.cs" />
<Reference Include="UnityEngine.UI">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
......
No preview for this file type
Zookeepers Trial/Assets/Art/maps/creation.png

415 KiB | W: | H:

Zookeepers Trial/Assets/Art/maps/creation.png

1.18 MiB | W: | H:

Zookeepers Trial/Assets/Art/maps/creation.png
Zookeepers Trial/Assets/Art/maps/creation.png
Zookeepers Trial/Assets/Art/maps/creation.png
Zookeepers Trial/Assets/Art/maps/creation.png
  • 2-up
  • Swipe
  • Onion skin
fileFormatVersion: 2
guid: 04e47696ea2d3b54cbd7164b5cd1a9e4
timeCreated: 1478919162
guid: 8349f9df539e16045bf2f5eb8352e1b3
timeCreated: 1478723836
licenseType: Free
TextureImporter:
fileIDToRecycleName: {}
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class ArenaCombatControl : MonoBehaviour {
private Rigidbody2D Player;
private Animator myAnimator;
public static float health;
public float original;
EnterDoor spawn;
[SerializeField]
private float speed;
private bool LookRight = true;
private bool canMove = true;
private bool canJump = false;
private float attackSpeedCooldown;
// fields to modify player stats based on weapons -- now in CharacterLook script!! *****
/*
// fields to modify player stats based on weapons
public WeaponStats[] weapons;
public int currentWeapon;
*/
// Use this for initialization
void Start() {
//weapons[currentWeapon].attackSpeed = 1f;
health = 10;
original = health;
weapons[currentWeapon].attackSpeed = 1f;
Player = GetComponent<Rigidbody2D>();
myAnimator = GetComponent<Animator>(); //required for animation *******
//SetWeaponStats();
......@@ -54,7 +57,7 @@ public class ArenaCombatControl : MonoBehaviour {
private void Attack() {
attackSpeedCooldown -= Time.deltaTime;
if (Input.GetKeyDown(KeyCode.Space) && attackSpeedCooldown <= 0) {
//attackSpeedCooldown = weapons[currentWeapon].attackSpeed;
attackSpeedCooldown = weapons[currentWeapon].attackSpeed;
myAnimator.SetBool("attack", true);
}
else {
......@@ -128,7 +131,32 @@ public class ArenaCombatControl : MonoBehaviour {
canJump = true;
}
}
IEnumerator waitandload()
{
yield return new WaitForSeconds(2.0f);
SceneManager.LoadScene("mainmenu");
}
public void ApplyDamageP(int damage)
{
health -= damage;
if (health <= 0)
{
StartCoroutine("waitandload");
}
}
//
public void ChangeHealthBarp(int damage)
{
GameObject healthbar = GameObject.Find("healthbarFullp");
float newsize = healthbar.transform.localScale.x - ((damage / original) * 0.3f);
healthbar.transform.localScale = new Vector3(newsize,0.3f,1f);
if(health <= 0)
{
healthbar.GetComponent<SpriteRenderer>().enabled = false;
}
}
/* can change stats simply in the inspector for dynamic purposes :)
//a few proposed weapon stats
private void SetWeaponStats()
......
......@@ -20,38 +20,14 @@ public class CharacterStats : MonoBehaviour {
public int defense; // Players resistance to damage
public int agility; // Players movement and attack speed
public int luck; // Players chance of getting more money
// For weapons (player will technically hold every weapon in the array, but it will switch between them)
public WeaponStats[] weapons;
public static int currentWeapon;
public SpriteRenderer weaponSpriteRenderer;
// Use this for initialization
void Start () {
weaponSpriteRenderer = GetComponent<SpriteRenderer>();
//to find the weapon sprite
if (weaponSpriteRenderer == null) {
GameObject weaponSprite = GameObject.FindWithTag("currentWeapon");
if (weaponSprite != null) {
//Debug.Log("found");
weaponSpriteRenderer = weaponSprite.GetComponent<SpriteRenderer>();
}
}
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
updateWeapon();
}
void updateWeapon() {
if (weapons[currentWeapon].image == null) {
Debug.Log("A weapon image was not set properly! (it's NULL)");
}
else {
weaponSpriteRenderer.sprite = weapons[currentWeapon].image;
}
}
}
}
......@@ -7,7 +7,7 @@ public class EnemyAI : MonoBehaviour {
private Transform target;
private Rigidbody2D Enemy;
private Animator myAnimator;
float enemyHealth;
public float enemyHealth, original;
float playerHealth;
private bool LookRight = false;
public bool set;
......@@ -16,8 +16,9 @@ public class EnemyAI : MonoBehaviour {
void Start() {
enemyHealth = EnemyHealth.health;
playerHealth = PlayerHealth.health;
enemyHealth = 10;
original = enemyHealth;
playerHealth = ArenaCombatControl.health;
root = new DecisionTree();
......@@ -35,7 +36,25 @@ public class EnemyAI : MonoBehaviour {
root.search();
}
public void ChangeHealthBare(int damage)
{
GameObject healthbar = GameObject.Find("healthbarFulle");
float newsize = healthbar.transform.localScale.x - ((damage / original)*0.3f);
healthbar.transform.localScale = new Vector3(newsize, 0.3f, 1f);
if (enemyHealth <= 0)
{
healthbar.GetComponent<SpriteRenderer>().enabled = false;
}
}
public void ApplyDamageE(int damage)
{
enemyHealth -= damage;
if (enemyHealth <= 0)
{
Destroy(gameObject);
}
}
public bool d_inAttackRange() {
if (Vector3.Distance(transform.position, target.position) < 1.5f) {
......@@ -58,7 +77,7 @@ public class EnemyAI : MonoBehaviour {
}
public bool d_isPlayerHpLow() {
if ((PlayerHealth.health/2) < playerHealth) {
if ((ArenaCombatControl.health/2) < playerHealth) {
return true;
}
return false;
......@@ -66,7 +85,7 @@ public class EnemyAI : MonoBehaviour {
public bool d_isHpLow() {
if ((EnemyHealth.health/2) < enemyHealth) {
if ((original/2) < enemyHealth) {
return true;
}
return false;
......
......@@ -5,28 +5,17 @@ public class EnemyHealth : MonoBehaviour {
/*SCRIPT FOR WHEN THE PLAYER IS HIT, NOT THE ENEMY*/
public static float health;
void Start() {
health = Random.Range(50, 500);
void Start()
{
GameObject weapon = GameObject.Find("weapon");
Physics2D.IgnoreCollision(weapon.GetComponent<Collider2D>(), GetComponent<Collider2D>());
}
// Update is called once per frame
void Update() {
if (health <= 0) {
Destroy(gameObject);
}
}
//allow the player to only be hurt by the enemy
void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.tag == "Enemy") {
//apply damage if the collision is the player
void OnCollisionEnter2D(Collision2D other) {
if (other.gameObject.name == "Player") {
Debug.Log("hit");
health = health - 1;
other.gameObject.SendMessage("ApplyDamageP", 1, SendMessageOptions.DontRequireReceiver);
other.gameObject.SendMessage("ChangeHealthBarp", 1, SendMessageOptions.DontRequireReceiver);
}
}
......
......@@ -8,7 +8,7 @@ public class EnterDoor : MonoBehaviour {
public string sceneName;
public GameObject player;
public Transform[] spawnPoint;
public static int spawnPointIndex = 3;
public static int spawnPointIndex;
public Text doorText;
//teleporting player when leaving back to the door they initially entered (to target)
......
......@@ -5,27 +5,18 @@ using UnityEngine.SceneManagement;
public class PlayerHealth : MonoBehaviour {
public static float health;
EnterDoor spawn;
// Update is called once per frame
void Update () {
if (health <= 0) {
OnLevelWasLoaded();
}
}
void Start()
{
GameObject weapon = GameObject.Find("weapon");
Physics2D.IgnoreCollision(weapon.GetComponent<Collider2D>(), GetComponent<Collider2D>());
}
//allow the player to only be hurt by the enemy
void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.tag == "Enemy") {
void OnCollisionEnter2D(Collision2D other) {
if (other.gameObject.name == "Enemy") {
Debug.Log("hit");
health = health - 1;
other.gameObject.SendMessage("ApplyDamageE", 1, SendMessageOptions.DontRequireReceiver);
other.gameObject.SendMessage("ChangeHealthBare", 1, SendMessageOptions.DontRequireReceiver);
}
}
void OnLevelWasLoaded() {
spawn.player.transform.position = spawn.spawnPoint[EnterDoor.spawnPointIndex].position;
}
}
\ No newline at end of file
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class PlayerMovement : MonoBehaviour
{
......@@ -122,6 +122,7 @@ public class PlayerMovement : MonoBehaviour
}
}
}
}
......@@ -8,7 +8,7 @@ public class ShopMenu : MonoBehaviour {
// Update is called once per frame
void Update () {
if (Input.GetKeyDown("f")) { // to leave the shop back to the main scene
if (Input.GetKeyDown("f")) {
SceneManager.LoadScene(sceneName);
}
}
......
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