public void GetTargetReferenceFromRallyPoint(GameObject other) { Creep newCreep = other.GetComponent <Creep>(); scrCreepEngagementHandler _newCreepEngagementHandler = newCreep.GetComponent <scrCreepEngagementHandler>(); if (newCreep._CreepHealth.CurrentHealth > 0f) //Extra check needed in case a creep that just died "slides" into the collider { DefenderCreepList.Add(newCreep); foreach (DefenderEngagementHandler _defender in Defenders) //Send all defenders to engage as none { if (_defender.defenderIsAlive && !_defender.thisDefenderIsEngagedAsMainTarget && !_defender.thisDefenderIsEngagedAsNoneTarget) { //print("Sent a defender as none target"); _defender.DefenderEngageNewTargetAsNone(newCreep); } } for (int i = 0; i < Defenders.Count; i++) //Send a defender to engage as main { if (!Defenders[i].thisDefenderIsEngagedAsMainTarget && Defenders[i].defenderIsAlive && _newCreepEngagementHandler.CurrentTarget == null) { //print("Sent a defender to engage new target: " + newCreep); Defenders[i].DefenderEngageNewTargetAsMain(Defenders[i], newCreep); return; //Only send one } } } }
private void InformCreepTarget(Creep _target) { CurrentCreepTarget = _target; scrCreepEngagementHandler _currentTargetEngagementHandler = CurrentCreepTarget.GetComponent <scrCreepEngagementHandler>(); _currentTargetEngagementHandler.AddDefenderToCreepTargetsList(this); _currentTargetEngagementHandler.SetThisCreepIsEngaged(); defenderMovement.MakeDefenderMoveTowardsTarget(); }
public void Add(Creep c) { creeps.Add(c); c.OnPathFinished += () => { }; c.GetComponent <Health>().OnDeath += () => { GameObject.FindObjectOfType <Player>().Money += c.Money; creeps.Remove(c); if (creeps.Any() == false) { OnDeath(); } }; }
private static ICreepSender GetSentCreep(Creep creep) { return(creep.GetComponent <ICreepSender>()); }