Skip to content
Snippets Groups Projects
Commit 076c1707 authored by I Gede Arya Raditya Parameswara's avatar I Gede Arya Raditya Parameswara
Browse files
parents eff93219 17ea9123
Branches
Tags
No related merge requests found
......@@ -125,7 +125,7 @@ public class EnemyAttack : MonoBehaviour
timer = 0f;
}
else if(nearestAttackable.gameObject == pet) {
Debug.Log("Enemy try to attack pet"); // ! Debug
// Debug.Log("Enemy try to attack pet"); // ! Debug
// If the pet has health to lose...
if (petHealth.currentHealth > 0)
{
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CanvasElementsManager : MonoBehaviour
{
GameObject[] petUIElements;
void Awake()
{
petUIElements = GameObject.FindGameObjectsWithTag("PetUI");
}
void Start()
{
GameObject pet = GameObject.FindGameObjectWithTag ("Pet");
if(pet != null)
{
setPetUIDisplayed(true);
}
else
{
setPetUIDisplayed(false);
}
}
public void setPetUIDisplayed(bool isDisplayed)
{
Debug.Log($"Pet UI Displayed: {isDisplayed}");
foreach(var petUIElement in petUIElements)
{
petUIElement.SetActive(isDisplayed);
}
}
}
fileFormatVersion: 2
guid: 1a6efe4df810cf5448c99498bd01e9a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -49,15 +49,14 @@ public class PetAttack : MonoBehaviour
GameObject PickEnemyToAttacked()
{
string currentTag = GetCurrentEnemyTag();
Debug.Log($"Current enemy tag: {currentTag}");
// Debug.Log($"Current enemy tag: {currentTag}"); // ! Debug
GameObject[] enemies = GameObject.FindGameObjectsWithTag(currentTag);
Debug.Log($"Skeleton watch {enemies.Length} enemies"); // ! Debug
// Debug.Log($"Skeleton watch {enemies.Length} enemies"); // ! Debug
if(enemies.Length > 0)
{
GameObject pickedEnemy = enemies[0];
float nearestDistToEnemy = Vector3.Distance(gameObject.transform.position, pickedEnemy.transform.position);
Debug.Log($"First enemy in skeleton iteration: {pickedEnemy.name}"); // ! Debug
foreach(var enemy in enemies)
{
float distToCurrentEnemy = Vector3.Distance(gameObject.transform.position, enemy.transform.position);
......@@ -71,7 +70,7 @@ public class PetAttack : MonoBehaviour
Debug.Log($"Nearest enemy from skeleton: {pickedEnemy.name}"); // ! Debug
return pickedEnemy;
}
Debug.Log("There are no enemy");
Debug.Log("There are no enemy"); // ! Debug
return null;
}
......
......@@ -11,25 +11,25 @@ public class PetHealth : MonoBehaviour
Animator anim;
AudioSource petAudio;
CanvasElementsManager canvasManager;
bool isDead;
bool damaged;
void Awake()
{
anim = GetComponent<Animator>();
petAudio = GetComponent<AudioSource>();
Debug.Log("PetHealth script loaded");
GameObject[] petUIElements = GameObject.FindGameObjectsWithTag("PetUI");
foreach(var petUIElement in petUIElements)
{
Debug.Log(petUIElement.name);
petUIElement.SetActive(true);
}
GameObject hudCanvas = GameObject.Find("HUDCanvas");
canvasManager = hudCanvas.GetComponent<CanvasElementsManager>();
currentHealth = startingHealth;
}
void Start()
{
canvasManager.setPetUIDisplayed(true);
}
void Update()
{
......@@ -74,5 +74,6 @@ public class PetHealth : MonoBehaviour
enemyMovement.petExist = false;
}
}
canvasManager.setPetUIDisplayed(false);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment