public void OnClickGetGames()
    {
        PacketHandleClickUI packet = new PacketHandleClickUI();

        packet.UIClicked = PacketHandleClickUI.UIButton.GetGameButton;
        EventManager.Get().EnqueuePacket(0, packet);
    }
    public void OnClickJoinGames(uint gameId)
    {
        PacketHandleClickUI packet = new PacketHandleClickUI();

        packet.UIClicked    = PacketHandleClickUI.UIButton.JoinGameButton;
        packet.GameIdToJoin = gameId;

        EventManager.Get().EnqueuePacket(0, packet);
    }
    private void OnEnable()
    {
        if (m_lines == null)
        {
            m_lines = new Dictionary <uint, GameObject>();
        }

        PseudoMenu.text = GameManager.PlayerPseudo;

        PacketHandleClickUI packet = new PacketHandleClickUI();

        packet.UIClicked = PacketHandleClickUI.UIButton.GetGameButton;
        EventManager.Get().EnqueuePacket(0, packet);
    }
Exemple #4
0
    public void ClickLeave()
    {
        GameManager.EnableCamera(true);
        GameManager.SetPlayerCam(null);

        PacketHandleClickUI packet = new PacketHandleClickUI();

        foreach (Transform child in GameManager.GameObjectContainer.transform)
        {
            Destroy(child.gameObject);
        }

        packet.UIClicked = PacketHandleClickUI.UIButton.LeaveGameButton;
        EventManager.Get().EnqueuePacket(0, packet);
        MenuController.ChangeState(MenuController.EGameState.Menu);
    }
Exemple #5
0
    public void OnClickQuitGame()
    {
        PacketHandleClickUI packet = new PacketHandleClickUI();

        packet.UIClicked = PacketHandleClickUI.UIButton.LeaveGameButton;
        EventManager.Get().EnqueuePacket(0, packet);

        foreach (var p in GameManager.PlayerInfos)
        {
            if (m_lines.ContainsKey(p.Key))
            {
                Destroy(m_lines[p.Key].gameObject);
            }
        }

        m_lines.Clear();
        GameManager.PlayerInfos.Clear();
        MenuController.ChangeState(MenuController.EGameState.Menu);
    }
        private void ManageHandleUIPacket(PacketHandleClickUI packet)
        {
            // TODO : check state du jeu -> le joueur peut avoir cliqué sur le bouton?
            switch (packet.UIClicked)
            {
            case PacketHandleClickUI.UIButton.JoinGameButton:
                PacketJoinGameRequest newPacketJoin = new PacketJoinGameRequest();
                newPacketJoin.GameJoinedId = packet.GameIdToJoin;
                EventManager.Get().EnqueuePacket(0, newPacketJoin);
                break;

            case PacketHandleClickUI.UIButton.CreateGameButton:
                EventManager.Get().EnqueuePacket(0, new PacketCreateGameRequest());
                break;

            case PacketHandleClickUI.UIButton.LeaveGameButton:
                EventManager.Get().EnqueuePacket(0, new PacketLeaveGameRequest());
                break;

            case PacketHandleClickUI.UIButton.GetGameButton:
                EventManager.Get().EnqueuePacket(0, new PacketGetGameRequest());
                break;

            case PacketHandleClickUI.UIButton.SendTextButton:
                PacketTextMessage newPacketText = new PacketTextMessage();
                newPacketText.MessageText = packet.TextMessage;
                EventManager.Get().EnqueuePacket(0, newPacketText);
                break;

            case PacketHandleClickUI.UIButton.ReadyButton:
                EventManager.Get().EnqueuePacket(0, new PacketPlayerReady());
                break;

            default:
                break;
            }
        }
Exemple #7
0
        static void HandleInput()
        {
            while (!wantToCancel)
            {
                Console.WriteLine("0 : Message | 1 : Get games | 2 : Create games | 3 : Join game | 4 : Leave game | 5 : Ready \n Your choice : ");
                string choice = Console.ReadLine();

                if (choice == "stop")
                {
                    wantToCancel = true;
                }
                else if (choice == "0")
                {
                    Console.WriteLine("Your message : ");
                    string message = Console.ReadLine();

                    PacketTextMessage packet = new PacketTextMessage();
                    packet.MessageText = message;
                    EventManager.Get().EnqueuePacket(0, packet);
                }
                else if (choice == "1")
                {
                    PacketHandleClickUI packet = new PacketHandleClickUI();
                    packet.UIClicked = PacketHandleClickUI.UIButton.GetGameButton;
                    EventManager.Get().EnqueuePacket(0, packet);
                }
                else if (choice == "2")
                {
                    PacketHandleClickUI packet = new PacketHandleClickUI();
                    packet.UIClicked = PacketHandleClickUI.UIButton.CreateGameButton;
                    EventManager.Get().EnqueuePacket(0, packet);
                }
                else if (choice == "3")
                {
                    Console.WriteLine("Game id : ");
                    string message = Console.ReadLine();

                    uint idGame = 0;
                    if (uint.TryParse(message, out idGame))
                    {
                        PacketHandleClickUI packet = new PacketHandleClickUI();
                        packet.UIClicked    = PacketHandleClickUI.UIButton.JoinGameButton;
                        packet.GameIdToJoin = idGame;

                        EventManager.Get().EnqueuePacket(0, packet);
                    }
                }
                else if (choice == "4")
                {
                    PacketHandleClickUI packet = new PacketHandleClickUI();
                    packet.UIClicked = PacketHandleClickUI.UIButton.LeaveGameButton;
                    EventManager.Get().EnqueuePacket(0, packet);
                }
                else if (choice == "5")
                {
                    PacketHandleClickUI packet = new PacketHandleClickUI();
                    packet.UIClicked = PacketHandleClickUI.UIButton.ReadyButton;
                    EventManager.Get().EnqueuePacket(0, packet);
                }
                else if (choice == "6")
                {
                    PacketHandleMovementInput packet = new PacketHandleMovementInput(1, 2, new DeusVector2(0, 10));
                    EventManager.Get().EnqueuePacket(0, packet);
                }
                else if (choice == "7")
                {
                    PacketHandleMovementInput packet = new PacketHandleMovementInput(1, 2, new DeusVector2(0, 0));
                    EventManager.Get().EnqueuePacket(0, packet);
                }
            }
        }