// Gets character selected using the event and changes allyIndex to match the character selected character private void CharacterToHeal(MoveAttack charMA) { if (charMA.WhatAmI == CharacterType.Ally && _isHolding == true) { // reduces the charges PersistantController.SetPotCharges(PersistantController.GetPotCharges() - 1); _allyToHeal = charMA.GetComponent <AllyHealth>(); if (_allyToHeal == null) { Debug.LogError("No AllyHealth attached to " + _allyToHeal.name); } HealCharacter(); _isHolding = false; } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { playerInRange = true; player = other.gameObject; playerHealth = player.GetComponent <PlayerHealth>(); } if (other.gameObject.tag == "Ally") { if (!target) { targetInRange = true; target = other.gameObject; targetHealth = target.GetComponent <AllyHealth>(); } } }
void SpawnUnit() { bool isAnyEnemyInRange = Physics.OverlapSphere(_goldPile.transform.position, GlobalTargetBreachRadius, EnemiesLayer).Length > 0; if ((Squad.Count >= PopulationCap) || !isAnyEnemyInRange) { return; } GameObject ally = (GameObject)Instantiate(PikemanPrefab, _spawnPoint, this.transform.rotation); ally.transform.Translate(new Vector3(0, 0, 4)); Ally allyScript = ally.GetComponent <Ally>(); allyScript.goldPile = GameObject.Find("GoldPile"); allyScript.speed = 5; allyScript.EnemiesLayer = EnemiesLayer; allyScript.LocalTargetBreachRadius = LocalTargetBreachRadius; allyScript.LocalTargetSeekRadius = LocalTargetSeekRadius; allyScript.Home = gameObject; AllyHealth allyHealthScript = ally.GetComponent <AllyHealth>(); allyHealthScript.Squad = Squad; Squad.Add(ally); }