コード例 #1
0
    void OnTriggerExit(Collider collider)
    {
        if (collider.GetComponent <Unit>() && !collider.GetComponent <Collectable>() &&
            !collider.GetComponent <Unit>().faction.Equals(this.GetComponentInParent <Unit>().faction))
        {
            NearsRTSGameObjects.Remove(collider.GetComponent <Unit>());
        }

        if (collider.GetComponent <WalkingUnit>() &&
            collider.GetComponent <WalkingUnit>().faction.Equals(this.GetComponentInParent <WalkingUnit>().faction))
        {
            NearFriendliesUnit.Remove(collider.GetComponent <WalkingUnit>());
        }
    }
コード例 #2
0
    void Update()
    {
        for (int i = 0; i < NearFriendliesUnit.Count; i++)
        {
            if (NearFriendliesUnit[i] == null)
            {
                NearFriendliesUnit.RemoveAt(i);
            }
        }

        for (int i = 0; i < NearsRTSGameObjects.Count; i++)
        {
            if (NearsRTSGameObjects[i] == null)
            {
                NearsRTSGameObjects.RemoveAt(i);
            }
        }

        this.GetComponentInParent <UnitAttack>().Aggro(AggroNearestOne(NearsRTSGameObjects));
    }