예제 #1
0
 public void Next()
 {
     if (TournamentUtil.Instance.IsInFinals)
     {
         Game.Instance.Nation02 = NationalSuits.getNationById(TournamentUtil.Instance.FinalsIds [1]);
     }
     else if (TournamentUtil.Instance.IsInSemiFinals)
     {
         Game.Instance.Nation02 = NationalSuits.getNationById(TournamentUtil.Instance.SemiFinalsIds [1]);
     }
     else if (TournamentUtil.Instance.IsInQuarter)
     {
         Game.Instance.Nation02 = NationalSuits.getNationById(TournamentUtil.Instance.QuarterIds [1]);
     }
     else if (TournamentUtil.Instance.IsInR16)
     {
         Game.Instance.Nation02 = NationalSuits.getNationById(TournamentUtil.Instance.R16Ids [1]);
     }
     Game.Instance.LandscapeId        = 255;
     Game.Instance.PlayerScore01      = 0;
     Game.Instance.PlayerScore02      = 0;
     Game.Instance.RemainingPlayers01 = Game.TEAM_PLAYERS;
     Game.Instance.RemainingPlayers02 = Game.TEAM_PLAYERS;
     Game.Instance.TimerActive        = true;
     Game.Instance.TimeRemained       = 120.2f;
     Application.LoadLevelAsync(Constants.LEVEL_GAMEPLAY);
 }
예제 #2
0
    void SetSemiFinals()
    {
        for (int i = 0; i < TournamentUtil.Instance.R16Ids.Length; i++)
        {
            byte id;
            if (i == 0)
            {
                id = (byte)NationalSuits.getNationId(Game.Instance.Nation01);
            }
            else
            {
                id = TournamentUtil.Instance.R16Ids [i];
            }
            R16Flags [i].sprite2D = NationalSuits.getNationFlag(NationalSuits.getNationById(id));
        }

        for (int i = 0; i < TournamentUtil.Instance.QuarterIds.Length; i++)
        {
            byte id;
            if (i == 0)
            {
                id = (byte)NationalSuits.getNationId(Game.Instance.Nation01);
            }
            else
            {
                id = TournamentUtil.Instance.QuarterIds [i];
            }
            QuartiFlags [i].sprite2D  = NationalSuits.getNationFlag(NationalSuits.getNationById(id));
            R16Goals [i * 2].text     = "" + TournamentUtil.Instance.R16Goals [i * 2];
            R16Goals [i * 2 + 1].text = "" + TournamentUtil.Instance.R16Goals [i * 2 + 1];
            if (TournamentUtil.Instance.R16Goals [i * 2] > TournamentUtil.Instance.R16Goals [i * 2 + 1])
            {
                R16Bg [i * 2].sprite2D = bgRosso;
            }
            else
            {
                R16Bg [i * 2 + 1].sprite2D = bgRosso;
            }
        }

        TournamentUtil.Instance.IsInSemiFinals = true;
        for (int i = 0; i < TournamentUtil.Instance.SemiFinalsIds.Length; i++)
        {
            Partita partita = CosaGoal(i, TournamentUtil.Instance.QuarterIds, TournamentUtil.Instance.QuarterGoals);
            SemifinaleFlags [i].sprite2D = NationalSuits.getNationFlag(NationalSuits.getNationById(partita.Id));
            QuartiGoals [i * 2].text     = "" + partita.Goal01;
            QuartiGoals [i * 2 + 1].text = "" + partita.Goal02;
            if (partita.Goal01 > partita.Goal02)
            {
                QuartiBg [i * 2].sprite2D = bgRosso;
            }
            else
            {
                QuartiBg [i * 2 + 1].sprite2D = bgRosso;
            }
            TournamentUtil.Instance.SemiFinalsIds [i]        = partita.Id;
            TournamentUtil.Instance.QuarterGoals [i * 2]     = partita.Goal01;
            TournamentUtil.Instance.QuarterGoals [i * 2 + 1] = partita.Goal02;
        }
    }
예제 #3
0
    void OnClick()
    {
        //UIGrid panel = NGUITools.FindInParents<UIGrid> (gameObject);
        //byte index = (byte)panel.GetIndex (this.transform);

        //byte nationId = (byte)(index + groupId * 4);
        if (Game.Instance.EditingNation01)
        {
            Game.Instance.Nation01 = NationalSuits.getNationById(nationId);
        }
        else if (Game.Instance.EditingNation02)
        {
            Game.Instance.Nation02 = NationalSuits.getNationById(nationId);
        }

        Game.Instance.EditingNation01 = false;
        Game.Instance.EditingNation02 = false;
    }
예제 #4
0
 void SetR16()
 {
     TournamentUtil.Instance.IsInR16 = true;
     for (int i = 0; i < TournamentUtil.Instance.R16Ids.Length; i++)
     {
         byte id;
         if (i == 0)
         {
             id = (byte)NationalSuits.getNationId(Game.Instance.Nation01);
         }
         else
         {
             id = getId(TournamentUtil.Instance.R16Ids);
         }
         TournamentUtil.Instance.R16Ids [i] = id;
         R16Flags [i].sprite2D = NationalSuits.getNationFlag(NationalSuits.getNationById(id));
     }
 }
예제 #5
0
    public void ConfigureOnlineFinished()
    {
        UniversalOnline.Instance.Progress = 90;
        byte[]     dataSmall = new byte[20];
        PlayerEnum player    = PlayerEnumUtils.GetCurrentPlayer();

        dataSmall [0] = Constants.CODE_CONFIGURE_MATCH;

        if (player == PlayerEnum.RIGHT)
        {
            int nationId02 = NationalSuits.getNationId(Game.Instance.Nation02);
            Game.Instance.LandscapeId = (byte)Random.Range(0, (int)Constants.BACKGROUNDS);
            dataSmall [1]             = Game.Instance.LandscapeId;
            dataSmall [2]             = Constants.CODE_NOTHING;
            dataSmall [3]             = (byte)nationId02;
            Game.Instance.Nation02    = NationalSuits.getNationById((byte)nationId02);
        }
        else
        {
            int nationId01 = NationalSuits.getNationId(Game.Instance.Nation01);
            dataSmall [1] = Constants.CODE_NOTHING;
            dataSmall [2] = (byte)nationId01;
            dataSmall [3] = Constants.CODE_NOTHING;

            Game.Instance.Nation01 = NationalSuits.getNationById((byte)nationId01);
        }
        if (Game.Instance.OnlinePlay)
        {
            PlayGamesPlatform.Instance.RealTime.SendMessageToAll(true, dataSmall);
        }
        else if (Game.Instance.BluetoothPlay)
        {
                                                #if UNITY_ANDROID
            SendInfoToServerMainMenu(dataSmall);
                                                #endif
        }
        UniversalOnline.Instance.State = UniversalOnline.States.Playing;

        if (UniversalOnline.Instance.TheOpponentIsReady)
        {
            Invoke("StartOnlineMatch", 2.5f);
        }
    }
예제 #6
0
    public void OnMessageReceived(byte[] data)
    {
        if (ball == null)
        {
            ball = GameObject.FindGameObjectWithTag(Constants.TAG_BALL);
        }

        switch (data [0])                           // what to update
        {
        case Constants.CODE_BALL_AND_SHOOT:

            posX = BitConverter.ToSingle(data, 1 + 4 * 0);
            posY = BitConverter.ToSingle(data, 1 + 4 * 1);
            cos  = BitConverter.ToSingle(data, 1 + 4 * 2);
            sin  = BitConverter.ToSingle(data, 1 + 4 * 3);

            posBallX = BitConverter.ToSingle(data, 1 + 4 * 4);
            posBallY = BitConverter.ToSingle(data, 1 + 4 * 5);
            ballVelX = BitConverter.ToSingle(data, 1 + 4 * 6);
            ballVelY = BitConverter.ToSingle(data, 1 + 4 * 7);
            PlayerShooter.Instance.Shoot(posX, posY, cos, sin);
            ball.transform.GetComponent <Rigidbody2D>().velocity = new Vector2(ballVelX, ballVelY);
            ball.transform.position = new Vector3(posBallX, posBallY, 0);
            break;

        case Constants.CODE_GOAL:
            Camera.main.GetComponent <GamePlaySetup> ().FakeGoal();
            Game.Instance.PlayerScore01 = data [1];
            Game.Instance.PlayerScore02 = data [2];
            Camera.main.GetComponent <GamePlaySetup> ().UpdateScore();
            break;

        case Constants.CODE_BALL:
            posBallX = BitConverter.ToSingle(data, 1 + 4 * 0);
            posBallY = BitConverter.ToSingle(data, 1 + 4 * 1);
            ballVelX = BitConverter.ToSingle(data, 1 + 4 * 2);
            ballVelY = BitConverter.ToSingle(data, 1 + 4 * 3);
            ball.transform.GetComponent <Rigidbody2D>().velocity = new Vector2(ballVelX, ballVelY);
            ball.transform.position = new Vector3(posBallX, posBallY, 0);
            break;

        case Constants.CODE_TIME:
            Game.Instance.TimeRemained = data [1];
            Camera.main.GetComponent <GamePlaySetup> ().UpdateGuiTime();
            break;

        case Constants.CODE_REMAINING_PLAYERS:
            Game.Instance.RemainingPlayers01 = data [1];
            Game.Instance.RemainingPlayers02 = data [2];
            Camera.main.GetComponent <GamePlaySetup> ().UpdateLifeBar();
            break;

        case Constants.CODE_CONFIGURE_MATCH:
            if (data [1] != Constants.CODE_NOTHING)
            {
                Game.Instance.LandscapeId = data [1];
            }
            if (data [2] != Constants.CODE_NOTHING)
            {
                Game.Instance.Nation01 = NationalSuits.getNationById(data [2]);
            }
            if (data [3] != Constants.CODE_NOTHING)
            {
                Game.Instance.Nation02 = NationalSuits.getNationById(data [3]);
            }
            theOpponentIsReady = true;
            break;

        case Constants.CODE_ALL_READY:
            UniversalOnline.Instance.Progress = 0;
            theOpponentIsReady = false;
            //Application.LoadLevel (Constants.LEVEL_GAMEPLAY);
                        #if UNITY_PRO_LICENSE
            Application.LoadLevelAsync(Constants.LEVEL_GAMEPLAY);
                        #else
            Application.LoadLevel(Constants.LEVEL_GAMEPLAY);
                        #endif
            break;
        }
    }
예제 #7
0
    void SetWinner()
    {
        for (int i = 0; i < TournamentUtil.Instance.R16Ids.Length; i++)
        {
            byte id;
            if (i == 0)
            {
                id = (byte)NationalSuits.getNationId(Game.Instance.Nation01);
            }
            else
            {
                id = TournamentUtil.Instance.R16Ids [i];
            }
            R16Flags [i].sprite2D = NationalSuits.getNationFlag(NationalSuits.getNationById(id));
        }

        for (int i = 0; i < TournamentUtil.Instance.QuarterIds.Length; i++)
        {
            byte id;
            if (i == 0)
            {
                id = (byte)NationalSuits.getNationId(Game.Instance.Nation01);
            }
            else
            {
                id = TournamentUtil.Instance.QuarterIds [i];
            }
            QuartiFlags [i].sprite2D  = NationalSuits.getNationFlag(NationalSuits.getNationById(id));
            R16Goals [i * 2].text     = "" + TournamentUtil.Instance.R16Goals [i * 2];
            R16Goals [i * 2 + 1].text = "" + TournamentUtil.Instance.R16Goals [i * 2 + 1];
            if (TournamentUtil.Instance.R16Goals [i * 2] > TournamentUtil.Instance.R16Goals [i * 2 + 1])
            {
                R16Bg [i * 2].sprite2D = bgRosso;
            }
            else
            {
                R16Bg [i * 2 + 1].sprite2D = bgRosso;
            }
        }

        for (int i = 0; i < TournamentUtil.Instance.SemiFinalsIds.Length; i++)
        {
            byte id;
            if (i == 0)
            {
                id = (byte)NationalSuits.getNationId(Game.Instance.Nation01);
            }
            else
            {
                id = TournamentUtil.Instance.SemiFinalsIds [i];
            }
            SemifinaleFlags [i].sprite2D = NationalSuits.getNationFlag(NationalSuits.getNationById(id));
            QuartiGoals [i * 2].text     = "" + TournamentUtil.Instance.QuarterGoals [i * 2];
            QuartiGoals [i * 2 + 1].text = "" + TournamentUtil.Instance.QuarterGoals [i * 2 + 1];
            if (TournamentUtil.Instance.QuarterGoals [i * 2] > TournamentUtil.Instance.QuarterGoals [i * 2 + 1])
            {
                QuartiBg [i * 2].sprite2D = bgRosso;
            }
            else
            {
                QuartiBg [i * 2 + 1].sprite2D = bgRosso;
            }
        }

        for (int i = 0; i < TournamentUtil.Instance.FinalsIds.Length; i++)
        {
            byte id;
            if (i == 0)
            {
                id = (byte)NationalSuits.getNationId(Game.Instance.Nation01);
            }
            else
            {
                id = TournamentUtil.Instance.FinalsIds [i];
            }
            FInaleFlags [i].sprite2D         = NationalSuits.getNationFlag(NationalSuits.getNationById(id));
            SemifinaleGoals [i * 2].text     = "" + TournamentUtil.Instance.SemiFinalsGoals [i * 2];
            SemifinaleGoals [i * 2 + 1].text = "" + TournamentUtil.Instance.SemiFinalsGoals [i * 2 + 1];
            if (TournamentUtil.Instance.SemiFinalsGoals [i * 2] > TournamentUtil.Instance.SemiFinalsGoals [i * 2 + 1])
            {
                SemifinaleBg [i * 2].sprite2D = bgRosso;
            }
            else
            {
                SemifinaleBg [i * 2 + 1].sprite2D = bgRosso;
            }
        }

        Partita partita = CosaGoal(0, TournamentUtil.Instance.FinalsIds, TournamentUtil.Instance.FinalsIds);

        FInaleGoals [0].text = "" + partita.Goal01;
        FInaleGoals [1].text = "" + partita.Goal02;
        if (partita.Goal01 > partita.Goal02)
        {
            FInaleBg [0].sprite2D = bgRosso;
        }
        else
        {
            FInaleBg [1].sprite2D = bgRosso;
        }
    }