private void Start() { if (transform.root != null) { faction = transform.root.GetComponent <FactionAccess>().faction; } FactionUnits.RegisterUnit(this); }
public override NodeResult Execute() { AITargeter aiSource = source as AITargeter; if (FactionUnits.NoEnemies((source as AITargeter).stats)) { return(NodeResult.Failure); } targeter = FactionUnits.FindClosestEnemy(source as AITargeter); if (Vector3.Distance(targeter.transform.position, aiSource.transform.position) < range) { return(NodeResult.Success); } return(NodeResult.Failure); }
public override NodeResult Execute() { if (FactionUnits.NoEnemies((source as AITargeter).stats)) { return(NodeResult.Failure); } if (!(source as AITargeter).moving.IsIdle) { return(NodeResult.Failure); } targeter = FactionUnits.FindClosestEnemy(source as AITargeter); (source as AITargeter).moving.Attach(mode, GenerateDirPathToTarget(mode, (source as AITargeter), targeter)); return(NodeResult.Success); }
private void OnDestroy() { FactionUnits.UnregisterUnit(this); }
// Note: Health doesn't fit here, because different subunits can have different hp. // Structural Hp does. public void OnSpawned(StringData faction) { FactionUnits.TryUnregisterUnit(this); this.faction = faction; }