Exemplo n.º 1
0
        public void CreateGame(GameCreateRequestModel data)
        {
            Logger.Log("--game created ", LogLevel.DebugInformation);
            GameRoom room;
            rooms.Add(room = new GameRoom());
            room.MaxUsers = data.Players.Count; //todo idk
            room.GameType = data.GameType;
            room.Started = false;
            room.Players.AddRange(data.Players);

            GameObject gameObject;
            if (cachedGames.ContainsKey(room.GameType))
                gameObject = cachedGames[room.GameType];
            else
                gameObject = cachedGames[room.GameType] = Global.Require<GameObject>(string.Format("./Games/{0}/app.js", room.GameType));

            room.Fiber = CreateFiber(room, gameObject, true);
            room.Unwind = players => {
                              gameData.FinishedGames++;
                              Logger.Log("--game closed", LogLevel.DebugInformation);
                          };
            room.PlayerLeave += (player) => {
                                    //todo laeve player api in the game
                                    ////i think an action that it calls

                                    room.Players.Remove(player);
                                    room.PlayersLeft.Add(player);
                                };

            foreach (var userLogicModel in room.Players) {
                myServerManager.RegisterGameServer(userLogicModel);
            }

            startGame(room);
        }
Exemplo n.º 2
0
        public void CreateGame(GameCreateRequestModel data)
        {

            ServerLogger.LogDebug("--game created ", data);
            dataManager.SiteData.Game_GetGamesByName(data.GameType, (game) =>
                                                                    {
                                                                        if (game == null)
                                                                        {
                                                                            ServerLogger.LogError("--game not found " + data.GameType, data);
                                                                            return;
                                                                        }
                                                                        ServerLogger.LogDebug("--game found " + game.Name, game);

                                                                        GameRoom room;
                                                                        rooms.Add(room = new GameRoom());
                                                                        room.MaxUsers = data.Players.Count; //todo idk
                                                                        room.GameType = data.GameType;
                                                                        room.Started = false;
                                                                        room.Players.AddRange(data.Players);
                                                                        GameObject evaluated_game = null;
                                                                        Script.Eval("evaluated_game=" + game.GameCode.Code);
                                                                        GameObject gameObject;
                                                                        if (cachedGames.ContainsKey(room.GameType))
                                                                            gameObject = cachedGames[room.GameType];
                                                                        else
                                                                            gameObject = cachedGames[room.GameType] = evaluated_game;

                                                                        room.Fiber = CreateFiber(room, gameObject, true, game);
                                                                        room.Unwind = players =>
                                                                        {
                                                                            gameData.FinishedGames++;
                                                                            ServerLogger.LogDebug("--game closed", gameData);
                                                                        };
                                                                        room.PlayerLeave += (player) =>
                                                                        {
                                                                            //todo laeve player api in the game
                                                                            ////i think an action that it calls

                                                                            room.Players.Remove(player);
                                                                            room.PlayersLeft.Add(player);
                                                                        };

                                                                        foreach (var userLogicModel in room.Players)
                                                                        {
                                                                            myServerManager.RegisterGameServer(userLogicModel);
                                                                        }

                                                                        startGame(room);
                                                                    });
        }
 public void CreateGame(GameCreateRequestModel gameCreateRequestModel)
 {
     qManager.SendMessage("GameServer", "Area.Game.Create", null, gameCreateRequestModel);
 }