void Awake() { health = GetComponentInChildren <Player_HealthController>(); movement = GetComponent <PlanetMovement>(); ability = GetComponent <ISpecialAbility>(); Camera.main.GetComponent <CameraFollow>().AddPlayers(gameObject.transform); }
void Start() { controller = GetComponentInParent <PlayerController>(); movement = GetComponentInParent <PlanetMovement>(); healthController = GetComponentInParent <Player_HealthController>(); controller.SetPlanetProtection(true); }
protected virtual void OnTriggerEnter2D(Collider2D other) { target = other.transform.root.GetComponent <Player_HealthController>(); //Hit the target if it is damageable if (target != null) { target.Heal(healthBonus); AudioManager1.instance.Play(healSound); Destroy(gameObject); } }
private void CheckHealth(Player_HealthController planet_HealthController, List <GameObject> hpBars, float playerHealth, Material playerMaterial) { if (planet_HealthController.health <= 4) { DeactivateHealthBars(hpBars, playerHealth); playerMaterial.color = colors[1]; for (int i = 0; i < hpBars.Count - 1; i++) { hpBars[i].SetActive(true); } } if (planet_HealthController.health <= 3) { DeactivateHealthBars(hpBars, playerHealth); playerMaterial.color = colors[2]; for (int i = 0; i < hpBars.Count - 2; i++) { hpBars[i].SetActive(true); } } if (planet_HealthController.health <= 2) { DeactivateHealthBars(hpBars, playerHealth); playerMaterial.color = colors[3]; for (int i = 0; i < hpBars.Count - 3; i++) { hpBars[i].SetActive(true); } } if (planet_HealthController.health <= 1) { DeactivateHealthBars(hpBars, playerHealth); for (int i = 0; i < hpBars.Count - 4; i++) { hpBars[i].SetActive(true); } } if (planet_HealthController.health <= 0) { DeactivateHealthBars(hpBars, playerHealth); for (int i = 0; i < hpBars.Count - 5; i++) { hpBars[i].SetActive(true); } } }
protected virtual void OnTriggerEnter2D(Collider2D other) { target = other.transform.root.GetComponent <Player_HealthController>(); //Hit the target if it is damageable if (target != null) { if (heal) { target.Heal(healthBonus); } else { target.Hit(damage, DamageType.physical, Vector2.zero, dmgStunTime); } Destroy(gameObject); } }
private void SortPlayers(List <GameObject> playerList) { _player1 = playerList[0]; if (playerList[0] != null) { _p1HealthController = playerList[0].GetComponent <Player_HealthController>(); } _player2 = playerList[1]; if (playerList[1] != null) { _p2HealthController = playerList[1].GetComponent <Player_HealthController>(); } _player3 = playerList[2]; if (playerList[2] != null) { _p3HealthController = playerList[2].GetComponent <Player_HealthController>(); } _player4 = playerList[3]; if (playerList[3] != null) { _p4HealthController = playerList[3].GetComponent <Player_HealthController>(); } }
void Start() { playerNr = GetComponent <PlayerController>().playerNr; healthController = GetComponent <Player_HealthController>(); playerUI = FindObjectOfType <PlayerUI>(); }
void Awake() { health = GetComponentInChildren <Player_HealthController>(); movement = GetComponent <PlanetMovement>(); }