Inheritance: MonoBehaviour
    // Use this for initialization
    void Start()
    {
        startgame = gameObject.GetComponent<StartGame>();

        offense = new GameObject("offense");
        defense = new GameObject("defense");
        ballPosition = new GameObject("ball");
        // grab and place the offensive players based on position and formation
        for(int i = 0; i < 11; i++)
        {
            GameObject playerPrefab = offensivePlayers.Find(obj => obj.name == offensive.SelectedOffensivePlay.PlayerPositions[i].ToString());
            GameObject _player = (GameObject)Instantiate(playerPrefab,offensive.SelectedOffensivePlay.VectorPosition[i],Quaternion.identity);
            _player.transform.position = offensive.SelectedOffensivePlay.VectorPosition[i];
            _player.transform.parent = offense.transform;
            _player.name = offensive.SelectedOffensivePlay.PlayerPositions[i];
        }
        /*
        //grab and place the defensive players based on position and formation
        for(int i = 0; i < 11; i++)
        {
            GameObject playerPrefab = defensivePlayers.Find(obj => obj.name == defensive.SelectedDefensivePlay.PlayerPositions[i].ToString());
            GameObject _player = (GameObject)Instantiate(playerPrefab, defensive.SelectedDefensivePlay.VectorPosition[i],Quaternion.identity);
            _player.transform.position = defensive.SelectedDefensivePlay.VectorPosition[i];
            _player.transform.parent = defense.transform;
            _player.name = defensive.SelectedDefensivePlay.PlayerPositions[i];
        }
        */
        defense.transform.parent = ballPosition.transform;
        offense.transform.parent = ballPosition.transform;
        ballPosition.transform.position = GameManager.ballPostion;
    }
Beispiel #2
0
 IEnumerator StartGame()
 {
     while (sg == null)
     {
         sg = GameObject.FindGameObjectWithTag("StartControl").GetComponent<StartGame>();
         yield return null;
     }
     StartBattle(sg.num);
 }
Beispiel #3
0
 void Awake()
 {
     if (instance != null)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     if (this.name == "ContinueButton")
     {
         Debug.Log("setting play");
     }
 }
Beispiel #4
0
        public void Run()
        {
            ActionManager.Instance.NewClientHandler();
            try
            {
                while (ActionManager.Instance.running)
                {
                    Hashtable c = NetworkUtil.ReceiveJsonObject(client);
                    string msgType = ((string)c["msgType"]).ToLower();
                    if (msgType == "pollstatecommand")
                    {
                        sender.SendJson(new StateMessage(State.State.CurrentState()));
                    }
                    if (msgType == "endturncommand")
                    {
                        ExecAction(new EndTurn(JSONSharp.JSON.Deserialize<EndTurnCommand>(c), sender));
                    }
                    if (msgType == "domulligancommand")
                    {
                        ExecAction(new DoMulligan(JSONSharp.JSON.Deserialize<DoMulliganCommand>(c), sender));
                    }
                    if (msgType == "playcardcommand")
                    {
                        ExecAction(new PlayCard(JSONSharp.JSON.Deserialize<PlayCardCommand>(c), sender));
                    }
                    if (msgType == "minionattackcommand")
                    {
                        ExecAction(new MinionAttack(JSONSharp.JSON.Deserialize<MinionAttackCommand>(c), sender));
                    }
                    if (msgType == "startgamecommand")
                    {
                        var x = new StartGame(JSONSharp.JSON.Deserialize<StartGameCommand>(c), sender);
                        ExecAction(x);
                    }
                    if (msgType == "endgamecommand")
                    {
                        ExecAction(new EndGame(JSONSharp.JSON.Deserialize<EndGameCommand>(c), sender));
                    }
                    if (msgType == "doemotecommand")
                    {
                        ExecAction(new DoEmote(JSONSharp.JSON.Deserialize<DoEmoteCommand>(c), sender));
                    }
                }

            }
            catch (Exception e)
            {
                Log.debug("Exception! Client handler closed due to SocketException. {0}", e.ToString());
                ActionManager.Instance.KillClientHandler();
            }

        }
    // Update is called once per frame
    void Update()
    {
        Camera.main.transform.position = new Vector3(player.transform.position.x, player.transform.position.y, -10);

        StartGame      startGame      = StartGameManeger.GetComponent <StartGame>();
        MainScriptBall mainScriptBall = player.GetComponent <MainScriptBall>();

        if (Input.GetKey(KeyCode.Mouse0))
        {
            Camera.main.GetComponent <AudioSource>().volume = 0.7f;
        }
        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            Camera.main.GetComponent <AudioSource>().volume = 1f;
        }
        if (mainScriptBall.Healts <= 0)
        {
            mainScriptBall.HightScoreShake();
        }
        if (startGame.Startgame)
        {
            {
                Camera.main.orthographicSize += 0.01f;
            }
            if (Camera.main.transform.position.y > 10f && !Input.GetKey(KeyCode.Mouse0) && Camera.main.orthographicSize < 13f)
            {
                Camera.main.orthographicSize   += 0.04f;
                HealtsObj.transform.localScale += new Vector3(0.0006f, 0.0006f);
                HealtsObj.transform.position    = new Vector3(HealtsObj.transform.position.x, HealtsObj.transform.position.y + 0.025f);
                if (Camera.main.orthographicSize >= 13f)
                {
                    Camera.main.orthographicSize = 13f;
                }
                if (HealtsObj.transform.position.y > Camera.main.transform.position.y + 8.5f)
                {
                    HealtsObj.transform.position = new Vector3(HealtsObj.transform.position.x, Camera.main.transform.position.y + 8.5f);
                }
                if (HealtsObj.transform.localScale.x >= 0.275f && HealtsObj.transform.localScale.y >= 0.235f)
                {
                    HealtsObj.transform.localScale = new Vector3(0.28f, 0.24f);
                }
            }


            if (Camera.main.transform.position.y < 10f && Camera.main.orthographicSize >= 8.4f && !Input.GetKey(KeyCode.Mouse0))
            {
                Camera.main.orthographicSize   -= 0.05f;
                HealtsObj.transform.localScale -= new Vector3(0.0013f, 0.0013f);
                HealtsObj.transform.position    = new Vector3(HealtsObj.transform.position.x, HealtsObj.transform.position.y - 0.04f);
                if (Camera.main.orthographicSize <= 8.4f)
                {
                    Camera.main.orthographicSize = 8.4f;
                }
                if (HealtsObj.transform.position.y < Camera.main.transform.position.y + 5.5f)
                {
                    HealtsObj.transform.position = new Vector3(HealtsObj.transform.position.x, Camera.main.transform.position.y + 5.5f);
                }
                if (HealtsObj.transform.localScale.x <= 0.17f && HealtsObj.transform.localScale.y <= 0.15f)
                {
                    HealtsObj.transform.localScale = new Vector3(0.17f, 0.15f);
                }
            }
        }
    }
Beispiel #6
0
        private void StartGames(object sender, EventArgs e)
        {
            StartGame?.Invoke(this, EventArgs.Empty);
            if (StartGameQ)
            {
                for (int i = 0; i < 4; i++)
                {
                    isButtonV[0] = false;
                }

                nowTimeTrueAnsverLose = 0;

                Ansver_AP = 0;
                Ansver_BP = 0;
                Ansver_CP = 0;
                Ansver_DP = 0;

                nowTimeCall     = 0;
                NowTime         = 0;
                nowTimeGAME     = 0;
                nowTimeHelpRoom = 0;



                player = new SoundPlayer("../../Resurses/sound/gong.wav");
                player.Play();
                nowTimeGAME = 0;

                isFandF    = true;
                IsCall     = true;
                IsHelpRoom = true;

                win  = false;
                lose = false;

                Start_Window(false);
                ZeroProgressBar();
                GroupRoomHelp(false);
                SecondWindow(true);

                FiftyOnFiftyImage(true);
                HelpRoomImage(true);
                CAllHelpImage(true);


                NumberlistView.Clear();
                NumberlistView.View = View.Details;

                ColumnHeader columnHeader1 = new ColumnHeader();
                columnHeader1.TextAlign = HorizontalAlignment.Left;
                columnHeader1.Width     = 70;
                ColumnHeader columnHeader2 = new ColumnHeader();
                columnHeader2.TextAlign      = HorizontalAlignment.Right;
                columnHeader2.Width          = 100;
                NumberlistView.FullRowSelect = true;
                NumberlistView.Columns.Clear();
                NumberlistView.Columns.Add(columnHeader1);
                NumberlistView.Columns.Add(columnHeader2);

                for (int count = 0; count < money.Length; count++)
                {
                    ListViewItem listItem = new ListViewItem((14 - count + 1).ToString());
                    if ((15 - count) % 5 == 0)
                    {
                        listItem.ForeColor = Color.Goldenrod;
                    }
                    else
                    {
                        listItem.ForeColor = Color.Yellow;
                    }

                    listItem.SubItems.Add(money[14 - count]);

                    NumberlistView.Items.Add(listItem);
                }
                NumberQuestion = 14;
                SetColorNewElement(NumberQuestion);

                TimeAnsver.Start();
            }
        }
Beispiel #7
0
 void Start()
 {
     instance = this;
 }
Beispiel #8
0
 void Awake()
 {
     _instance = this;
 }
 private void Awake()
 {
     startGame = FindObjectOfType <StartGame>();
 }
Beispiel #10
0
 /**Method Name: EndGame
  * Parameters: N/A
  * Returns: N/A
  *
  * Loads the next scene, effectively ending the game
  * */
 void EndGame()
 {
     StartGame.LoadNext();
 }
Beispiel #11
0
 // Start is called before the first frame update
 void Start()
 {
     GameObject.Find("vcam").GetComponent <CinemachineVirtualCamera>().Follow = gameObject.transform;
     startGame         = GameObject.Find("Start Game").GetComponent <StartGame>();
     startGame.isAlive = true;
 }
Beispiel #12
0
 public static void Buffer_StartGame(StartGame startGame)
 {
     p_AllMsg.StartGame.player_id = startGame.player_id;
     p_AllMsg.StartGame.type      = startGame.type;
 }
 public void SendStartGame()
 {
     StartGame?.Invoke();
 }
Beispiel #14
0
 public static void HandleStartGame() => StartGame.SafeInvoke();
Beispiel #15
0
 private void Awake()
 {
     keyInputs        = GameObject.FindObjectOfType <KeyboardInput>();
     depot            = GameObject.FindObjectOfType <Depot>();
     startGameManager = GameObject.FindObjectOfType <StartGame>();
 }
Beispiel #16
0
        private void ManageMessage(Object sender, NewMessageEvent newMessage)
        {
            if (newMessage.Message == "ERROR")
            {
                _error = true;
                ReceiveDone.Set();
            }
            string[] decompostion = newMessage.Message.Split(' ');
            string   type         = decompostion[0];

            switch (type)
            {
            case "GAMEMODE":
                _idGameMode = int.Parse(decompostion[1].Split('=')[1]);
                ReceiveDone.Set();
                break;

            case "PLAYER":
                _idPlayer = int.Parse(decompostion[1].Split('=')[1]);
                ReceiveDone.Set();
                break;

            case "GAMES":
                _gameModes = new List <CurrentGameMode>();
                foreach (var info in decompostion)
                {
                    if (info == "GAMES")
                    {
                        continue;
                    }
                    if (info == "")
                    {
                        continue;
                    }
                    _gameModes.Add(DecryptGame(info));
                }
                ReceiveDone.Set();
                break;

            case "NEWPLAYER":
                bool ready = bool.Parse(decompostion[1].Split('=')[1]);
                if (ready)
                {
                    StartGame?.Invoke(this, new StartGameEvent());
                }
                else
                {
                    NewPlayer?.Invoke(this, new NewPlayerEvent {
                        Player = DecryptPlayer(decompostion[2])
                    });
                }
                break;

            case "ADDPLAYER":
                _isReady = bool.Parse(decompostion[1].Split('=')[1]);
                ReceiveDone.Set();
                break;

            case "PLAYERSGAME":
                _players = new List <Player>();
                foreach (var info in decompostion)
                {
                    if (info == "PLAYERSGAME")
                    {
                        continue;
                    }
                    if (info == "")
                    {
                        continue;
                    }
                    _players.Add(DecryptPlayer(info));
                }
                ReceiveDone.Set();
                break;

            case "ERRORGAME":
                ErrorGames?.Invoke(this, new ErrorGamesEvent());
                break;

            case "DELPLAYER":
                DeletePLayer?.Invoke(this, new DeletePlayerEvent(int.Parse(decompostion[1].Split('=')[1])));
                break;

            case "SWITCH":
                SwitchCell?.Invoke(this, new SwitchCellEvent(int.Parse(decompostion[1].Split('=')[1]), int.Parse(decompostion[2].Split('=')[1]), int.Parse(decompostion[3].Split('=')[1])));
                break;

            case "STARTGEN":
                StartGenEv?.Invoke(this, new StartGenEvent());
                break;

            case "DIFFGEN":
                _cells = new List <Cell>();
                if (decompostion[1] == "FIN")
                {
                    _cells = null;
                    ReceiveDone.Set();
                    break;
                }
                foreach (var info in decompostion)
                {
                    if (info == "DIFFGEN")
                    {
                        continue;
                    }
                    if (info == "")
                    {
                        continue;
                    }
                    _cells.Add(DecryptCell(info));
                }
                ReceiveDone.Set();
                break;

            case "GETZONE":
                _zone = new List <Cell>();
                foreach (var info in decompostion)
                {
                    if (info == "DIFFGEN")
                    {
                        continue;
                    }
                    if (info == "")
                    {
                        continue;
                    }
                    _zone.Add(DecryptCell(info));
                }
                ReceiveDone.Set();
                break;
            }
        }
Beispiel #17
0
        public static void Main(string[] args)
        {
            Console.Clear();

            poz2 = 1;
            Logo.show();
            RankingConsole.loadData();
            PrintMenu(12, s);

            while (true)
            {
                string selected = Console.ReadKey().Key.ToString();
                if (selected == "Enter")
                {
                    switch (poz2)
                    {
                    case 1:
                        StartGame.show();
                        RankingConsole.saveData();
                        break;

                    case 2:
                        Console.Clear();
                        SAPER.View.Logo.show();
                        SAPER.View.RankingConsole.loadData();
                        Console.SetCursorPosition(25, 12);
                        Console.WriteLine(@"Saper to gra logiczna polegająca na odkrywaniu na planszy poszczególnych pól     ");
                        Console.SetCursorPosition(25, 13);
                        Console.WriteLine(@"w taki sposób, aby nie natrafić na minę.Na każdym z odkrytych pól napisana       ");
                        Console.SetCursorPosition(25, 14);
                        Console.WriteLine(@"jest liczba min, które bezpośrednio stykają się z danym polem (od zera do ośmiu).");
                        Console.SetCursorPosition(25, 15);
                        Console.WriteLine(@"Jeśli oznaczymy dane pole flagą, jest ono zabezpieczone przed odsłonięciem,      ");
                        Console.SetCursorPosition(25, 16);
                        Console.WriteLine(@"dzięki czemu przez przypadek nie odsłonimy miny. ");
                        Console.SetCursorPosition(25, 18);
                        Console.WriteLine(@"Sterowanie:");
                        Console.SetCursorPosition(25, 19);
                        Console.WriteLine(@"Enter - odkryj pole");
                        Console.SetCursorPosition(25, 20);
                        Console.WriteLine(@"Spacja - wstaw flagę");
                        Console.SetCursorPosition(25, 21);
                        Console.WriteLine(@"Strzałki - poruszanie");
                        Console.ReadKey();
                        SAPER.Program.Main(null);
                        break;

                    case 3:
                        Console.Clear();

                        Console.WriteLine(HIGHSCORE1);
                        Console.WriteLine(HIGHSCORE2);
                        Console.WriteLine(HIGHSCORE3);
                        Console.WriteLine(HIGHSCORE4);
                        Console.WriteLine(HIGHSCORE5);

                        Console.WriteLine();
                        Console.WriteLine(HIGHSCORE);
                        Console.WriteLine();
                        List <Highscore> highscore = Core.Highscore.SelectAll();
                        int i = 1;
                        foreach (var h in highscore)
                        {
                            Console.Write("   " + i + ". ");
                            Console.WriteLine("   " + h.Nickname);
                            Console.SetCursorPosition(39, 7 + i);
                            Console.WriteLine(h.Score + "s");
                            i++;
                        }
                        //Tu cos sie psuje
                        Console.ReadKey();
                        SAPER.Program.Main(null);
                        break;

                    case 4:
                        Environment.Exit(0);
                        break;
                    }
                }
                Select(selected);
            }
        }
Beispiel #18
0
 protected virtual void OnStartGame(StartGameEventArgs e)
 {
     StartGame?.Invoke(this, e);
 }
Beispiel #19
0
        static void Main(string[] args)
        {
            Console.Write("Please enter the weight of the fruit basket (min weight is 40kg, the max weight is 140kg): ");
            int basketWeight         = Validation.BasketWeightValidation();
            int guessNumber          = 0;
            int totalAttemptscounter = 0;

            var numbersGuessedByThePlayers = new Dictionary <int, Player>();

            do
            {
                int totalPlayers = PlayerKeeper._player.ToArray().Length;

                Console.Clear();
                Console.WriteLine("=============MENU=============");
                Console.WriteLine("1. Add new player");
                Console.WriteLine("2. Play a game");
                Console.WriteLine("3. Remove Player at index");
                Console.WriteLine("4. Reset game");
                Console.WriteLine("5. Exit");
                StartGame startgame = (StartGame)Validation.InputNumberValidation();
                switch (startgame)
                {
                case StartGame.NewPlayer:
                {
                    Console.Clear();
                    Console.WriteLine("Please enter the name and type of the player");

                    Console.Write("Please enter player name: ");
                    string name = Console.ReadLine();

                    Console.Clear();
                    Console.Write("Please enter player type");
                    Console.WriteLine();
                    Console.WriteLine("1. Casual Player");
                    Console.WriteLine("2. Note Player");
                    Console.WriteLine("3. Uber Player");
                    Console.WriteLine("4. Cheater");
                    Console.WriteLine("5. Uber Cheater");
                    string type = Player.PlayerTypeSelector();

                    Player player = new Player(name: name, type: type);
                    PlayerKeeper.Add(player);
                }
                break;

                case StartGame.PlayGame:
                {
                    if (totalPlayers >= 2 && totalPlayers <= 8)
                    {
                        while (guessNumber != basketWeight)
                        {
                            if (totalAttemptscounter != 100)
                            {
                                for (int i = 0; i < PlayerKeeper._player.ToArray().Length; i++)
                                {
                                    if (PlayerKeeper._player[i].Type == "Casual Player")
                                    {
                                        guessNumber = CasualPlayer.GuessNumber();

                                        Console.WriteLine($"Player: {PlayerKeeper._player[i].Name}\nType: {PlayerKeeper._player[i].Type}\nGuessed number: {guessNumber}");
                                        AddUniqueNumberToDictonary(numbersGuessedByThePlayers, guessNumber, i);

                                        totalAttemptscounter++;
                                        if (guessNumber == basketWeight)
                                        {
                                            Player.Winner(i, guessNumber);
                                            break;
                                        }
                                    }

                                    if (PlayerKeeper._player[i].Type == "Note Player")
                                    {
                                        guessNumber = NotePlayer.GuessNumber();
                                        Console.WriteLine($"Player: {PlayerKeeper._player[i].Name}\nType: {PlayerKeeper._player[i].Type}\nGuessed number: {guessNumber}");
                                        AddUniqueNumberToDictonary(numbersGuessedByThePlayers, guessNumber, i);
                                        totalAttemptscounter++;
                                        if (guessNumber == basketWeight)
                                        {
                                            Player.Winner(i, guessNumber);
                                            break;
                                        }
                                    }

                                    if (PlayerKeeper._player[i].Type == "Uber Player")
                                    {
                                        guessNumber = UberPlayer.GuessNumber();


                                        Console.WriteLine($"Player: {PlayerKeeper._player[i].Name}\nType: {PlayerKeeper._player[i].Type}\nGuessed number: {guessNumber}");
                                        AddUniqueNumberToDictonary(numbersGuessedByThePlayers, guessNumber, i);
                                        totalAttemptscounter++;
                                        if (guessNumber == basketWeight)
                                        {
                                            Player.Winner(i, guessNumber);
                                            break;
                                        }
                                    }

                                    if (PlayerKeeper._player[i].Type == "Cheater")
                                    {
                                        guessNumber = Cheater.GuessNumber();
                                        Console.WriteLine($"Player: {PlayerKeeper._player[i].Name}\nType: {PlayerKeeper._player[i].Type}\nGuessed number: {guessNumber}");
                                        AddUniqueNumberToDictonary(numbersGuessedByThePlayers, guessNumber, i);
                                        totalAttemptscounter++;

                                        if (guessNumber == basketWeight)
                                        {
                                            Player.Winner(i, guessNumber);
                                            break;
                                        }
                                    }

                                    if (PlayerKeeper._player[i].Type == "Uber Cheater")
                                    {
                                        guessNumber = UberCheater.GuessNumber();
                                        Console.WriteLine($"Player: {PlayerKeeper._player[i].Name}\nType: {PlayerKeeper._player[i].Type}\nGuessed number: {guessNumber}");
                                        AddUniqueNumberToDictonary(numbersGuessedByThePlayers, guessNumber, i);
                                        totalAttemptscounter++;

                                        if (guessNumber == basketWeight)
                                        {
                                            Player.Winner(i, guessNumber);
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Console.WriteLine("Maximum number of attempts reached! ");
                                int closestNumber = ClosestNumber(basketWeight);

                                Console.WriteLine($"The winner\n{numbersGuessedByThePlayers[closestNumber]}\n Number Guesses: {closestNumber}");
                                Console.ReadKey();


                                break;
                            }
                            Console.WriteLine();
                            Console.WriteLine($"{totalAttemptscounter}");
                            Console.ReadKey();
                        }
                    }
                    else
                    {
                        Console.WriteLine("The minimum number of player is 2 and maximum is 8");
                    }
                }
                break;

                case StartGame.RemovePlayer:
                {
                    Console.Clear();
                    Console.Write("Please enter the index of the player you would like to remove: ");
                    Validation.IndexInputValidation();
                }
                break;

                case StartGame.ResetGame:
                {
                    totalAttemptscounter = 0;
                    guessNumber          = 0;
                    CasualPlayer.ClearTotalNumberSheet();
                    UberPlayer.Number  = 39;
                    UberCheater.Number = 40;
                    numbersGuessedByThePlayers.Clear();
                }
                break;

                case StartGame.Exit:
                {
                    return;
                }

                default:
                {
                    Console.Clear();
                    Console.WriteLine("There is no such command");
                    Console.ReadKey();
                }
                break;
                }
            } while (true);
        }
Beispiel #20
0
 public void ToGameScene()
 {
     StartGame.V_StartGame();
     Blinking.B_Stop = false;
 }
Beispiel #21
0
        private static void HandleToClient(string source, MessageReader packet)
        {
            var messageType = (MessageType)packet.Tag;

            Console.ForegroundColor = ConsoleColor.Cyan;
            //Console.WriteLine($"{source,-15} Client received: {packet.Tag,-2} {messageType}");

            try
            {
                var reader = packet.GetHazelReader();
                var body   = reader.PeekToEnd();
                if (SaveMessages)
                {
                    File.WriteAllBytes(Path.Combine(MessageFolder, $"recv_{packet.Tag}_{allId++}.bin"), body);
                }

                switch (messageType)
                {
                case MessageType.ReselectServer:
                    var reselect = ReselectServer.Deserialize(reader);
                    DumpToConsole(reselect);
                    break;

                case MessageType.Redirect:
                    var redirect = Redirect.Deserialize(reader);
                    DumpToConsole(redirect);
                    break;

                case MessageType.HostGame:
                    var host = HostGameResponse.Deserialize(reader);
                    DumpToConsole(host);
                    break;

                case MessageType.JoinGame:
                    var join = JoinGameResponse.Deserialize(reader);
                    DumpToConsole(join);
                    break;

                case MessageType.GameData:
                    var gamedata = GameData.Deserialize(reader);
                    foreach (var item in gamedata)
                    {
                        HandleGameData(item, false);
                    }

                    //Directory.CreateDirectory("gamedata");
                    //File.WriteAllBytes(Path.Combine("gamedata", $"recv_data_{gamedataId++}.bin"), body);
                    break;

                case MessageType.GameDataTo:
                    var gamedatato = GameDataTo.Deserialize(reader);
                    foreach (var item in gamedatato)
                    {
                        HandleGameDataTo(item, false);
                    }
                    break;

                case MessageType.JoinedGame:
                    var joined = JoinedGame.Deserialize(reader);
                    DumpToConsole(joined);
                    break;

                case MessageType.AlterGame:
                    var alter = AlterGameResponse.Deserialize(reader);
                    DumpToConsole(alter);
                    break;

                case MessageType.GetGameListV2:
                    var gamelist = GetGameListV2Response.Deserialize(reader);
                    DumpToConsole(gamelist);
                    break;

                case MessageType.RemovePlayer:
                    var removeplayer = RemovePlayerResponse.Deserialize(reader);
                    DumpToConsole(removeplayer);
                    break;

                case MessageType.StartGame:
                    var start = StartGame.Deserialize(reader);
                    DumpToConsole(start);
                    if (BreakOnGameStart)
                    {
                        Console.WriteLine("Press any key to continue...");
                        Console.ReadKey();
                    }
                    break;

                case MessageType.EndGame:
                    var end = EndGame.Deserialize(reader);
                    DumpToConsole(end);
                    if (BreakOnGameEnd)
                    {
                        Console.WriteLine("Press any key to continue...");
                        Console.ReadKey();
                    }

                    //Clear Entities to prevent collisions
                    EntityTracker.entities.Clear();
                    break;

                default:
                    Console.WriteLine($"Unhandled Message: {messageType} size: {body.Length}");
                    return;
                }

                if (reader.GetBytesLeft() > 0 && LogNotConsumed)
                {
                    Console.WriteLine($"[{messageType}]{reader.GetBytesLeft()} bytes not cunsumed");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error handling ToClient: " + ex.Message);
            }
        }
Beispiel #22
0
 public Bishop(string _color, int _row, int _col, StartGame _startGame) : base(_color, _row, _col, _startGame)
 {
     Type = "Bishop";
     rank = 4;
     InitPiece();
 }
Beispiel #23
0
 public static void OnStartGame()
 {
     StartGame?.Invoke();
 }
Beispiel #24
0
        public static void Main(string[] args)
        {
            var startGame = new StartGame();

            startGame.Run();
        }
Beispiel #25
0
 public async Task <IActionResult> StartGame([FromBody] StartGame command)
 => await ProcessCommand(command);
Beispiel #26
0
 private void LobbyForm_Activated(object sender, EventArgs e)
 {
     //MainForm.M_Form.BringToFront();
     StartGame.Focus();
 }
Beispiel #27
0
 //wygenerowanie gry o zadanych parametrach
 private void startGame(int width, int height, int numbersOfMines)
 {
     StartGame?.Invoke(width, height, numbersOfMines);
 }
Beispiel #28
0
 public void CallStartGame() => StartGame?.Invoke();
Beispiel #29
0
 public void Init(StartGame startGame)
 {
     this.startGame = startGame;
 }
    void PrepareSocket()
    {
        if (socket == null)
        {
            print("Initializing socket");
            socket = IO.Socket(serverURL);

            //on connection to the server, request a room
            socket.Once(Socket.EVENT_CONNECT, () => {
                print("Socket connected");

                if (roomcode == "-1") //only request a room if this is not some kind of reconnection
                {
                    socket.Emit("request room");
                }
            });

            //server created the room and sent the code back. Store and display the code
            socket.On("request room", (data) =>
            {
                //parse the message received from the socket
                RequestRoom room = JsonUtility.FromJson <RequestRoom>(data.ToString());
                roomcode         = room.roomcode;

                //update the roomcode in the UI
                GameManager.DisplayRoomCode(roomcode);
            });

            //server indicated that a player joined the room. Store and display the new player in the player list
            socket.On("join room", (data) =>
            {
                JoinRoom join = JsonUtility.FromJson <JoinRoom>(data.ToString());

                if (join.joined == true) //add the user to the player list
                {
                    print("Joined: " + join.username);
                    GameManager.AddPlayer(join.username);
                }
                else //inidicate that the given user failed to enter the room (probably due to a duplicate name)
                {
                    print("fail:" + join.username);
                }
            });

            socket.On("everybody in", () => {
                GameManager.DisplayTutorial(this);
            });

            //server has started an instance of the game. Store and display the category and players
            socket.On("start game", (data) =>
            {
                StartGame start = JsonUtility.FromJson <StartGame>(data.ToString());

                print("prompt: " + start.category);
                print("player1: " + start.player1Name);
                print("player2: " + start.player2Name);

                //clear any previous answers + reset vote indicator
                GameManager.DisplayAnswer(0, "");
                GameManager.DisplayAnswer(1, "");
                GameManager.UpdateVote(0.5f);

                //update the game state to show the correct screen
                GameManager.StartGame(start.player1Name, start.player2Name, start.category);
            });

            //server has relayed a submission from a player. Display it on the screen
            socket.On("enter submission", (data) =>
            {
                EnterSubmission submission = JsonUtility.FromJson <EnterSubmission>(data.ToString());

                print("player " + submission.player + " submission: " + submission.submission);


                //update the game state to show the correct screen
                GameManager.DisplayAnswer(submission.player, submission.submission);
            });

            //server has caught another vote. update the percent shown on screen
            socket.On("vote", (data) =>
            {
                Vote vote = JsonUtility.FromJson <Vote>(data.ToString());

                //display the correct vote percent
                GameManager.UpdateVote(vote.percentage);
            });

            //server has sent timer updates. Display them
            socket.On("time changed", (data) =>
            {
                TimeChanged tc = JsonUtility.FromJson <TimeChanged>(data.ToString());

                //display the correct time
                GameManager.UpdateTime(tc.time);
            });

            //the server has indicated that the round has ended. Display the winner.
            socket.On("timeout", (data) =>
            {
                Timeout timeout = JsonUtility.FromJson <Timeout>(data.ToString());
                //display the correct time
                GameManager.EndGame(timeout.winner);
            });

            socket.On("game_error", (data) =>
            {
                print(data);
            });

            socket.On(Socket.EVENT_DISCONNECT, () => {
                print("there was a disconnect");
            });

            socket.On(Socket.EVENT_RECONNECT, () => {
                print("Reconnected");
            });
        }
    }
Beispiel #31
0
    public void UserAnswerButton(int answer) // 0 = <, 1 = between, 2 = >
    {
        GameObject manager         = GameObject.Find("_Manager");
        StartGame  startGameScript = (StartGame)manager.GetComponent("StartGame");

        quizText.text   = startGameScript.quizRank.ToString();
        topText.text    = startGameScript.topRank.ToString();
        bottomText.text = startGameScript.bottomRank.ToString();

        RightWrongNone rightWrongNoneScript;

        rightWrongNoneScript = (RightWrongNone)lessRightWrong.GetComponent("RightWrongNone");
        rightWrongNoneScript.ShowRightWrongNone(2);
        rightWrongNoneScript = (RightWrongNone)betweenRightWrong.GetComponent("RightWrongNone");
        rightWrongNoneScript.ShowRightWrongNone(2);
        rightWrongNoneScript = (RightWrongNone)moreRightWrong.GetComponent("RightWrongNone");
        rightWrongNoneScript.ShowRightWrongNone(2);

        bool correct = false;

        switch (answer)
        {
        case 0:     // <
            rightWrongNoneScript = (RightWrongNone)lessRightWrong.GetComponent("RightWrongNone");
            if (startGameScript.quizRank < startGameScript.topRank)
            {
                rightWrongNoneScript.ShowRightWrongNone(0);
                correct = true;
            }
            else
            {
                rightWrongNoneScript.ShowRightWrongNone(1);
            }
            break;

        case 1:     // <
            rightWrongNoneScript = (RightWrongNone)betweenRightWrong.GetComponent("RightWrongNone");
            if ((startGameScript.topRank < startGameScript.quizRank) && (startGameScript.quizRank < startGameScript.bottomRank))
            {
                rightWrongNoneScript.ShowRightWrongNone(0);
                correct = true;
            }
            else
            {
                rightWrongNoneScript.ShowRightWrongNone(1);
            }
            break;

        case 2:     // <
            rightWrongNoneScript = (RightWrongNone)moreRightWrong.GetComponent("RightWrongNone");
            if (startGameScript.bottomRank < startGameScript.quizRank)
            {
                rightWrongNoneScript.ShowRightWrongNone(0);
                correct = true;
            }
            else
            {
                rightWrongNoneScript.ShowRightWrongNone(1);
            }
            break;
        }

        int currentScore = PlayerPrefs.GetInt("CurrentScore");
        int bestScore    = PlayerPrefs.GetInt("BestScore");

        if (correct)
        {
            currentScore = currentScore + 1;
            if (currentScore > bestScore)
            {
                bestScore = currentScore;
            }
        }
        else
        {
            currentScore = 0;
        }

        currentText.text = currentScore.ToString();
        bestText.text    = bestScore.ToString();

        PlayerPrefs.SetInt("CurrentScore", currentScore);
        PlayerPrefs.SetInt("BestScore", bestScore);

        FadeShow fadeShowScript = (FadeShow)rightWrongNoneCanvas.GetComponent("FadeShow");

        fadeShowScript.ShowMe(10);
    }
 static void Main()
 {
     StartGame.Game();
 }
 void Awake()
 {
     game = StartGame.startgame;
     //Debug.Log(theCamera);
     //Debug.Log(startgame);
 }
Beispiel #34
0
        public void StartGame(StartGame command)
        {
            GameStarted e = new GameStarted(this.Id);

            RaiseEvent(e);
        }