public static bool Fireball(GameObject user)
        {
            MessageLog.AddMessage("Fireball: " + user.Name + " casts Fireball.", "white");

            GameObject spell = new GameObject("Fireball", Tiles.Effect.FireballTile, user.X, user.Y);

            spell.Spell         = true;
            spell.AlwaysVisible = false;

            Rogue.GameWorld.Objects.Add(spell);

            Rendering.RenderAll();
            Terminal.Refresh();

            ThrowingAnimation(spell, user);

            MessageLog.AddMessage("Fireball: The fireball explodes.", "white");

            foreach (GameObject obj in Rogue.GameWorld.Objects)
            {
                if (obj.Fighter != null && obj.Fighter.AI.Type != Constants.AI.None && obj.X == spell.X && obj.Y == spell.Y)
                {
                    int amount = 12;
                    MessageLog.AddMessage("Fireball: " + obj.Name + " is damaged for " + amount.ToString() + " Hit Points.", "white");

                    obj.Fighter.TakeDamage(amount);
                    break;
                }
            }

            Rogue.GameWorld.Objects.Remove(spell);

            return(false);
        }
        public static bool Throw(GameObject item, GameObject user)
        {
            MessageLog.AddMessage("Throw: " + user.Name + " throws " + item.Name + ".", "white");

            GameObject thrownItem = item.Clone();

            thrownItem.Item.Count = 1;
            thrownItem.X          = user.X;
            thrownItem.Y          = user.Y;

            Rogue.GameWorld.Objects.Add(thrownItem);

            Rendering.RenderAll();
            Terminal.Refresh();

            ThrowingAnimation(thrownItem, user);

            return(false);
        }
        internal void Move(int dx, int dy)
        {
            if (this != Rogue.GameWorld.Player)
            {
                if (dx == 0 && dy == -1)
                {
                    if (Fighter.Direction != 0)
                    {
                        Fighter.Direction = 0;
                        return;
                    }
                }
                if (dx == -1 && dy == 0)
                {
                    if (Fighter.Direction != 90)
                    {
                        Fighter.Direction = 90;
                        return;
                    }
                }
                if (dx == 0 && dy == 1)
                {
                    if (Fighter.Direction != 180)
                    {
                        Fighter.Direction = 180;
                        return;
                    }
                }
                if (dx == 1 && dy == 0)
                {
                    if (Fighter.Direction != 270)
                    {
                        Fighter.Direction = 270;
                        return;
                    }
                }
            }

            if (!GameMap.Blocked(X + dx, Y + dy))
            {
                if (this == Rogue.GameWorld.Player || FoV.InFov(Rogue.GameWorld.Player.X, Rogue.GameWorld.Player.Y, X, Y, Rogue.GameWorld.Player))
                {
                    if (dx == 1 || dx == -1)
                    {
                        for (int x = 0; x < 64 / Constants.MoveSmoothSteps; x++)
                        {
                            OffsetX += Constants.MoveSmoothSteps * dx;
                            if (this != Rogue.GameWorld.Player)
                            {
                                Rendering.RenderAll(this);
                                Draw("white", true);
                                Terminal.Refresh();
                            }
                            else
                            {
                                Rendering.RenderAll();
                            }
                        }

                        OffsetX = 0;
                    }
                    if (dy == 1 || dy == -1)
                    {
                        for (int x = 0; x < 64 / Constants.MoveSmoothSteps; x++)
                        {
                            OffsetY += Constants.MoveSmoothSteps * dy;
                            if (this != Rogue.GameWorld.Player)
                            {
                                Rendering.RenderAll(this);
                                Draw("white", true);
                                Terminal.Refresh();
                            }
                            else
                            {
                                Rendering.RenderAll();
                            }
                        }

                        OffsetY = 0;
                    }

                    if (this == Rogue.GameWorld.Player)
                    {
                        Camera.HandleMoveCamera(dx, dy);
                    }
                }

                X += dx;
                Y += dy;
            }
        }
        public static Constants.PlayerAction HandleKeys()
        {
            int key = Terminal.Read();

            if (Terminal.Peek() != key)
            {
                if (Rogue.GameWorld.State == Constants.GameState.Playing)
                {
                    if (RotateLeft.Contains(key))
                    {
                        for (int i = 0; i < 90; i += Constants.TurnSteps)
                        {
                            Rogue.GameWorld.Player.Fighter.Direction += Constants.TurnSteps;
                            if (Rogue.GameWorld.Player.Fighter.Direction >= 360)
                            {
                                Rogue.GameWorld.Player.Fighter.Direction -= 360;
                            }
                            Rendering.RenderAll();
                        }
                        return(Constants.PlayerAction.UsedTurn);
                    }
                    else if (RotateRight.Contains(key))
                    {
                        for (int i = 0; i < 90; i += Constants.TurnSteps)
                        {
                            Rogue.GameWorld.Player.Fighter.Direction -= Constants.TurnSteps;
                            if (Rogue.GameWorld.Player.Fighter.Direction < 0)
                            {
                                Rogue.GameWorld.Player.Fighter.Direction += 360;
                            }
                            Rendering.RenderAll();
                        }
                        return(Constants.PlayerAction.UsedTurn);
                    }
                    else if (LeftMovement.Contains(key))
                    {
                        if (Rogue.GameWorld.Player.Fighter.Direction == 90)
                        {
                            Rogue.GameWorld.Player.PlayerMoveOrAttack(-1, 0);
                        }
                        else
                        {
                            Rogue.GameWorld.Player.Move(-1, 0);
                        }
                        return(Constants.PlayerAction.UsedTurn);
                    }
                    else if (RightMovement.Contains(key))
                    {
                        if (Rogue.GameWorld.Player.Fighter.Direction == 270)
                        {
                            Rogue.GameWorld.Player.PlayerMoveOrAttack(1, 0);
                        }
                        else
                        {
                            Rogue.GameWorld.Player.Move(1, 0);
                        }
                        return(Constants.PlayerAction.UsedTurn);
                    }
                    else if (UpMovement.Contains(key))
                    {
                        if (Rogue.GameWorld.Player.Fighter.Direction == 0)
                        {
                            Rogue.GameWorld.Player.PlayerMoveOrAttack(0, -1);
                        }
                        else
                        {
                            Rogue.GameWorld.Player.Move(0, -1);
                        }
                        return(Constants.PlayerAction.UsedTurn);
                    }
                    else if (DownMovement.Contains(key))
                    {
                        if (Rogue.GameWorld.Player.Fighter.Direction == 180)
                        {
                            Rogue.GameWorld.Player.PlayerMoveOrAttack(0, 1);
                        }
                        else
                        {
                            Rogue.GameWorld.Player.Move(0, 1);
                        }
                        return(Constants.PlayerAction.UsedTurn);
                    }
                    else if (InventoryKey.Contains(key))
                    {
                        Item.DisplayInventory();
                    }
                    else if (SkipTurn.Contains(key))
                    {
                        return(Constants.PlayerAction.UsedTurn);
                    }
                    else if (key == Terminal.TK_G)
                    {
                        UseMethods.Fireball(Rogue.GameWorld.Player);
                    }
                    else if (ActionKeys.Contains(key))
                    {
                        foreach (GameObject item in Rogue.GameWorld.Objects)
                        {
                            if (item.Item != null && item.X == Rogue.GameWorld.Player.X && item.Y == Rogue.GameWorld.Player.Y)
                            {
                                item.Item.Pick(Rogue.GameWorld.Player);
                                return(Constants.PlayerAction.UsedTurn);
                            }
                        }

                        foreach (GameObject stairs in Rogue.GameWorld.Objects)
                        {
                            if (stairs.Downstairs && stairs.X == Rogue.GameWorld.Player.X && stairs.Y == Rogue.GameWorld.Player.Y)
                            {
                                MapMethods.NextLevel();
                                return(Constants.PlayerAction.UsedTurn);
                            }
                            if (stairs.Upstairs && stairs.X == Rogue.GameWorld.Player.X && stairs.Y == Rogue.GameWorld.Player.Y)
                            {
                                return(MapMethods.PreviousLevel());
                            }
                        }
                    }
                }
            }

            if (EscapeKeys.Contains(key))
            {
                return(Constants.PlayerAction.ExitGame);
            }

            return(Constants.PlayerAction.NotUsedTurn);
        }
        private static void ThrowingAnimation(GameObject obj, GameObject user)
        {
            for (int times = 0; times < Constants.SpellRange; times++)
            {
                if (user.Fighter.Direction == 90 || user.Fighter.Direction == 270)
                {
                    int dx = user.Fighter.Direction == 90 ? -1 : 1;

                    if (GameMap.MapBlocked(obj.X + dx, obj.Y))
                    {
                        break;
                    }
                    if (CommonMethods.TargetInCoordinate(obj.X, obj.Y))
                    {
                        break;
                    }

                    for (int x = 0; x < 64 / Constants.MoveSmoothSteps; x++)
                    {
                        Rendering.RenderAll(obj);
                        obj.OffsetX += Constants.MoveSmoothSteps * dx;

                        if (GameMap.MapExplored(obj.X + dx, obj.Y) || FoV.InFov(user.X, user.Y, obj.X + dx, obj.Y, user))
                        {
                            obj.Draw("white", true);
                        }

                        Terminal.Refresh();
                    }

                    obj.X      += dx;
                    obj.OffsetX = 0;
                }
                else if (user.Fighter.Direction == 0 || user.Fighter.Direction == 180)
                {
                    int dy = user.Fighter.Direction == 0 ? -1 : 1;

                    if (GameMap.MapBlocked(obj.X, obj.Y + dy))
                    {
                        break;
                    }
                    if (CommonMethods.TargetInCoordinate(obj.X, obj.Y))
                    {
                        break;
                    }

                    for (int x = 0; x < 64 / Constants.MoveSmoothSteps; x++)
                    {
                        Rendering.RenderAll(obj);
                        obj.OffsetY += Constants.MoveSmoothSteps * dy;

                        if (GameMap.MapExplored(obj.X, obj.Y + dy) || FoV.InFov(user.X, user.Y, obj.X, obj.Y + dy, user))
                        {
                            obj.Draw("white", true);
                        }

                        Terminal.Refresh();
                    }

                    obj.Y      += dy;
                    obj.OffsetY = 0;
                }
            }
        }