Пример #1
0
    public List <MenuAction> getRiceTerrainActions(RiceTerrainTile riceTerrain)
    {
        //Debug.Log ("Actions for Terrain=" + riceTerrain.getChunkNumber ());
        List <MenuAction> actionsAvailable = new List <MenuAction>();

        if (!isActionInProgress(riceTerrain.getChunkNumber()))
        {
            List <int> actionsCurrentPhase = GameObject.FindGameObjectWithTag("Logic").GetComponent <PhaseManager>().getActionsInCurrentPhase();
            for (uint i = 0; i < actionsCurrentPhase.Count; ++i)
            {
                int currentAction = actionsCurrentPhase[(int)i];

                bool areDependenciesOk   = riceTerrain.checkDependencies(_action[currentAction]);
                bool hasBeenInvestigated = InvestigationManager.GetInstance().areInvestigated(_action[currentAction].getInvestigationRequired());
                bool hasWater            = WorldTerrain.GetInstance().riceChunkHasWater(riceTerrain.getChunkNumber()) || !_action[currentAction].needCanal;
                bool hasActionDone       = riceTerrain.isActionDone(currentAction);

                if (!hasActionDone && hasBeenInvestigated && areDependenciesOk && hasWater)
                {
                    ChunkAction        newAction = _action[currentAction];
                    PerformChunkAction callback  = this.addActionInProgress;
                    ChunkAction        t         = newAction.copyWithCallback(callback, riceTerrain.getChunkNumber());
                    actionsAvailable.Add((MenuAction)t);
                }
                //Debug.Log("  Action "+currentAction+" Dep="+areDependenciesOk+" Inv="+hasBeenInvestigated+" Water="+hasWater+" !Done="+!hasActionDone);
            }
        }
        actionsAvailable.Sort((x, y) => x.priority.CompareTo(y.priority));
        return(actionsAvailable);
    }
Пример #2
0
 public ChunkAction(int aID, bool aIsRequired, bool aHasPenalization, string aTitle, string aInfo, int aDuration, bool hasToAddAsDone, bool isCanalNeeded, int neededWorkers, int aPriotity)
 {
     id                     = aID;
     enabled                = true;
     isRequired             = aIsRequired;
     hasPenalization        = aHasPenalization;
     title                  = aTitle;
     info                   = aInfo;
     iconImgPath            = "";
     performChunkAction     = null;
     _dependencies          = new Dictionary <string, ArrayList>();
     doMenuAction           = performAction;
     chunk                  = -1;
     duration               = aDuration;
     tilesWorked            = 0;
     hoursElapsed           = 0;
     isFinished             = false;
     addAsDone              = hasToAddAsDone;
     needCanal              = isCanalNeeded;
     workersNeeded          = neededWorkers;
     _objectRequired        = new List <int> ();
     _animation             = new List <string>();
     _investigationRequired = new List <int> ();
     _actionPartners        = new List <int> ();
     priority               = aPriotity;
 }
Пример #3
0
    public ChunkAction copyWithCallback(PerformChunkAction callback, int chunk)
    {
        ChunkAction newAction = new ChunkAction(this.id, this.isRequired, this.hasPenalization, this.title, this.info, this.duration, this.addAsDone, this.needCanal, this.workersNeeded, this.priority);

        newAction.performChunkAction     = callback;
        newAction._objectRequired        = this._objectRequired;
        newAction._animation             = this._animation;
        newAction._investigationRequired = this._investigationRequired;
        newAction._actionPartners        = this._actionPartners;
        newAction.chunk    = chunk;
        newAction.priority = priority;

        return(newAction);
    }
Пример #4
0
 public void load(ActionManagerData actionManagerData)
 {
     //public ChunkAction(int aID, bool aIsRequired, bool aHasPenalization, string aTitle, string aInfo, int aDuration, bool hasToAddAsDone, bool isCanalNeeded, int neededWorkers)
     foreach (ActionInProgressData data in actionManagerData.ActionsInProgress)
     {
         ChunkAction        newAction = _action[data.ID];
         PerformChunkAction callback  = this.addActionInProgress;
         ChunkAction        t         = newAction.copyWithCallback(callback, data.ChunkNumber);
         t.hoursElapsed = data.HoursElapsed;
         if (t.hasAnimation())
         {
             t.starAnimationWithRemainingDistance(data.AnimationRemainingDistance);
         }
         t.performChunkAction(t);
     }
 }