Пример #1
0
        protected virtual void OnGameStateUpdated(Core.GameStateInformation.GameStateUpdate gameStateUpdate)
        {
            GameStateUpdatedEventHandler temp = GameStateUpdated;

            if (temp != null)
            {
                temp(gameStateUpdate);
            }
        }
Пример #2
0
        private void UpdateGameState(Guid key)
        {
            GameplayCommunicationsStore client = ConnectedClients[key];

            Core.GameStateInformation.GameStateUpdate gameStateUpdate = new Core.GameStateInformation.GameStateUpdate();

            Character playerCharacter = _players.Where(i => i.Id == client.PlayerCharacterId).First();

            gameStateUpdate.ViewableArea  = GetViewableArea(playerCharacter.Location, gameStateUpdate);
            gameStateUpdate.OtherPlayers  = GetOtherViewablePlayersPositions(key, playerCharacter.Location);
            gameStateUpdate.NpcsInTheArea = GetNpcsInTheArea(key, playerCharacter.Location);

            client.Callback.GameStateUpdatedCallback(gameStateUpdate);
        }
Пример #3
0
 public void UpdateGameState(Core.GameStateInformation.GameStateUpdate gameStateUpdate)
 {
     playerView1.GameStateUpdate = gameStateUpdate;
 }
Пример #4
0
        //TODO:Move this to a business object instead of having it in the service.
        private List <Core.GameStateInformation.GameTile> GetViewableArea(System.Drawing.Point playerPosition, Core.GameStateInformation.GameStateUpdate gameStateUpdate)
        {
            //We need to get a list of tiles that are currently viewable to the player based on their current position in the map
            List <Core.GameStateInformation.GameTile> tiles = new List <Core.GameStateInformation.GameTile>();

            int relativeY = 0;

            //TODO:Currently assuming that the player view is 7X7
            for (int y = playerPosition.Y - 3; y <= playerPosition.Y + 3; y++)
            {
                int relativeX = 0;
                for (int x = playerPosition.X - 3; x <= playerPosition.X + 3; x++)
                {
                    Business.Maps.MapTile mapTile = _map.Tiles.GetFromLocation(x, y);
                    Core.GameStateInformation.GameTile gameTile = new Core.GameStateInformation.GameTile();
                    gameTile.Location = new System.Drawing.Point(relativeX, relativeY);

                    if (mapTile != null)
                    {
                        gameTile.BackgroundImageName        = mapTile.Terrain.BackgroundImageName;
                        gameTile.WallImageNames             = mapTile.WallImages;
                        gameTile.UnpassableObjectImageNames = mapTile.UnpassableObjects;
                        gameTile.ObjectNames = mapTile.Objects;
                        gameTile.DoorNames   = mapTile.DoorImages;

                        foreach (Business.Maps.MapNonPlayerCharacter npc in mapTile.NPCs)
                        {
                            //TODO:Need to handle the npc image name
                            string imageName = "NPC_" + npc.NonPlayerCharacterType.ToString();
                            gameTile.NonPlayableCharacterImageNames.Add(imageName);
                        }
                    }

                    tiles.Add(gameTile);

                    relativeX++;
                }
                relativeY++;
            }

            return(tiles);
        }
Пример #5
0
 void GameplayCallbackHandler_GameStateUpdated(Core.GameStateInformation.GameStateUpdate gameStateUpdate)
 {
     gameContainer1.UpdateGameState(gameStateUpdate);
 }
Пример #6
0
 public void GameStateUpdatedCallback(Core.GameStateInformation.GameStateUpdate gameStateUpdate)
 {
     OnGameStateUpdated(gameStateUpdate);
 }