Beispiel #1
0
        public void Enter(BaseEntity entity)
        {
            Console.WriteLine("Entity is now storing resources");
            Gatherer gatherer = entity as Gatherer;

            gatherer.path.Set(Path.GetPathTo(GameWorld.instance.tiles.tiles[TileSystem.GetIndexOfTile(gatherer.position)], GameWorld.instance.tiles.tiles[GameWorld.instance.buildings[0].entrancePosition]));
        }
        public void Enter(BaseEntity entity)
        {
            Console.WriteLine("Entity is now gathering resources.");
            Gatherer gatherer = entity as Gatherer;

            gatherer.path.Set(Path.GetPathTo(GameWorld.instance.tiles.tiles[TileSystem.GetIndexOfTile(gatherer.position)], Material.IDToMaterial(gatherer.matID)));
        }
        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();
            }
        }
        public StorageBuilding(Vector2D pos, Vector2D scale) : base(Building_Types.StorageBuilding, pos, scale)
        {
            sprite = Resources.StorageShed_01;

            entrancePosition = TileSystem.GetIndexOfTile(position + scale - new Vector2D(1, 1));
            //Console.WriteLine(entrancePosition);
            //entrancePosition = GameWorld.instance.tiles.tiles[TileSystem.GetIndexOfTile(position + scale)].position;
        }
Beispiel #5
0
        private void SetTiles()
        {
            GameWorld world = GameWorld.instance;

            for (int i = TileSystem.GetIndexOfTile(position); i < TileSystem.GetIndexOfTile(position + new Vector2D(0, scale.y)); i += world.tiles.tilesPerRow)
            {
                for (int j = 0; j < scale.x / BaseTile.tileWidth; j++)
                {
                    world.tiles.tiles[i + j].isWalkable = false;
                }
            }
        }