Beispiel #1
0
    private void GetNewPlans()
    {
        //Removing non-valid plans from existing dictionary
        Dictionary <Tile, GameObject> temp = new Dictionary <Tile, GameObject>(_tiles);

        foreach (KeyValuePair <Tile, GameObject> pair in temp)
        {
            if (_selectionArea.Contains(pair.Key.Position) == false)
            {
                pair.Value.SetActive(false);
                _jobIconsPool.Push(pair.Value);
                _tiles.Remove(pair.Key);
            }
        }
        temp.Clear();

        //Detecting new tiles where we can create a plan.
        foreach (Vector2Int position in _selectionArea.GetPositions())
        {
            Tile t = Utils.TileAt(position.x, position.y);
            if ((t is null) ||
                _tiles.ContainsKey(t) ||
                (t.Contents?.StaticObject is null && t.IsTraversable == false))
            {
                continue;
            }

            //(t.content?.staticObject != null && t.content.staticObject.GetType() != typeof(Vegetation))

            _tiles.Add(t, CreateJobIcon(t));
        }
    }
Beispiel #2
0
    protected List <Tile> GetTilesInArea()
    {
        List <Tile> tiles = new List <Tile>();

        foreach (Vector2Int position in _selectionArea.GetPositions())
        {
            Tile t = Utils.TileAt(position.x, position.y);
            if (t is null || !t.IsTraversable)
            {
                continue;
            }
            tiles.Add(t);
        }
        return(tiles);
    }
    private void GetNewTrees()
    {
        //Removing non-valid trees from existing dictionary
        Dictionary <Tree, GameObject> temp = new Dictionary <Tree, GameObject>(_trees);

        foreach (KeyValuePair <Tree, GameObject> pair in temp)
        {
            if (_selectionArea.Contains(pair.Key.Position) == false)
            {
                pair.Value.SetActive(false);
                _jobIconsPool.Push(pair.Value);
                _trees.Remove(pair.Key);
            }
        }
        temp.Clear();

        //Detecting new trees.
        foreach (Vector2Int position in _selectionArea.GetPositions())
        {
            Tile t = Utils.TileAt(position.x, position.y);
            if (t is null || t.Contents is null || t.Contents.StaticObject is null)
            {
                continue;
            }

            StaticObject staticObject = t.Contents.StaticObject;

            if (staticObject.GetType() != typeof(Tree) || (staticObject as Tree).HasCutJob)
            {
                continue;
            }

            if (_trees.ContainsKey(staticObject as Tree) == false)
            {
                _trees.Add(staticObject as Tree, CreateJobIcon(staticObject as Tree));
            }
        }
    }
Beispiel #4
0
    private void GetNewStaticJobs()
    {
        FilterTilesBySelectionArea <StaticJob>(_staticJobs);
        FilterTilesBySelectionArea <ConstructionPlan>(_constructionPlans);

        foreach (Vector2Int position in _selectionArea.GetPositions())
        {
            Tile t = Utils.TileAt(position.x, position.y);
            if (t?.Contents is null || t.Contents.StaticJobs.Count == 0 && t.Contents.ConstructionPlan is null)
            {
                continue;
            }

            foreach (StaticJob sj in t.Contents.StaticJobs)
            {
                _staticJobs.Add(sj);
            }

            if (t.Contents.ConstructionPlan != null)
            {
                _constructionPlans.Add(t.Contents.ConstructionPlan);
            }
        }
    }