/// <summary> /// Hurts player if detected by overlap sphere. /// </summary> public void Attack() { Debug.Log("Attack triggered"); Vector3 directionOfPlayer = GetPlayerDirection(); WeaponSelector.UseSelectedWeapon(directionOfPlayer); }
//===================================================================== #region Public methods //===================================================================== /// <summary> /// Initializes and acitvates the player card associated with the input /// index. /// </summary> /// <param name="index">The index of the player.</param> /// <param name="health">The Health component of the player.</param> public void ActivatePlayerCard(int index, Health health, WeaponSelector weaponSelector) { switch (index) { case 0: InitCard(_player0Card, health, weaponSelector); break; case 1: InitCard(_player1Card, health, weaponSelector); break; case 2: InitCard(_player2Card, health, weaponSelector); break; case 3: InitCard(_player3Card, health, weaponSelector); break; default: Debug.Log("Invalid player card index: " + index); break; } }
/// <summary> /// Initializes and activates the input player card. /// </summary> /// <param name="card"></param> /// <param name="health"></param> private void InitCard(GameObject card, Health health, WeaponSelector weaponSelector) { card.SetActive(true); card.GetComponentInChildren <UIHealthBar>().HealthSource = health; card.GetComponentInChildren <UIWeaponInfo>().WeaponSelector = weaponSelector; }
//===================================================================== #region Initialization //===================================================================== private new void InitVars() { NavMeshAgent = GetComponent <NavMeshAgent>(); WeaponSelector = GetComponentInChildren <WeaponSelector>(); }