Exemplo n.º 1
0
        public void Execute(BaseEntity entity)
        {
            Gatherer gatherer = entity as Gatherer;

            if (gatherer.path.isFinished && !gatherer.noMatsLeft)
            {
                if (gatherer.CollectMaterialsFromTile(GameWorld.instance.tiles.tiles[TileSystem.GetIndexOfTile(gatherer.position)]))
                {
                    gatherer.path.Set(Path.GetPathTo(GameWorld.instance.tiles.tiles[TileSystem.GetIndexOfTile(gatherer.position)], Material.IDToMaterial(gatherer.matID)));
                }
                else
                {
                    gatherer.state.ChangeState(StoreResourcesState.instance);
                }
                if (gatherer.path.Count == 0)
                {
                    //if (!gatherer.noMatsLeft) {
                    gatherer.state.ChangeState(StoreResourcesState.instance);
                    //} else {
                    gatherer.noMatsLeft = true;
                    //GameWorld.instance.materialCollection += gatherer.inventory;
                    //gatherer.inventory.Clear();
                    //}
                }

                ResourceGatherer.instance.RedrawBackground();
            }
        }