コード例 #1
0
        private static void Update()
        {
            while (true)
            {
                renderQueue();
                if (battleMode)
                {
                    BattleGrid.Update();
                    bool quit = BattleGrid.HandleKeys();
                    if (quit)
                    {
                        break;
                    }
                    goto end;
                }
                bool exit = Controls.HandleKeys();

                if (exit)
                {
                    break;
                }
end:
                int t = 0;
            }

            Terminal.Close();
        }
コード例 #2
0
        public void moveToPlayer()
        {
            if (path.Count < 0)
            {
                return;
            }
            Random rnd  = new Random();
            int    dice = rnd.Next(1, 11);

            if (dice == 6)
            {
                return;
            }
            // Store the prevous position and make it not blocked
            //Then block the current position. This stops the player from walking ontop of this gameobject

            previousPosition = position;
            Rogue.GameWorld.Map.tiles[(int)position.X, (int)position.Y].blocked = false;
            if (path.Count == 0)
            {
                Rogue.battleMode = true;
                return;
            }
            if (path.Count - 2 < 0)
            {
                // Sometimes the path length is only 1 (right next to the player)
                position.X = path[0].X;
                position.Y = path[0].Y;

                BattleGrid.Start('@', 'G');
            }
            else
            {
                position.X = path[path.Count - 2].X;
                position.Y = path[path.Count - 2].Y;
            }
            Rogue.GameWorld.Map.tiles[(int)position.X, (int)position.Y].blocked = true;
        }