Пример #1
0
    // Use this for initialization
    void Start()
    {
        GameOverInfo info = GameObject.FindObjectOfType <GameOverInfo>();

        GetComponent <Text>().text = "Score: " + info.score + "\n"
                                     + "Players: " + info.numPlayers;
    }
Пример #2
0
 public void changeToGameOverScene(GameOverInfo gameOverInfo)
 {
     //Se cambia de escena a la escena de Game Over
     this.gameOverInfo = gameOverInfo;
     currentScene      = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex;
     UnityEngine.SceneManagement.SceneManager.LoadScene("GameOverScene");
 }
Пример #3
0
    void OnEnable()
    {
        RoomMgr            rm      = RoomMgr.GetInstance();
        GameOverInfo       info    = rm.overinfo;
        List <GameEndInfo> endinfo = info.endinfo;

        int maxScore = -1;

        foreach (PlayerInfo p in rm.players)
        {
            if (p.score > maxScore)
            {
                maxScore = p.score;
            }
        }

        Transform seats = transform.Find("seats");
        UIGrid    grid  = seats.GetComponent <UIGrid>();
        int       index = 0;

        for (int i = 0; i < rm.players.Count; i++, index++)
        {
            PlayerInfo  p      = rm.players[i];
            Transform   seat   = seats.GetChild(i);
            GameEndInfo ei     = endinfo[i];
            bool        bigwin = p.score > 0 && p.score == maxScore;

            seat.gameObject.SetActive(true);

            seat.Find("bghead/icon").GetComponent <IconLoader> ().setUserID(p.userid);
            seat.Find("name").GetComponent <UILabel>().text  = p.name;
            seat.Find("id").GetComponent <UILabel>().text    = "ID:" + p.userid;
            seat.Find("score").GetComponent <UILabel>().text = "" + p.score;
            seat.Find("winner").gameObject.SetActive(bigwin);
            seat.Find("owner").gameObject.SetActive(false);

            Transform stats     = seat.Find("stats");
            string[]  statNames = new string[] { "自摸次数", "接炮次数", "点炮次数" /* , "暗杠次数", "明杠次数" */ };
            for (int j = 0; j < statNames.Length; j++)
            {
                stats.GetChild(j).GetComponent <UILabel>().text = statNames[j];
            }

            Transform vals     = seat.Find("values");
            int[]     statVals = new int[] { ei.numzimo, ei.numjiepao, ei.numdianpao /*, ei.numangang, ei.numminggang */ };
            for (int j = 0; j < statVals.Length; j++)
            {
                vals.GetChild(j).GetComponent <UILabel>().text = "" + statVals[j];
            }
        }

        for (int i = index; i < seats.childCount; i++)
        {
            seats.GetChild(i).gameObject.SetActive(false);
        }

        grid.Reposition();
    }
Пример #4
0
 void Start()
 {
     anim  = GameObject.Find("Canvas").GetComponent <Animator>();
     stop  = GetComponent <PlayerMovement>();
     goi   = GetComponent <GameOverInfo>();
     tail  = GetComponent <BoardClassic>();
     adCon = GetComponent <AdController>();
     dpad  = GameObject.Find("DPad");
 }
Пример #5
0
 void Start()
 {
     anim  = GameObject.Find("Canvas").GetComponent <Animator>();
     text  = GetComponent <DictionaryLookup>();
     stop  = GetComponent <PlayerMovement>();
     goi   = GetComponent <GameOverInfo>();
     tail  = GetComponent <BoardWordSnake>();
     adCon = GetComponent <AdController>();
     dpad  = GameObject.Find("DPad");
 }
        public override void OnDisconnected(DisconnectCause cause)
        {
            Debug.LogFormat("A Player Left Room: " + PhotonNetwork.LocalPlayer.NickName);
            GameOverInfo overInfo = new GameOverInfo();

            overInfo.lostPlayerID = PhotonNetwork.LocalPlayer.UserId;
            overInfo.reasonToLose = "player Disconnected";
            multiplayerService.ChangeToGameOverState(overInfo);
            Debug.Log("Disconnected because of: " + cause);
        }
Пример #7
0
 public void CloseGameOverScene()
 {
     //reiniciar valors de gameoverinfo
     GameOverInfo.Init();
     //desactivem les tombes
     for (int i = 1; i <= numberLosers; i++)
     {
         GameObject.Find("Background/Background Island/Loser" + i).SetActive(false);
     }
     SceneManager.LoadScene(0);
 }
Пример #8
0
    // Start is called before the first frame update
    void Start()
    {
        //se obtiene la información y se muestra en la pantalla
        GameObject   gameOverController = GameObject.Find("GameOverController");
        GameOverInfo gameOverInfo       = gameOverController.GetComponent <GameOverController>().gameOverInfo;

        previousScene = gameOverController.GetComponent <GameOverController>().currentScene;
        Destroy(GameObject.Find("GameOverController"));

        transform.GetChild(0).gameObject.GetComponent <Text>().text    = gameOverInfo.text;
        transform.GetChild(1).gameObject.GetComponent <Image>().sprite = gameOverInfo.sprite;
    }
Пример #9
0
 public void playerHit()
 {
     lives--;
     if (lives < 0)
     {
         GameObject   g    = new GameObject();
         GameOverInfo info = g.AddComponent <GameOverInfo>();
         info.numPlayers = Config.NUMBER_OF_PLAYERS;
         info.score      = score;
         Application.LoadLevel("GameOverScene");
     }
 }
Пример #10
0
    public void reset()
    {
        info      = new RoomInfo();
        conf      = new RoomConf();
        players   = new List <PlayerInfo> ();
        state     = new GameState();
        seats     = new List <SeatInfo> ();
        action    = new GameAction();
        overinfo  = new GameOverInfo();
        histories = new List <GameOverInfo>();

        dissolve = null;
    }
        void GameOverEventProscess(EventData photonEvent)
        {
            Debug.Log("[CommunicationManager] GameOver Scene");
            object[]     data         = (object[])photonEvent.CustomData;
            GameOverInfo gameOverInfo = new GameOverInfo();

            gameOverInfo.lostPlayerID = (string)data[0];
            gameOverInfo.reasonToLose = (string)data[1];
            multiplayerService.ChangeToGameOverState(gameOverInfo);
            roomManager.ResetPlayersInRoom();
            PhotonNetwork.LeaveRoom();
            //PhotonNetwork.JoinLobby();
        }
        public void NotifyGameOver(GameOverInfo gameOverInfo)
        {
            Debug.Log("GameOver");
            //GAMEOVEREVENT
            object[]          content           = new object[] { gameOverInfo.lostPlayerID, gameOverInfo.reasonToLose };
            RaiseEventOptions raiseEventOptions = new RaiseEventOptions {
                Receivers = ReceiverGroup.All
            };
            SendOptions sendOptions = new SendOptions {
                Reliability = true
            };

            PhotonNetwork.RaiseEvent(GAMEOVEREVENT, content, raiseEventOptions, sendOptions);
        }
Пример #13
0
        public NotificationPage(GameOverInfo info)
        {
            IsOpen = true;
            ScaleX = 0;

            Info = info;

            Style       = Application.Current.Resources["GameOverOutsideFrameStyle"] as Style;
            Frame.Style = Application.Current.Resources["GameOverInsideFrameStyle"] as Style;

            Task.Run(async() => await BeginAnimation(this));

            Initialize();
        }
Пример #14
0
        public override void ProcessLogic(IGameModuleContext context)
        {
            if (gameLogic.GameOverJustification.IsGameOver)
            {
                var info = new GameOverInfo(playerName, gameLogic.ScoreStatus.Value, gameLogic.GameOverJustification.Reason);

                context.Exit(info);

                return;
            }

            gameLogic.Update();
            scoreTransitionUI.Update();
        }
Пример #15
0
    void OnEnable()
    {
        Debug.Log("OnEnable");
        if (btn_next != null)
        {
            RoomMgr rm  = RoomMgr.GetInstance();
            int     cnt = rm.histories.Count;
            index = cnt > 0 ? cnt - 1 : 0;

            GameOverInfo info = rm.histories [index];
            showResults(info.results);

            updateBtns();
        }
    }
Пример #16
0
    public void onBtnPrev()
    {
        RoomMgr rm  = RoomMgr.GetInstance();
        int     cnt = rm.histories.Count;

        if (index > 0)
        {
            index--;
        }

        if (index >= 0 && index < cnt)
        {
            GameOverInfo info = rm.histories [index];
            showResults(info.results);
        }

        updateBtns();
    }
Пример #17
0
        private void DisplayGameNotification(bool isVictory, int wrongMines)
        {
            GameOverInfo info = new GameOverInfo
            {
                DidWin            = isVictory,
                Time              = Timer.Timer,
                MineLeft          = Minesweeper.MinesLeft,
                RightGuessedMines = Settings.GetSettings().CountMines - Minesweeper.MinesLeft - wrongMines,
                WrongGuessedMines = wrongMines,
                AllMines          = Settings.GetSettings().CountMines,
                FlagedMines       = Settings.GetSettings().CountMines - Minesweeper.MinesLeft,
                Restart           = () => { Restart(); Minesweeper.IsEnabled = true; },
                OpenRecords       = NavigateThroughRecords
            };

            NotificationPage notification = new NotificationPage(info);

            _mainGrid.Children.Add(notification);
        }
Пример #18
0
    public GameOverInfo updateOverInfo(JsonObject data)
    {
        GameOverInfo _info = JsonUtility.FromJson <GameOverInfo> (data.ToString());

        overinfo = _info;
        histories.Add(_info);

        bool dissolve = _info.results.Count == 0;

        if (!dissolve)
        {
            for (int i = 0; i < players.Count; i++)
            {
                players [i].score = _info.results [i].totalscore;
            }
        }

        return(_info);
    }
Пример #19
0
    public void checkLogic()
    {
        for (int i = players.Count - 1; i >= 0; i--)
        {
            if (players[i].GetNumSlimes() == 0)
            {
                //This player loses
                GameOverInfo.SetLoser(players[i]);
                //si li tocava al que ha mort i aquest era l'ultim de la llista, el torn es el del primer de la llista
                players.RemoveAt(i); //definitivament el borrem de la llista
                break;
            }
        }

        Player winner = IsGameEndedAndWinner();

        if (winner != null)
        {
            GameOverInfo.SetWinner(winner);
            foreach (Player p in players)
            {
                if (p != winner)
                {
                    GameOverInfo.SetLoser(p);
                }
            }
            GameSelection.playerColors.Clear();
            GameSelection.playerCores.Clear();
            GameSelection.playerIAs.Clear();
            //players.Clear ();
            SceneManager.LoadScene("GameOver");
        }

        if (playerActions >= currentPlayer.actions)
        {
            NextPlayer();
        }
        else
        {
            status = GameControllerStatus.WAITINGFORACTION;
        }
    }
Пример #20
0
    public void doGameOver()
    {
#if UNIT_TEST
        unittest();
#else
        RoomMgr      rm   = RoomMgr.GetInstance();
        GameOverInfo info = rm.overinfo;
        List <GameOverPlayerInfo> results = info.results;
        List <GameEndInfo>        endinfo = info.endinfo;

        int cnt = rm.histories.Count;
        index = cnt > 0 ? cnt - 1 : 0;

        if (btn_next != null)
        {
            btn_next.SetActive(false);
        }

        if (btn_prev != null)
        {
            btn_prev.SetActive(false);
        }

        if (results == null || results.Count == 0)
        {
            gameObject.SetActive(false);
            game_result.SetActive(true);
            Debug.Log("result []");
            return;
        }

        bool over = endinfo != null && endinfo.Count > 0;

        btn_start.SetActive(!over);
        btn_result.SetActive(over);

        showResults(results);
#endif
    }
Пример #21
0
    public void updateRoom(JsonObject room)
    {
        JsonUtility.FromJsonOverwrite(room.ToString(), info);
        JsonUtility.FromJsonOverwrite(room ["conf"].ToString(), conf);

        JsonArray _seats     = room ["seats"] as JsonArray;
        JsonArray _histories = room["histories"] as JsonArray;

        players.Clear();
        seats.Clear();
        histories.Clear();

        int userid = GameMgr.GetInstance().userMgr.userid;

        for (int i = 0; i < _seats.Count; i++)
        {
            JsonObject seat   = (JsonObject)_seats[i];
            PlayerInfo player = JsonUtility.FromJson <PlayerInfo>(seat.ToString());

            players.Add(player);
            seats.Add(new SeatInfo());

            if (userid == player.userid)
            {
                seatindex = i;
            }
        }

        for (int i = 0; i < _histories.Count; i++)
        {
            JsonObject   history = (JsonObject)_histories[i];
            GameOverInfo info    = JsonUtility.FromJson <GameOverInfo>(history.ToString());

            histories.Add(info);
        }

        Debug.Log("_histories count: " + _histories.Count);
    }
        public void playerHit(string hitPlayerID, int charachterID, float damage)
        {
            inRoomplayers[hitPlayerID][charachterID] -= damage;
            HitInfo hitInfo = new HitInfo();

            hitInfo.playerId        = hitPlayerID;
            hitInfo.characterHealth = inRoomplayers[hitPlayerID][charachterID];
            hitInfo.characterId     = charachterID;
            hitInfo.destroy         = false;
            if (inRoomplayers[hitPlayerID][charachterID] < 0)
            {
                hitInfo.destroy = true;
                inRoomplayers[hitPlayerID].Remove(charachterID);
            }
            communicationManager.NotifyPlayerHit(hitInfo);
            if (inRoomplayers[hitPlayerID].Count < 1)
            {
                GameOverInfo overInfo = new GameOverInfo();
                overInfo.lostPlayerID = hitPlayerID;
                overInfo.reasonToLose = "All Characters Dead";
                communicationManager.NotifyGameOver(overInfo);
            }
        }
Пример #23
0
    // Use this for initialization
    void Start()
    {
        Player winner = GameOverInfo.GetWinner();

        GameObject.Find("Background/Background Winner poster/Player").GetComponent <Text>().text += " #" + winner.GetName().Substring(winner.GetName().Length - 1, 1);
        GameObject go = GameObject.Find("Background/Background Island/WinnerBody");

        if (!winner.GetName().Equals("0"))
        {
            go.GetComponent <Image>().color = winner.GetColor();
            go = GameObject.Find("Background/Background Island/WinnerBody/WinnerFace");
            go.GetComponent <Image>().sprite = SpritesLoader.GetInstance().GetResource(winner.statsCoreInfo.picDirection);
        }
        List <Player> losers = GameOverInfo.GetLosers();

        //com a molt hi ha 5 losers
        numberLosers = losers.Count;
        for (int i = 0; i < numberLosers; i++)
        {
            go = GameObject.Find("Background/Background Island/Loser" + (i + 1));
            go.SetActive(true);
            go.GetComponent <Image>().color = losers[i].GetColor();
        }
    }
Пример #24
0
        //====== ctors

        public GameOverGameModule(GameOverInfo gameOverInfo, int?placement)
        {
            this.gameOverInfo = Verify.NotNull(gameOverInfo, nameof(gameOverInfo));
            this.placement    = placement;
        }
Пример #25
0
 public void ChangeToGameOverState(GameOverInfo gameOverInfo)
 {
     gameService.ChangeToGameOverState(gameOverInfo);
     playerService.ResetPlayerService();
 }
Пример #26
0
    // Use this for initialization
    void Start()
    {
        /*
         * TipDialog a = new TipDialog ();
         * a.SetButtonImage(SpritesLoader.GetInstance ().GetResource ("Buttons/button_template"));
         * a.SetBackgroundImage(SpritesLoader.GetInstance ().GetResource ("Panels/emergent"));
         * a.SetInfoTextText ("Has aceptado");
         * a.Hide ();
         * TwoOptionsDialog t = new TwoOptionsDialog();
         * t.SetButtonsImage(SpritesLoader.GetInstance ().GetResource ("Buttons/button_template"));
         * t.SetBackgroundImage(SpritesLoader.GetInstance ().GetResource ("Panels/emergent"));
         * t.SetAceptButtonColor (new Color(0f,0f,1f));
         * t.SetDeclineButtonColor (new Color(1f,0f,0f));
         * t.SetOnClickAceptFunction(()=>{
         *      a.Show();
         * });
         */

        /*
         *      Time.timeScale = 1;
         *      ChainTextDialog ctd = new ChainTextDialog ();
         *      ctd.SetButtonImage(SpritesLoader.GetInstance ().GetResource ("Buttons/button_template"));
         *      ctd.SetBackgroundImage(SpritesLoader.GetInstance ().GetResource ("Panels/emergent"));
         */

        TileFactory.tileMaterial = tileMaterial;
        //InGameMarker igm = new InGameMarker ();
        //igm.SetSprite (SpritesLoader.GetInstance().GetResource("Test/testTileSlim"));
        FloatingTextController.Initialize();
        uiController    = Camera.main.GetComponent <UIController>();
        soundController = gameObject.GetComponent <SoundController>();
        camController   = Camera.main.GetComponent <CameraController>();
        conquerSprite   = SpritesLoader.GetInstance().GetResource("Tiles/conquest_flag");
        //panelTip = GameObject.Find("PanelTip"); //ja tenim el panell, per si el necessitem activar, i desactivar amb : panelTip.GetComponent<DialogInfo> ().Active (boolean);
        //textTip = GameObject.Find("TextTip"); //ja tenim el textBox, per canviar el text : textTip.GetComponent<Text> ().text = "Text nou";
        //panelTip.GetComponent<DialogInfo>().Active(false);
        //textTip.GetComponent<Text>().text = "Aquí es mostraran els diferents trucs que pot fer el jugador";
        players        = new List <Player>();
        Time.timeScale = 1f;
        if (ModosVictoria.IsDefined(typeof(ModosVictoria), GameSelection.modoVictoria))
        {
            condicionVictoria = (ModosVictoria)GameSelection.modoVictoria;
        }
        else
        {
            condicionVictoria = ModosVictoria.ASESINATO; //por defecto
        }

        MAX_TURNS = GameSelection.MAX_TURNS;

        int maxPlayers = GameSelection.playerColors.Count;

        if (maxPlayers == 0)
        {
            GameSelection.playerColors.Add(new Color(0, 0, 1));
            GameSelection.playerColors.Add(new Color(1, 0, 0));
            GameSelection.playerCores.Add(SlimeCoreTypes.SLOTH);
            GameSelection.playerCores.Add(SlimeCoreTypes.WRATH);
            GameSelection.playerIAs.Add(false);
            GameSelection.playerIAs.Add(true);
            maxPlayers = 2;
        }
        for (int i = 0; i < maxPlayers; i++)
        {
            if (GameSelection.playerIAs [i])
            {
                //players.Add(new Player("Jugador "+(i+1),StatsFactory.GetStat(GameSelection.playerCores[i])));
                Debug.Log("Ia true");
                players.Add(new Player("Jugador " + (i + 1), StatsFactory.GetStat(GameSelection.playerCores[i]), AIManager.GetAIByVictoryCondition(this, condicionVictoria)));
            }
            else
            {
                players.Add(new Player("Jugador " + (i + 1), StatsFactory.GetStat(GameSelection.playerCores[i])));
            }
            players[i].SetColor(GameSelection.playerColors[i]);
        }
        matrix = GameSelection.map;//new Matrix(11, 0.3f, 1234567);
        if (matrix == null)
        {
            matrix = new Matrix(5 * players.Count, 0.3f, Random.Range(0, 10000));
        }
        MapDrawer.instantiateMap(matrix.getIterable());
        int numSlimesPerPlayer           = 2;
        List <List <Vector2> > positions = matrix.GetPositions(players.Count, numSlimesPerPlayer);
        int j = 0;

        foreach (Player player in players)
        {
            List <Vector2> positionsSlimes = positions[j];
            foreach (Vector2 positionSlime in positionsSlimes)
            {
                SlimeFactory.instantiateSlime(player, positionSlime);
            }
            j++;
        }
        if (players.Count == 0)
        {
            players.Add(new Player("Jugador 1", StatsFactory.GetStat(SlimeCoreTypes.WRATH), AIManager.GetAIByVictoryCondition(this, condicionVictoria)));            // Test with 2 players
            players.Add(new Player("Jugador 2", StatsFactory.GetStat(SlimeCoreTypes.GLUTTONY)));
            players[0].SetColor(Color.blue);
            players[1].SetColor(Color.red);
            positions = matrix.GetPositions(players.Count, 1);
            SlimeFactory.instantiateSlime(players[0], positions[0][0]);
            SlimeFactory.instantiateSlime(players[1], positions[1][0]);
        }
        //matrix = new Matrix(MapParser.ReadMap(MapTypes.Medium));

        currentTurn   = 0;
        currentPlayer = players[0];
        playerActions = 0;

        uiController.UpdateRound(currentTurn + 1);
        uiController.UpdatePlayer(GetCurrentPlayer().GetColor());

        uiController.UpdateActions(playerActions, GetCurrentPlayer().actions);
        uiController.ShowBothPanels();
        //iniciem la informacio de game over
        totalTiles = matrix.TotalNumTiles();
        //Debug.Log("TILES TOTALS: "+ totalTiles);

        // La condicio de victoria s'assigna mes amunt, aqui nomes s'actualitzen els requisits.
        switch (condicionVictoria)
        {
        case ModosVictoria.CONQUISTA:
            //define percentage tiles to win
            if (MAX_TURNS == 0)
            {
                percentageTilesToWin = 0.25f;
            }
            else
            {
                percentageTilesToWin = 0.75f;
            }

            //Debug.Log("Porcentaje de conquista para ganar: "+percentageTilesToWin);
            break;

        case ModosVictoria.MASA:
            //define mass to win
            massToWin = 0;
            foreach (Player player in players)
            {
                if (player.GetTotalMass() > massToWin)
                {
                    massToWin = player.GetTotalMass();
                }
            }
            massToWin *= 2;
            //Debug.Log("Masa total del jugador para ganar: "+massToWin);
            break;
        }

        GameOverInfo.Init();
        AudioClip clip = SoundsLoader.GetInstance().GetResource("Sounds/MainGameTheme");

        soundController.PlayLoop(clip);
        camController.InitMaxZoom();


        status = GameControllerStatus.CHECKINGLOGIC;
    }
Пример #27
0
 private void PlayerControllerOnGameOver(GameOverInfo gameOverInfo)
 {
     SceneTransitionManager.FadeOutThenFadeIn(_endGameScreenScene, SoundManager.GameOverClip);
 }