예제 #1
0
        public override void Run(TimeSpan timeElapsed)
        {
            TargetPosition = Source.Position + PositionChange;

            if (TargetPosition == Source.Position)
            {
                return;
            }

            if (Map.IsTileWalkable(TargetPosition.X, TargetPosition.Y))
            {
                var ents = Map.GameObjects.GetEntities(TargetPosition).ToArray();

                if (ents.Length == 0)
                {
                    Source.MoveBy(PositionChange);

                    if (Source == Map.ControlledGameObject)
                    {
                        if (PositionChange == Directions.West)
                        {
                            BasicTutorial.GameState.Dungeon.Messages.Print("You move west.", BasicTutorial.MessageConsole.MessageTypes.Status);
                        }
                        else if (PositionChange == Directions.East)
                        {
                            BasicTutorial.GameState.Dungeon.Messages.Print("You move east.", BasicTutorial.MessageConsole.MessageTypes.Status);
                        }
                        else if (PositionChange == Directions.North)
                        {
                            BasicTutorial.GameState.Dungeon.Messages.Print("You move north.", BasicTutorial.MessageConsole.MessageTypes.Status);
                        }
                        else if (PositionChange == Directions.South)
                        {
                            BasicTutorial.GameState.Dungeon.Messages.Print("You move south.", BasicTutorial.MessageConsole.MessageTypes.Status);
                        }
                    }
                }
                else
                {
                    foreach (var item in ents)
                    {
                        BumpGameObject bump = new BumpGameObject(Source, (GameObjects.GameObjectBase)item);
                        BasicTutorial.GameState.Dungeon.ActionProcessor.PushAndRun(bump);
                    }
                }
            }
            else
            {
                BumpTile bump = new BumpTile(Source, Map[TargetPosition]);
                BasicTutorial.GameState.Dungeon.ActionProcessor.PushAndRun(bump);
            }

            Finish(ActionResult.Success);
        }
예제 #2
0
        public override void Run(TimeSpan timeElapsed)
        {
            TargetPosition = Source.Position + PositionChange;

            if (TargetPosition == Source.Position)
            {
                return;
            }

            bool moved = Source.MoveIn(PositionChange);

            if (!moved)
            {
                Tiles.Tile tile = Source.CurrentMap.GetTerrain <Tiles.Tile>(TargetPosition);
                if (!tile.IsWalkable)
                {
                    BumpTile bump = new BumpTile(Source, tile);
                    BasicTutorial.GameState.Dungeon.ActionProcessor.PushAndRun(bump);
                }
                else
                {
                    foreach (BasicEntity item in Source.CurrentMap.GetEntities <BasicEntity>(TargetPosition)) // Something blocked us
                    {
                        BumpGameObject bump = new BumpGameObject(Source, item);
                        BasicTutorial.GameState.Dungeon.ActionProcessor.PushAndRun(bump);
                    }
                }
            }
            else if (Source == ((Tiles.TileMap)Source.CurrentMap).ControlledGameObject) // We are the player
            {
                if (PositionChange == Direction.LEFT)
                {
                    BasicTutorial.GameState.Dungeon.Messages.Print("You move west.", BasicTutorial.MessageConsole.MessageTypes.Status);
                }
                else if (PositionChange == Direction.RIGHT)
                {
                    BasicTutorial.GameState.Dungeon.Messages.Print("You move east.", BasicTutorial.MessageConsole.MessageTypes.Status);
                }
                else if (PositionChange == Direction.UP)
                {
                    BasicTutorial.GameState.Dungeon.Messages.Print("You move north.", BasicTutorial.MessageConsole.MessageTypes.Status);
                }
                else if (PositionChange == Direction.DOWN)
                {
                    BasicTutorial.GameState.Dungeon.Messages.Print("You move south.", BasicTutorial.MessageConsole.MessageTypes.Status);
                }
            }

            Finish(ActionResult.Success);
        }