Beispiel #1
0
    public int DestroyAllUnitsOfColour(UnitColour colour)
    {
        int numRemoved = 0;

        for (int i = units.Count - 1; i >= 0; i--)
        {
            RecruitmentAreaUnit unit = units[i] as RecruitmentAreaUnit;
            if (unit.GetColour() == colour)
            {
                DestroyObject(unit.gameObject);
                units.RemoveAt(i);
                numRemoved++;
            }
        }
        collectingState[(int)colour].collecting = false;
        return(numRemoved);
    }
Beispiel #2
0
    void UpdateCollecting()
    {
        int count = units.Count;

        for (int j = 0; j < count; j++)
        {
            RecruitmentAreaUnit unit = units[j] as RecruitmentAreaUnit;
            int i = (int)unit.GetColour();
            if (collectingState[i].collecting)
            {
                unit.WalkToGoal(collectingState[i].doorPosition, collectingState[i].timeRemaining);
            }
        }
        for (int i = 0; i < collectingState.Length; ++i)
        {
            collectingState[i].timeRemaining -= Time.deltaTime;
            if (collectingState[i].timeRemaining <= 0)
            {
                collectingState[i].collecting = false;
            }
        }
    }