예제 #1
0
        /// <summary>
        /// Player controller method
        /// To be run in own thread
        /// </summary>
        public void Update()
        {
            ConsoleKeyInfo keypress;

            while (true)
            {
                // Grab Player input
                keypress = Console.ReadKey(true);

                // Move Left
                if (keypress.KeyChar == 'a')
                {
                    // Bumper to ensure we don't fall out of the array bounds
                    if (model[0].X == 0)
                    {
                        continue;
                    }

                    // Move each Cell in the players model, Left
                    foreach (Cell cell in model)
                    {
                        cell.X -= 1;
                    }
                }

                // Move Right
                if (keypress.KeyChar == 'd')
                {
                    // Bumper to ensure we don't fall out of the array bounds
                    if (model[4].X == X - 1)
                    {
                        continue;
                    }

                    // Move each Cell in the players model, Right
                    foreach (Cell cell in model)
                    {
                        cell.X += 1;
                    }
                }

                // Shoot
                if (keypress.KeyChar == ' ')
                {
                    ballisticManager.RegisterProjectile(new Projectile(model[2].X, model[2].Y - 1, -1));
                }
            }
        }