Exemplo n.º 1
0
        /// <summary>
        /// Loads all the content needed for the game stage
        /// </summary>
        public static void LoadContent()
        {
            //Link togther the LevelContainer and InputMenu class throug events

            //Level Events
            LevelContainer.Instance.RunCompleteFailed  += m => InputMenu.Instance.ShowResultsForRoundFailed(m);
            LevelContainer.Instance.RunCompleteSuccess += li => InputMenu.Instance.ShowResultsForRoundSuccess(li);
            LevelContainer.Instance.AllLevelsComplete  += lr => InputMenu.Instance.ShowResultsAllLevelsComplete(lr);


            //Command events
            InputMenu.Instance.CommandReadingStarting    += () => LevelContainer.Instance.ReStartLevel();
            InputMenu.Instance.CommandReadingComplete    += q => LevelContainer.Instance.LoadCommands(q);
            LevelContainer.Instance.ExecutingNextCommand += () => InputMenu.Instance.ShowNextCommand();

            //Collectable events
            LevelContainer.Instance.KeysAndGemsCounted += (nk, ng) => InputMenu.Instance.SetNumKeys(nk, ng);
            LevelContainer.Instance.playerKeyCollected += nk => InputMenu.Instance.UpdateNumCollectedKeys(nk);
            LevelContainer.Instance.playerGemCollected += ng => InputMenu.Instance.UpdateNumCollectedGems(ng);

            //leaving the game stage
            InputMenu.Instance.PlayerReadyToExistMainGame += s => AllLevelsComplete.Invoke(s);
            InputMenu.Instance.QuitGame += () => BackToMenu.Invoke();



            //Load content for LevelContainer and InputMenu
            foreach (ISection section in sections)
            {
                section.LoadContent();
            }

            //Load the legend image
            legend = Helper.LoadImage("Images/command legend ethan");
        }
Exemplo n.º 2
0
        public LobbyViewModel(GTTcpClient client, PlayerListViewModel playerList)
        {
            SelectedGameStage = GameStage.First;
            _playerList       = playerList;
            IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());

            HostIp            = ipHostInfo.AddressList.Where(ip => ip.AddressFamily == AddressFamily.InterNetwork).First().ToString();
            ConnectInProgress = false;
            Port    = DefaultPort;
            Ip      = HostIp;
            _client = client;
            _client.BuildingBegun      += Client_BuildingBegun;
            _playerList.LostConnection += PlayerList_LostConnection;

            HostCommand = new DelegateCommand(param => Server == null, param =>
            {
                try
                {
                    Server = new GTTcpListener(Port, SelectedGameStage);
                    Task.Factory.StartNew(() => Server.Start(), TaskCreationOptions.RunContinuationsAsynchronously | TaskCreationOptions.LongRunning);
                    Ip = "127.0.0.1";
                    ConnectCommand.Execute(null);
                }
                catch (SocketException)
                {
                    Error = "Az adott port már használatban van!";
                }
            });

            ConnectCommand = new DelegateCommand(param => !ConnectInProgress && !IsConnected, param => Connect());

            ReadyCommand = new DelegateCommand(param =>
            {
                try
                {
                    _client.ToggleReady(ServerStage.Lobby);
                }
                catch (Exception e)
                {
                    Error = $"Hiba a szerverrel való kommunikáció közben:\n{e.Message}";
                }
            });

            BackToMenuCommand = new DelegateCommand(param =>
            {
                UnsubscribeFromEvents();
                BackToMenu?.Invoke(this, Server != null);
            });

            StartBuildingCommand = new DelegateCommand(param => Server != null && !Server.NotReadyPlayers.Any() && _client.PlayerInfos.Count > 1,
                                                       param =>
            {
                Task.Factory.StartNew(() => Server.StartBuildStage(), TaskCreationOptions.LongRunning);
            });
        }
Exemplo n.º 3
0
 void Start()
 {
     PhotonNetwork.ConnectUsingSettings(null);
     md         = GameObject.Find("ModeData").GetComponent <ModeData>();
     roomhost   = GameObject.Find("InputFieldText").GetComponent <Text>();
     push1      = GameObject.Find("OkButton").GetComponent <RoomName>();
     push2      = GameObject.Find("StartButton").GetComponent <RoomMake>();
     numplayers = GameObject.Find("NumOfPlayers").GetComponent <Text>();
     dd         = GameObject.Find("RoomDropdown").GetComponent <Dropdown>();
     dlabel     = GameObject.Find("DropdownLabel").GetComponent <Text>();
     push3      = GameObject.Find("RoomDropdown").GetComponent <Guest>();
     push4      = GameObject.Find("BackButton").GetComponent <BackButton>();
     push5      = GameObject.Find("BackToMenuButton").GetComponent <BackToMenu>();
     //DontDestroyOnLoad(this);
     suit = new string[4] {
         "♠", "♥", "♣", "♦"
     };
 }
Exemplo n.º 4
0
 private void OnBackToMenu()
 {
     BackToMenu?.Invoke(this, EventArgs.Empty);
 }