Пример #1
0
 public bool canSeePlayer(GameGrid grid, Vector2 player)
 {
     grid.Clear();
     ShadowCast.ComputeVisibility(grid, pos, 5f, name);
     foreach (Tile t in grid.Game_map.Values)
     {
         if (t.lit && t.discoveredby == name && t.pos == player)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #2
0
 public void handleKey(RLKeyPress keyPress)
 {
     if (keyPress.Key == RLKey.Up)
     {
         if (map.canMove(player.pos, 0, -1))
         {
             map.resetLight();
             player.move(0, -1);
             var pos = new Vector2(player.pos.x, player.pos.y);
             ShadowCast.ComputeVisibility(map.grid, pos, 7.5f);
         }
     }
     else if (keyPress.Key == RLKey.Down)
     {
         if (map.canMove(player.pos, 0, 1))
         {
             map.resetLight();
             player.move(0, 1);
             var pos = new Vector2(player.pos.x, player.pos.y);
             ShadowCast.ComputeVisibility(map.grid, pos, 7.5f);
         }
     }
     else if (keyPress.Key == RLKey.Left)
     {
         if (map.canMove(player.pos, -1, 0))
         {
             map.resetLight();
             player.move(-1, 0);
             var pos = new Vector2(player.pos.x, player.pos.y);
             ShadowCast.ComputeVisibility(map.grid, pos, 7.5f);
         }
     }
     else if (keyPress.Key == RLKey.Right)
     {
         if (map.canMove(player.pos, 1, 0))
         {
             map.resetLight();
             player.move(1, 0);
             var pos = new Vector2(player.pos.x, player.pos.y);
             ShadowCast.ComputeVisibility(map.grid, pos, 7.5f);
         }
     }
 }
Пример #3
0
 public SPEngine(RLRootConsole rootConsole)
 {
     player           = new Player(new Vector2(0, 0), '@', 100, "Tom", this);
     this.rootConsole = rootConsole;
     MapGenerate();
     do
     {
         rootConsole.Clear();
         MapConsole.Clear();
         MapConsole.Print(0, 0, "Loading Map", RLColor.White);
         RLConsole.Blit(MapConsole, 0, 0, 70, 50, rootConsole, 0, 10);
         rootConsole.Draw();
         Thread.Sleep(200);
         MapConsole.Print(0, 0, "Loading Map.", RLColor.White);
         RLConsole.Blit(MapConsole, 0, 0, 70, 50, rootConsole, 0, 10);
         rootConsole.Draw();
         Thread.Sleep(200);
         MapConsole.Print(0, 0, "Loading Map..", RLColor.White);
         RLConsole.Blit(MapConsole, 0, 0, 70, 50, rootConsole, 0, 10);
         rootConsole.Draw();
         Thread.Sleep(200);
         MapConsole.Print(0, 0, "Loading Map...", RLColor.White);
         RLConsole.Blit(MapConsole, 0, 0, 70, 50, rootConsole, 0, 10);
         rootConsole.Draw();
     } while(mapLoadDone == false);
     inv  = new Inventory(InvConsole);
     side = new SidePanel(SideConsole, player, 21, 96, this);
     TickTimer.Elapsed += new ElapsedEventHandler(OnTick);
     TickTimer.Interval = 200;
     TickTimer.Enabled  = true;
     AddMonsters();
     player.pos = map.findPPos();
     entityList.Add(player);
     ConstructGrid();
     ShadowCast.ComputeVisibility(map.grid, player.pos, 7.5f, player.name);
     inv.items.Add(new Weapon((char)234, 300, 4));
 }
Пример #4
0
        public virtual void HandleKey(RLKeyPress keyPress, Player player)
        {
            switch (keyPress.Key)
            {
            case RLKey.W:
            {
                if (!map.canMove(player.pos, 0, -1))
                {
                    return;
                }
                map.resetLight();
                player.move(0, -1);
                ShadowCast.ComputeVisibility(map.grid, player.pos, 7.5f, player.name);
                OnPlayerMove(new PlayerMoveEventArgs {
                        playerPos = player.pos, engine = this
                    });
            }
            break;

            case RLKey.S:
            {
                if (!map.canMove(player.pos, 0, 1))
                {
                    return;
                }
                map.resetLight();
                player.move(0, 1);
                var pos = new Vector2(player.pos.X, player.pos.Y);
                ShadowCast.ComputeVisibility(map.grid, pos, 7.5f, player.name);
                OnPlayerMove(new PlayerMoveEventArgs {
                        playerPos = player.pos, engine = this
                    });
            }
            break;

            case RLKey.A:
            {
                if (!map.canMove(player.pos, -1, 0))
                {
                    return;
                }
                map.resetLight();
                player.move(-1, 0);
                var pos = new Vector2(player.pos.X, player.pos.Y);
                ShadowCast.ComputeVisibility(map.grid, pos, 7.5f, player.name);
                OnPlayerMove(new PlayerMoveEventArgs {
                        playerPos = player.pos, engine = this
                    });
            }
            break;

            case RLKey.D:
            {
                if (!map.canMove(player.pos, 1, 0))
                {
                    return;
                }
                map.resetLight();
                player.move(1, 0);
                var pos = new Vector2(player.pos.X, player.pos.Y);
                ShadowCast.ComputeVisibility(map.grid, pos, 7.5f, player.name);
                OnPlayerMove(new PlayerMoveEventArgs {
                        playerPos = player.pos, engine = this
                    });
            }
            break;

            case RLKey.Space:
            {
                player.attack();
            }
            break;

            case RLKey.Comma:
            {
                inv?.Move(-1);
            }
            break;

            case RLKey.Period:
            {
                inv?.Move(1);
            }
            break;

            default:
                break;
            }
        }