Ejemplo n.º 1
0
 private void Start()
 {
     if (transform.root != null)
     {
         faction = transform.root.GetComponent <FactionAccess>().faction;
     }
     FactionUnits.RegisterUnit(this);
 }
Ejemplo n.º 2
0
    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);
    }
Ejemplo n.º 3
0
    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);
    }
Ejemplo n.º 4
0
 private void OnDestroy()
 {
     FactionUnits.UnregisterUnit(this);
 }
Ejemplo n.º 5
0
    // 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;
    }