Exemple #1
0
    public override void Execute()
    {
        _floodWaterTilesCommand = new FloodWaterTilesCommand();
        _floodWaterTilesCommand.Execute();

        _floodClusterCommands = new Stack <FloodClusterCommand>();
        _pumpWaterCommands    = new Stack <PumpWaterClusterCommand>();
        List <WaterCluster> clustersToFlood = new List <WaterCluster>();

        // Flooding may change the clusters list
        // Thus, we can't do it in this foreach, because we use its enumerator
        foreach (WaterCluster cluster in WaterClusterManager.Instance.clusters)
        {
            cluster.RecountFloodLevel();

            PumpWaterClusterCommand pumpCommand = new PumpWaterClusterCommand(cluster);
            pumpCommand.Execute();
            _pumpWaterCommands.Push(pumpCommand);

            if (cluster.FloodLevel >= WaterClusterManager.floodThreshold)
            {
                clustersToFlood.Add(cluster);
            }
        }
        foreach (WaterCluster cluster in clustersToFlood)
        {
            FloodClusterCommand floodClusterCommand = new FloodClusterCommand(cluster);
            floodClusterCommand.Execute();
            _floodClusterCommands.Push(floodClusterCommand);
        }
        _recreateClustersCommand = new CreateClustersCommand();
        _recreateClustersCommand.Execute();
    }
Exemple #2
0
    public void RecreateClusters()
    {
        AreClustersCreated = false;
        CreateClustersCommand createClustersCommand = new CreateClustersCommand
        {
            isUndoable = false
        };

        CommandManager.Instance.ExecuteCommand(createClustersCommand);
        AreClustersCreated = true;
        OnClustersCreated?.Invoke();
    }