public EventConsequence GetDeepCopy()
    {
        EventConsequence ec = new EventConsequence();

        ec.foodChange       = foodChange;
        ec.woodChange       = woodChange;
        ec.populationChange = populationChange;
        ec.tagChanges       = new List <TagChange>();
        for (int i = 0; i < tagChanges.Count; ++i)
        {
            ec.tagChanges.Add(tagChanges[i].GetDeepCopy());
        }
        return(ec);
    }
 public bool IsPossibleConsequences(EventConsequence ec)
 {
     if ((_storage.food.Amount + ec.foodChange) < 0)
     {
         return(false);
     }
     if ((_storage.wood.Amount + ec.woodChange) < 0)
     {
         return(false);
     }
     if ((_storage.population.Amount + ec.populationChange) < 0)
     {
         return(false);
     }
     return(true);
 }
    protected IEnumerator PlayStepsCoroutine()
    {
        //  StartEvenement
        //  Update resources + Evenement Consequence (Same Frame)
        //  Gestion de la base
        //  Resource en Prévision (Panel Résumé)
        //  Save
        while (true)
        {
            int selectedBackGround = Random.Range(0, backgrounds.Length);
            for (int i = 0; i < backgrounds.Length; ++i)
            {
                backgrounds[i].gameObject.SetActive(i == selectedBackGround);
            }

            //  Evenement

            GameUIManager.Instance.OnEventPart();
            _eventConsequence = null;
            EvenementHandler.Instance.StartEvent(TurnContainer.Instance.turnCounter.turn, TagContainer.Instance.tags, OnEventEnded);
            while (_eventConsequence == null)
            {
                yield return(new WaitForEndOfFrame());
            }

            Debug.Log("UpdateIncome");
            UpdateIncome();
            Debug.Log(_eventConsequence);
            EventConsequence(_eventConsequence);
            _eventConsequence = null;

            _waitingForNextStepClick = true;
            GameUIManager.Instance.OnConstructionPart();
            //  Gestion de la base

            while (_waitingForNextStepClick)
            {
                yield return(new WaitForEndOfFrame());
            }

            GameUIManager.Instance.OnEndStepPart();
            ++TurnContainer.Instance.turnCounter.turn;
            SaveManager.Instance.Save();
        }
    }
 protected void EventConsequence(EventConsequence ec)
 {
     StorageManager.Instance.storage.food.Amount       += ec.foodChange;
     StorageManager.Instance.storage.wood.Amount       += ec.woodChange;
     StorageManager.Instance.storage.population.Amount += ec.populationChange;
     for (int i = 0; i < ec.tagChanges.Count; ++i)
     {
         if (ec.tagChanges[i].isAnAddition)
         {
             bool alreadyExist = false;
             for (int j = 0; j < TagContainer.Instance.tags.Count; ++j)
             {
                 if (TagContainer.Instance.tags[j] == ec.tagChanges[i].tag)
                 {
                     alreadyExist = true;
                     break;
                 }
             }
             if (!alreadyExist)
             {
                 TagContainer.Instance.tags.Add(ec.tagChanges[i].tag);
             }
         }
         else
         {
             for (int j = 0; j < TagContainer.Instance.tags.Count; ++j)
             {
                 if (TagContainer.Instance.tags[j] == ec.tagChanges[i].tag)
                 {
                     TagContainer.Instance.tags.RemoveAt(j);
                     break;
                 }
             }
         }
     }
 }
 protected void OnEventEnded(EventConsequence ec)
 {
     _eventConsequence = ec;
 }
 public Choice(string txt, EventConsequence e)
 {
     eventConsequence = e;
     text             = txt;
 }