Exemple #1
0
    public void AddTimedLifeModifer(TurnPlayingObject objectToModify, TimedLifeModifier modifier)
    {
        TurnPlayingObjectWithTimedModifiers objectGroup = allPlayingObjects.Find(x => x.mainObject == objectToModify);

        if (objectGroup != null)
        {
            objectGroup.timedModifers.Add(modifier);
        }
        else
        {
            Debug.Log("object not found");
        }
    }
Exemple #2
0
    public void AddObject(TurnPlayingObject objectToAdd)
    {
        Debug.Log("object to add" + (objectToAdd != null) + ((Unit)objectToAdd).positionInGrid);

        TurnPlayingObjectWithTimedModifiers adaptedObjectToAdd       = new TurnPlayingObjectWithTimedModifiers(objectToAdd);
        IEnumerator <TurnPlayingObjectWithTimedModifiers> enumerator = allPlayingObjects.GetEnumerator();

        int position = 0;

        while (enumerator.MoveNext() && enumerator.Current.mainObject.GetInitiative() > objectToAdd.GetInitiative())
        {
            position++;
        }

        Debug.Log("unit added at position " + position);
        allPlayingObjects.Insert(position, adaptedObjectToAdd);
    }
Exemple #3
0
    // when all units have either do nothing or are unable to do something
    public void LaunchTurn()
    {
        Debug.Log("new turn");
        if (allPlayingObjects.Count > 0)
        {
            foreach (var playingObject in allPlayingObjects)
            {
                playingObject.mainObject.SetBudget(playingObject.mainObject.GetBudget() + playingObject.mainObject.GetIncrement());
                playingObject.shouldPlay = true;
            }

            currentPlayingObject = allPlayingObjects [0];
            currentPlayingObject.BeginTurn();
        }
        else
        {
            Debug.Log("no unit");
        }
    }
Exemple #4
0
    private void OnTurnEnded()
    {
        int previouslyPlayingObjectIndex = allPlayingObjects.FindIndex(x => currentPlayingObject == x);
        int nbObjects = allPlayingObjects.Count;

        if (previouslyPlayingObjectIndex == nbObjects - 1 && ShouldLaunchTurn())
        {
            //begin the next turn
            LaunchTurn();
        }
        else
        {
            currentPlayingObject = allPlayingObjects [(previouslyPlayingObjectIndex + 1) % nbObjects];
            if (currentPlayingObject.shouldPlay)
            {
                currentPlayingObject.BeginTurn();
            }
            else
            {
                OnTurnEnded();
            }
        }
    }