Exemplo n.º 1
0
Arquivo: Game.cs Projeto: jklw10/ROQWE
        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button == MouseButton.Left)
            {
                Entity shot = Raycasting.Cast(Player.Position.XY, Vector.RadiansToVector(Player.Pic.Angle, 1));
                Console.WriteLine("shot:" + shot.Type + "  X:" + shot.X + "  Y:" + shot.Y);
                Entity lit = InView.Find(x => x.Position == shot.Position);
                if (!(lit is null))
                {
                    lit.Pic.Highlight(10);
                }


                if (shot.Type == Types.snakeType)
                {
                    Level[Where].Find(shot.Position).Health -= 1;
                    if (Level[Where].Find(shot.Position).Health <= 0)
                    {
                        InView.RemoveAt(InView.FindIndex(x => x.Position.XY == shot.Position.XY));
                        Level[Where].RemoveAt(shot.Position);
                    }
                }
            }
        }
Exemplo n.º 2
0
Arquivo: Game.cs Projeto: jklw10/ROQWE
        protected override void OnKeyDown(KeyboardKeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (e.Key == Key.F)
            {
                debug = !debug;
            }
            if (e.Key == Key.Right)
            {
                CameraAngle -= new Vector3(0, 0, 0.1f);
            }
            if (e.Key == Key.Left)
            {
                CameraAngle += new Vector3(0, 0, 0.1f);
            }
            if (e.Key == Key.Up)
            {
                CameraAngle -= new Vector3(0, 0.1f, 0);
            }
            if (e.Key == Key.Down)
            {
                CameraAngle += new Vector3(0, 0.1f, 0);
            }
            if (e.Key == Key.U)
            {
                DrawMap(Where);
            }
            if (e.Key == Key.H)
            {
                Thread t = new Thread(() =>
                {
                    Console.WriteLine("thread started");
                    if (Thread.CurrentThread.Name == null)
                    {
                        Thread.CurrentThread.Name = "Raycast";
                    }
                    else
                    {
                        Console.WriteLine("Unable to name a previously " +
                                          "named thread.");
                    }
                    Vector position = Player.Position.XY;
                    double Angle    = Player.Pic.Angle;
                    for (double rad = -Math.PI; rad < Math.PI; rad += 0.01)
                    {
                        Raycasting.Cast(position, Vector.RadiansToVector(Angle + rad, 1));
                        //Console.WriteLine("shot:" + shot.Type + "  X:" + shot.X + "  Y:" + shot.Y);
                    }
                    lock (InView)
                    {
                        InView.AddRange(DQD);
                        DQD = new List <Entity>();
                    }
                    Console.WriteLine("thread stop");
                });

                if (!(t.ThreadState == System.Threading.ThreadState.Running))
                {
                    t.Start();
                }
            }
            if (e.Key == Key.G)
            {
                if (debugS > 24)
                {
                    debugS++;
                }
                else
                {
                    debugS = 0;
                }
            }
            if (Controls(this, e))
            {
                foreach (Entity entity in InView)
                {
                    if (entity.Type == Types.snakeType)
                    {
                        EnemyThink(entity);
                    }
                }
            }
            if (e.Key == Key.I)
            {
                for (int y = 0; y < Player.inventory.size.Y; y++)
                {//draws each item in inventory on screen
                    for (int x = 0; x < Player.inventory.size.X; x++)
                    {
                        Console.Write(Player.inventory[x, y] + " ");
                    }
                    Console.WriteLine();
                }
            }
        }