Esempio n. 1
0
        public void Log(MatchSummary summary)
        {
            var message = String.Format("Match result: Player {0} wins{1}Win reason: {2}", summary.Winner, Environment.NewLine, summary.WinReason);

            Debug.WriteLine(message);
            Console.WriteLine(message);
        }
Esempio n. 2
0
        public void TestMatchPoller()                                       // still not working
        {
            MatchHistory history = new MatchHistory();

            history.Matches[5].Id = 66;

            mockWebAPI.Setup(webAPI => webAPI.GetMatchHistory())
            .Returns(history);

            var poller = new MatchPoller(mockWebAPI.Object, 100);

            MatchSummary match   = null;
            var          matches = poller.PollMatches().GetEnumerator();
            int          count   = 0;

            for (int i = 0; i < 6; i++)
            {
                matches.MoveNext();
                match = matches.Current;
                count++;
            }

            Assert.AreEqual(66, match.Id);
            Assert.AreEqual(6, count);
        }
    IEnumerator CheckAndDisplay(MatchSummary ms)
    {
        GameObject gO = GameObject.Find("Bullet (Clone)");

        while (gO != null)
        {
            gO = GameObject.Find("Bullet_Hammer(Clone)");
            yield return(new WaitForSeconds(0.3f));
        }
        // Debug.Log("DisplaySummary Called!");
        this.gameObject.SetActive(true);
        Debug.Log(ms.ToString());
        if (ms.isWin)
        {
            winPanel.SetActive(true);
            losePanel.SetActive(false);
            SoundManager.GetInstance().PlayEffect("choose");
            SoundManager.GetInstance().PlayEffect("happy");
        }
        else
        {
            winPanel.SetActive(false);
            losePanel.SetActive(true);
            SoundManager.GetInstance().PlayEffect("sad");
        }
        // Debug.Log("DisplaySummary Done!");
    }
Esempio n. 4
0
        protected static void RenderWinDetails(MatchSummary result, Match match)
        {
            if (match.GetResult() == MatchResult.Tie)
            {
                result.Winner    = 1;
                result.WinReason = "Match was a tie, so player 1 wins by default.";
                return;
            }

            var winner   = match.GetResult() == MatchResult.PlayerOneWins ? match.GetPlayer(1) : match.GetPlayer(2);
            var opponent = match.GetResult() == MatchResult.PlayerOneWins ? match.GetPlayer(2) : match.GetPlayer(1);

            result.Winner = winner.PlayerNumber;

            if (((opponent.Lives <= 0) && (opponent.Ship == null)) &&
                ((winner.Lives > 0) || (winner.Ship != null)))
            {
                result.WinReason = String.Format("Player {0} ran out of lives.", opponent.PlayerNumber);
            }
            else
            {
                result.WinReason = String.Format("Player {0} had more kills than player {1}.", winner.PlayerNumber,
                                                 opponent.PlayerNumber);
            }
        }
Esempio n. 5
0
 private void LogAll(MatchSummary summary)
 {
     foreach (ILogger logger in _loggers)
     {
         logger.Log(summary);
     }
 }
Esempio n. 6
0
    void updateTournamentResults(MatchSummary summary)
    {
        MatchResultData result = new MatchResultData();

        result.Team1.Alias = summary.Team1.Alias;
        result.Team1.Score = summary.Team1.Score;
        result.Team2.Alias = summary.Team2.Alias;
        result.Team2.Score = summary.Team2.Score;

        OnlineTournamentHandler.AddMatchResult(result);
    }
Esempio n. 7
0
 public void GameOver(MatchSummary ms)
 {
     Debug.Log("[GAMECONTROLLER] GAME OVER");
     // foreach(PlayerController p in playerControllers){
     //  Destroy(p.gameObject);
     // }
     uiController.SetFightingUI(false);
     ((FightUIController)uiController).summaryPanelController.DisplaySummary(ms);
     // SwitchScene("Scene_Game","Scene_Front");
     StartCoroutine(TimedEndGame(17f));
 }
Esempio n. 8
0
    void onPostmatchFullStats(MatchSummary summary)
    {
        GameData.CurrentMatchSummary = summary;

        if (GameData.CurrentMode == ModeData.Mode.TOURNAMENT)
        {
            updateTournamentResults(summary);
        }

        disableEvents();
        GetTree().ChangeScene("Scenes/PostmatchScene.tscn");
    }
Esempio n. 9
0
        public MatchSummary RenderSummary(IMatch renderMatch)
        {
            var match = (Match)renderMatch;

            var result = new MatchSummary
            {
                Rounds = match.GetRoundNumber()
            };

            result.Players.Add(RenderPlayer(match, 1));
            result.Players.Add(RenderPlayer(match, 2));

            RenderWinDetails(result, match);

            return(result);
        }
Esempio n. 10
0
        private IEventMatchSummary GenMatchEventSummary(int lsevent_id, int series_id)
        {
            EventMatchSummary mtcsum = new EventMatchSummary();
            MatchSummarySeries series = new MatchSummarySeries();
            MatchSummary match = new MatchSummary();
            match.Add(new MatchSummaryItem() { Team = "Test Team a", TeamScore = 999, Rank = 1, RankPoints = 10, Color = "Green" });
            match.Add(new MatchSummaryItem() { Team = "Test Team b", TeamScore = 888, Rank = 2, RankPoints = 1, Color = "Red" });
            series.Add(DateTime.Now, match);

            match.Add(new MatchSummaryItem() { Team = "Test Team b", TeamScore = 1001, Rank = 1, RankPoints = 10, Color = "Green" });
            match.Add(new MatchSummaryItem() { Team = "Test Team a", TeamScore = 1000, Rank = 2, RankPoints = 1, Color = "Red" });
            series.Add(DateTime.Now.AddHours(1), match);

            mtcsum.Add("event", series);
            return mtcsum;
        }
Esempio n. 11
0
    public static MatchSummary  GameOver_MatchSummary(ref GSPacketIn pkg, int mainPID)
    {
        MatchSummary ms     = new MatchSummary();
        int          pCount = pkg.ReadInt();

        for (int i = 0; i < pCount; i++)
        {
            ms.Id = pkg.ReadInt();
            // if (ms.Id != mainPID){
            //     pkg.ReadBoolean();
            //     for (int j = 0; j < 23; j ++){
            //         pkg.ReadInt();
            //     }
            //     continue;
            // }
            ms.isWin           = pkg.ReadBoolean();
            ms.Grade           = pkg.ReadInt();
            ms.GP              = pkg.ReadInt();
            ms.TotalKill       = pkg.ReadInt();
            ms.TotalHurt       = pkg.ReadInt();
            ms.TotalShootCount = pkg.ReadInt();
            ms.TotalCure       = pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            ms.GainGP = pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            pkg.ReadInt();
            ms.GainOffer  = pkg.ReadInt();
            ms.CanTakeOut = pkg.ReadInt();
            if (ms.Id == mainPID)
            {
                return(ms);
            }
        }
        ms.riches = pkg.ReadInt();
        return(ms);
    }
Esempio n. 12
0
        public void Log(MatchSummary summary)
        {
            var result = JsonConvert.SerializeObject(
                summary,
                Formatting.Indented,
                new JsonSerializerSettings
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            }
                );

            using (
                var writer =
                    new StreamWriter(ReplayDirectory + Path.DirectorySeparatorChar +
                                     Settings.Default.MatchResultFilename))
            {
                writer.WriteLine(result);
            }
        }
 public void Log(MatchSummary result)
 {
     Log(String.Format("Match result: Player {0} wins", result.Winner));
     Log(String.Format("Win reason: {0}", result.WinReason));
 }
Esempio n. 14
0
 public void GameOverHandler(MatchSummary ms)
 {
     gameController.GameOver(ms);
 }
Esempio n. 15
0
 public void DisplaySummary(MatchSummary ms)
 {
     this.gameObject.SetActive(true);
     StartCoroutine(CheckAndDisplay(ms));
 }
Esempio n. 16
0
    public override void OnRecvPacket(GSPacketIn pkg)
    {
        this.m_lastRecv = pkg.Code;
        this.m_recvCount++;
        // Debug.Log("player ["+this.m_account+"]:"+DateTime.Now+" receive: "+pkg.Code+" (ePackageType."+(ePackageType)pkg.Code+")");

        /*if (this.m_log != null)
         * {
         *  this.m_log.WriteLine(Marshal.ToHexDump(string.Format("player [{0}]:{1} recive:", this.m_account, DateTime.Now), pkg.Buffer, 0, pkg.Length));
         * }*/
        Debug.Log("OnRecvPacket: " + (ePackageType)pkg.Code);
        switch (pkg.Code)
        {
        case (byte)ePlayerPackageType.LOGIN: {
            //LOGIN
            if (pkg.ReadByte() != 0)
            {
                string str = pkg.ReadString();
                Debug.Log(this.m_account + " login socket failed: " + str);
                this.m_state   = ePlayerState.Stopped;
                this.LastError = "SocketError:" + str;
                break;
            }
            this.UserId = pkg.ClientID;
            pkg.ReadInt();     //4
            this.m_playerId          = pkg.Parameter1;
            localPlayerInfo          = new PlayerInfo();
            localPlayerInfo.id       = this.m_playerId;
            localPlayerInfo.nickname = this.NickName;
            ClientRecvPreparer.PlayerInfo_LOGIN(ref localPlayerInfo, ref pkg);

            Debug.Log("login socket success! pid " + this.m_playerId + " uid: " + this.UserId);
            // Debug.Log("login info: "+ localPlayerInfo.ToString());
            // Debug.Log("localPlayerInfo style: " + localPlayerInfo.style);
            UnityThread.executeInUpdate(() =>
                {
                    //Call UpdateLocalPlayerPreview in ConnectorManager
                    connectorManager.UpdateLocalPlayerPreview();
                });
            break;
        }

        case 2: {
            //KIT_USER
            Debug.Log("CMDType 2 KIT_USER");
            this.m_state   = ePlayerState.Stopped;
            this.LastError = "KickReason:" + pkg.ReadString();
            Debug.Log(this.LastError);
            break;
        }

        case 3: {
            //SYS_MESS
            Debug.Log("CMDType 3 - SYS MESS");
            int val = pkg.ReadInt();
            Debug.Log("CMDType 3 val: " + val.ToString());
            this.LastMsg = pkg.ReadString();
            Debug.Log(this.LastMsg);
            break;
        }

        case (byte)ePlayerPackageType.GRID_GOODS: {
            // MainBag = 0, PropBag = 1, TaskBag = 2,
            //TempBag = 4, CaddyBag = 5, Bank    = 11, Store   =12, Card=15
            int             bagType    = pkg.ReadInt();
            int             slotLength = pkg.ReadInt();
            List <ItemInfo> bagBag     = new List <ItemInfo>();
            Debug.Log("bagtype: " + bagType + " - " + (eBagType)bagType + " slotLEngth: " + slotLength);
            for (int ind = 0; ind < slotLength; ind++)
            {
                pkg.ReadInt();
                bagBag.Add(new ItemInfo(ref pkg, true));
                // Debug.Log(bagBag[ind].ToString());
            }
            UnityThread.executeInUpdate(() =>
                {
                    //Call StartGameHandler in ConnectorManager
                    connectorManager.GridGoodsHandler(bagType, bagBag);
                });
            break;
        }

        case (byte)ePackageType.GAME_ROOM_CREATE: {
            RoomInfo ri = new RoomInfo();
            ri.id          = pkg.ReadInt();
            ri.roomType    = (eRoomType)pkg.ReadByte();
            ri.hardLevel   = (eHardLevel)pkg.ReadByte();
            ri.timeMode    = pkg.ReadByte();
            ri.playerCount = pkg.ReadByte();
            ri.placescount = pkg.ReadByte();
            ri.isPasswd    = pkg.ReadBoolean();
            ri.mapid       = pkg.ReadInt();
            ri.isplaying   = pkg.ReadBoolean();
            ri.roomname    = pkg.ReadString();
            ri.gametype    = (eGameType)pkg.ReadByte();
            ri.levelLimits = pkg.ReadInt();
            pkg.ReadBoolean();    //pkg.WriteBoolean(false);
            Debug.Log(ri.ToString());
            this.m_state  = ePlayerState.Room;
            this.m_isHost = true;
            this.m_roomCount++;
            this.Act(new PlayerExecutable(this.StartGame));
            break;
        }

        case (byte)ePlayerPackageType.ITEM_EQUIP: {
            {
                pkg.ReadInt();     //id
                pkg.ReadInt();     //agi
                pkg.ReadInt();     //Attack
                pkg.ReadString();  //Colors
                pkg.ReadString();  //Skin
                pkg.ReadInt();     //Defence
                pkg.ReadInt();     // GP
                pkg.ReadInt();     //Grade
                pkg.ReadInt();     //Luck
                pkg.ReadInt();     //Hide
                pkg.ReadInt();     //Repute
                pkg.ReadBoolean(); // Sex
                pkg.ReadString();  // Style
                pkg.ReadInt();     //Offer
                pkg.ReadString();  //NickName
                pkg.ReadBoolean(); pkg.ReadInt();
                pkg.ReadInt();     //Win
                pkg.ReadInt();     //Total
                pkg.ReadInt();     //Escape
                pkg.ReadInt(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadInt(); pkg.ReadBoolean();
                pkg.ReadInt(); pkg.ReadString(); pkg.ReadString(); pkg.ReadInt();
                pkg.ReadInt(); //FightPower
                pkg.ReadInt(); pkg.ReadInt(); pkg.ReadString(); pkg.ReadInt(); pkg.ReadString();
                //AchievementPoint
                pkg.ReadInt(); pkg.ReadString(); pkg.ReadDateTime();
            }
            int             iCount = pkg.ReadInt(); //itemCount
            List <ItemInfo> items  = new List <ItemInfo>();
            for (int ind = 0; ind < iCount; ind++)
            {
                items.Add(new ItemInfo(ref pkg, false));
                Debug.Log(items[ind].ToString());
            }
            break;
        }

        case (byte)ePlayerPackageType.UPDATE_PRIVATE_INFO: {
            localPlayerInfo.money     = pkg.ReadInt();
            localPlayerInfo.medal     = pkg.ReadInt();
            localPlayerInfo.gold      = pkg.ReadInt();
            localPlayerInfo.giftToken = pkg.ReadInt();
            break;
        }

        case (byte)ePlayerPackageType.UPDATE_PlAYER_INFO: {
            localPlayerInfo.nickname = this.m_account;
            localPlayerInfo.id       = this.m_playerId;
            localPlayerInfo.grade    = this.m_grade;
            localPlayerInfo.gp       = pkg.ReadInt();   //info.GP);
            pkg.ReadInt();                              //info.Offer);
            pkg.ReadInt();                              //info.RichesOffer);
            pkg.ReadInt();                              //info.RichesRob);
            localPlayerInfo.win        = pkg.ReadInt(); //info.Win);
            localPlayerInfo.totalMatch = pkg.ReadInt(); //info.Total);
            pkg.ReadInt();                              //info.Escape);

            localPlayerInfo.attack  = pkg.ReadInt();    //info.Attack);
            localPlayerInfo.defence = pkg.ReadInt();    //info.Defence);
            localPlayerInfo.agility = pkg.ReadInt();    //info.Agility);
            localPlayerInfo.luck    = pkg.ReadInt();    //info.Luck);
            pkg.ReadInt();                              //info.Hide);
            localPlayerInfo.style = pkg.ReadString();   //info.Style);
            localPlayerInfo.color = pkg.ReadString();   //info.Colors);
            localPlayerInfo.skin  = pkg.ReadString();   //info.Skin);

            pkg.ReadInt();                              //info.ConsortiaID);
            pkg.ReadString();                           //info.ConsortiaName);
            pkg.ReadInt();                              //info.ConsortiaLevel);
            pkg.ReadInt();                              //info.ConsortiaRepute);

            pkg.ReadInt();                              //info.Nimbus);
            pkg.ReadString();                           //info.PvePermission);
            pkg.ReadString();                           //"1");
            localPlayerInfo.fightPower = pkg.ReadInt(); //info.FightPower);
            // pkg.ReadInt();//1);
            // pkg.ReadInt();//-1);
            // pkg.ReadString();//"ss");
            // pkg.ReadInt();//1);
            // pkg.ReadString();//"ss");
            // ////AchievementPoint
            // pkg.ReadInt();//0);
            // ////honor
            // pkg.ReadString();//"honor");
            // // //LastSpaDate
            // // if ();//info.ExpendDate != null)
            // //     pkg.ReadDateTime();//();//DateTime)info.ExpendDate);
            // // else { pkg.ReadDateTime();//DateTime.MinValue); }
            // //charmgp
            // pkg.ReadInt();//100);
            // //consortiaCharmGP
            // pkg.ReadInt();//100);

            // pkg.ReadDateTime();//DateTime.MinValue);
            // ////DeputyWeaponID
            // pkg.ReadInt();//10001);
            // pkg.ReadInt();//0);
            // // box gi ko biet
            // pkg.ReadInt();//info.AnswerSite);
            // // pkg.ReadInt();//0);
            Debug.Log(localPlayerInfo.ToString());
            UnityThread.executeInUpdate(() =>
                {
                    //Call Update mainplayer info in ConnectorManager
                    connectorManager.UpdateLocalPlayerPreview();
                    connectorManager.UpdateStatsDisplay();
                });
            break;
        }

        case (byte)ePlayerPackageType.GAME_CMD: {
            //GAME_CMD
            //Debug.Log("GAME_CMD");
            eTankCmdType type     = (eTankCmdType)pkg.ReadByte();
            int          pId      = pkg.Parameter1;
            int          LifeTime = pkg.Parameter2;
            Debug.Log("[CMD] " + ((eTankCmdType)type).ToString() + " - lifeTime: " + LifeTime.ToString());
            switch (type)
            {
            case eTankCmdType.TAKE_CARD:
            // Debug.Log("TAKE_CARD ");
            // return;
            case eTankCmdType.GAME_OVER:
                // this.Act(new PlayerExecutable(this.EnterWaitingRoom));
                // this.Act(new PlayerExecutable(this.CreateRoom));
                // this.Act(new PlayerExecutable(this.StartGame));
                MatchSummary ms = ClientRecvPreparer.GameOver_MatchSummary(ref pkg, this.m_playerId);
                UnityThread.executeInUpdate(() =>
                    {
                        //Call StartGameHandler in ConnectorManager
                        connectorManager.GameOverHandler(ms);
                    });
                return;

            case eTankCmdType.GAME_TIME:
                this.m_lifeTime = pkg.ReadInt();
                Debug.Log("GAME_TIME sync: " + this.m_lifeTime.ToString());
                return;

            case eTankCmdType.START_GAME:
                // Game.Logic/PVPGame.cs
                int size = pkg.ReadInt();         //number of players
                // List<PlayerInfo> Players = new List<PlayerInfo>();
                for (int i = 0; i < size; i++)
                {
                    int tmpId = pkg.ReadInt();
                    for (int j = 0; j < size; j++)
                    {
                        if (tmpId != playersList[j].id)
                        {
                            continue;
                        }
                        playersList[j].x         = pkg.ReadInt();
                        playersList[j].y         = pkg.ReadInt();
                        playersList[j].direction = pkg.ReadInt();
                        playersList[j].blood     = pkg.ReadInt();
                        pkg.ReadInt();             //2
                        pkg.ReadInt();             //34
                        playersList[j].isMainPlayer = false;
                        //check if player is this user
                        //Debug.Log("thisPid: "+ this.m_playerId.ToString() + " - Pid: " + Players[i].id.ToString());
                        // if (playersList[j].id == this.m_playerId){
                        if (playersList[j].nickname == this.m_account ||
                            playersList[j].nickname == this.NickName)
                        {
                            playersList[j].isMainPlayer = true;
                            this.m_playerId             = playersList[j].id;
                            this.m_posX = playersList[j].x;
                            this.m_posY = playersList[j].y;
                        }
                        playersList[j].dander      = pkg.ReadInt();
                        playersList[j].effectCount = pkg.ReadInt();
                        playersList[j].property3   = new List <int>();
                        playersList[j].property4   = new List <int>();
                        for (int k = 0; k < playersList[j].effectCount; k++)
                        {
                            playersList[j].property3.Add(pkg.ReadInt());
                            playersList[j].property4.Add(pkg.ReadInt());
                        }
                        break;
                    }
                }
                UnityThread.executeInUpdate(() =>
                    {
                        //Call StartGameHandler in ConnectorManager
                        connectorManager.StartGameHandler(playersList);
                    });
                this.m_state = ePlayerState.StartGame;
                return;

            case eTankCmdType.GAME_CREATE:
                this.m_gameCount++;
                pkg.ReadInt();         //Roomtype
                pkg.ReadInt();         //gametype
                pkg.ReadInt();         //Timetype
                localPlayerInfo.nickname = this.m_account;
                this.playersList         = ClientRecvPreparer.GameCreate_PlayerList(ref localPlayerInfo, ref pkg);
                this.m_playerId          = localPlayerInfo.id;
                this.m_state             = ePlayerState.CreateGame;
                UnityThread.executeInUpdate(() =>
                    {
                        //Call GameCreateHandler in ConnectorManager
                        connectorManager.GameCreateHandler(this.playersList);
                    });
                return;

            case eTankCmdType.GAME_LOAD:

                pkg.ReadInt();         //maxTime
                int mapId = pkg.ReadInt();
                UnityThread.executeInUpdate(() =>
                    {
                        //Call LoadMapHandler in ConnectorManager
                        connectorManager.GameLoadHandler(mapId);
                    });
                return;

            case eTankCmdType.LOAD:

                this.m_state = ePlayerState.Loading;
                // this.Act(new PlayerExecutable(this.SendLoadingComplete));
                return;

            case eTankCmdType.GAME_MISSION_INFO:
                MissionInfo mi = ClientRecvPreparer.GetPVEMissionInfo(ref pkg);
                UnityThread.executeInUpdate(() =>
                    {
                        connectorManager.PVEMissionPrepare(mi);
                    });
                return;

            case eTankCmdType.GAME_UI_DATA:
                // update turn index and kill count;
                int TurnIndex = pkg.ReadInt();
                int count = pkg.ReadInt();
                int param3 = pkg.ReadInt(), param4 = pkg.ReadInt();
                UnityThread.executeInUpdate(() =>
                    {
                        Debug.Log(string.Format("GAME_UI_DATA : TurnIndex:{0} - count:{1} - param3,4:{2},{3}",
                                                TurnIndex, count, param3, param4));
                    });
                return;

            case eTankCmdType.ADD_LIVING:
                // update turn index and kill count;
                LivingInfo li = ClientRecvPreparer.AddLivingInfo(ref pkg);
                UnityThread.executeInUpdate(() =>
                    {
                        Debug.Log("ADD_LIVING : " + li.ToString());
                    });
                return;

            case eTankCmdType.TURN:
                Debug.Log("pId turn: " + pkg.Parameter1.ToString());
                int wind = pkg.ReadInt();
                pkg.ReadBoolean();
                pkg.ReadByte();
                pkg.ReadByte();
                pkg.ReadByte();
                bool isHiding = pkg.ReadBoolean();

                //turnTime
                // TimeType
                int            timeType      = pkg.ReadInt();
                List <BoxInfo> newBoxesList  = new List <BoxInfo>();
                int            newBoxesCount = pkg.ReadInt();
                for (int j = 0; j < newBoxesCount; j++)
                {
                    newBoxesList.Add(new BoxInfo());
                    newBoxesList[j].id = pkg.ReadInt();
                    newBoxesList[j].x  = pkg.ReadInt();
                    newBoxesList[j].y  = pkg.ReadInt();
                    pkg.ReadInt();
                    // pkg.ReadBoolean();
                }
                List <PlayerInfo> updatedPlayerList = new List <PlayerInfo>();
                int listSize = pkg.ReadInt();
                for (int j = 0; j < listSize; j++)
                {
                    updatedPlayerList.Add(new PlayerInfo());
                    updatedPlayerList[j].id         = pkg.ReadInt();
                    updatedPlayerList[j].isLiving   = pkg.ReadBoolean();
                    updatedPlayerList[j].x          = pkg.ReadInt();
                    updatedPlayerList[j].y          = pkg.ReadInt();
                    updatedPlayerList[j].blood      = pkg.ReadInt();
                    updatedPlayerList[j].isNoHole   = pkg.ReadBoolean();
                    updatedPlayerList[j].energy     = pkg.ReadInt();
                    updatedPlayerList[j].dander     = pkg.ReadInt();
                    updatedPlayerList[j].shootCount = pkg.ReadInt();
                }
                int turnIndex = pkg.ReadInt();

                UnityThread.executeInUpdate(() =>
                    {
                        //Call TurnHandler in ConnectorManager
                        connectorManager.TurnHandler(pkg.Parameter1, newBoxesList, updatedPlayerList);
                    });
                // this.m_state = ePlayerState.Shoot;
                // this.m_shootCount++;
                //this.Act(new PlayerExecutable(this.Shoot));
                return;

            case eTankCmdType.CURRENTBALL:
                bool special       = pkg.ReadBoolean();
                int  currentBallId = pkg.ReadInt();
                UnityThread.executeInUpdate(() =>
                    {
                        //Call CurrentBallHandler in ConnectorManager
                        connectorManager.CurrentBallHandler(pId, special, currentBallId);
                    });
                //pkg.WriteByte((byte)player.BallCount);
                return;

            case eTankCmdType.FIRE:
                List <FireInfo> fireInfos = ClientRecvPreparer.MakeFireInfo(ref pkg);
                UnityThread.executeInUpdate(() =>
                    {
                        //Call FireHandler in ConnectorManager
                        connectorManager.FireHandler(pId, fireInfos);
                    });
                return;

            case eTankCmdType.FIRE_TAG:
                bool tag       = pkg.ReadBoolean();
                byte speedTime = pkg.ReadByte();
                UnityThread.executeInUpdate(() =>
                    {
                        //Call FireTagHandler in ConnectorManager
                        connectorManager.FireTagHandler(pId, tag, speedTime);
                    });
                return;

            case eTankCmdType.USING_PROP:
                byte propType   = pkg.ReadByte();
                int  place      = pkg.ReadInt();
                int  templateId = pkg.ReadInt();
                UnityThread.executeInUpdate(() =>
                    {
                        //Call UsingPropHandler in ConnectorManager
                        connectorManager.UsingPropHandler(pId, propType, place, templateId);
                    });
                return;

            case eTankCmdType.MOVESTART:
                byte   moveType = pkg.ReadByte();
                int    tx       = pkg.ReadInt();
                int    ty       = pkg.ReadInt();
                byte   dir      = pkg.ReadByte();
                bool   isLiving = pkg.ReadBoolean();
                string action   = pkg.ReadString();       // is null or empty or "move"
                // Debug.Log("MOVE type: "+moveType.ToString()+" tX: " + tx.ToString()+
                //         " tY:"+ ty.ToString()+ " dir: "+dir.ToString());
                UnityThread.executeInUpdate(() =>
                    {
                        //Call MoveStartHandler in ConnectorManager
                        connectorManager.MoveStartHandler(pId, moveType, tx, ty, dir, isLiving);
                    });

                return;

            case eTankCmdType.DIRECTION:
                int direction = pkg.ReadInt();
                UnityThread.executeInUpdate(() =>
                    {
                        //Call CurrentBallHandler in ConnectorManager
                        connectorManager.DirectionHandler(pId, direction);
                    });
                return;

            case eTankCmdType.DANDER:
                int playerId = pkg.Parameter1;
                int dander   = pkg.ReadInt();
                localPlayerInfo.dander = dander;
                UnityThread.executeInUpdate(() =>
                    {
                        //Call CurrentBallHandler in ConnectorManager
                        connectorManager.DanderHandler(pId, dander);
                    });
                return;

            default:
                Debug.Log("Unhandled GAME_CMD type: " + type.ToString());
                return;
            }
            break;
        }

        // case 0x5e:{
        // //GAME_CREATE_ROOM
        //     Debug.Log("GET GAME_CREATE_ROOM PACKAGE");
        //     if (pkg.ReadInt() != 0)//if (m_isHost == false)
        //     {
        //         this.m_state = ePlayerState.Room;
        //         this.m_isHost = true;
        //         this.m_roomCount++;
        //         this.Act(new PlayerExecutable(this.StartGame));
        //     }
        //         break;
        // }
        case 5:
        {
            //SYS_DATE
            Debug.Log("GET SYS_DATE PACKAGE");
            // this.Act(new PlayerExecutable(this.EnterWaitingRoom));
            // System.Threading.Thread.Sleep(100);
            // this.Act(new PlayerExecutable(this.CreateRoom));
            // //Debug.Log(this.m_State == ePlayerState.Room);
            // //Debug.Log(this.m_isHost);
            // //Debug.Log(this.m_roomCount);
            // System.Threading.Thread.Sleep(100);
            // this.Act(new PlayerExecutable(this.StartGame));
            break;
        }

        case (int)ePackageType.GAME_PAIRUP_START:
            UnityThread.executeInUpdate(() =>
            {
                connectorManager.ConfirmMatching();
            });
            break;

        default:
            Debug.Log("Unhandled Package type: " + ((ePackageType)pkg.Code).ToString());
            break;
        }
    }
Esempio n. 17
0
        /// <summary>
        /// Check if a match file exists.
        /// </summary>
        public static bool MatchFileExists(MatchSummary match)
        {
            string filename = GetMatchPath(match);

            return(File.Exists(filename));
        }
Esempio n. 18
0
 public void Log(MatchSummary summary)
 {
 }
Esempio n. 19
0
 public static MatchDetail GetMatchDetailEventually(MatchSummary summary)
 {
     return(GetMatchDetailEventually(summary.MatchId));
 }
        public IApiResponseParsingResult ParseResponse(ParseApiResponse message)
        {
            var responseType = ApiResponseType.Unknown;

            try
            {
                object response;

                var responseXml = DynamicXml.Parse(message.Data);
                responseType = responseXml.GetName();

                switch (responseType)
                {
                case ApiResponseType.CompetitorProfile:
                    response = CompetitorProfile.Parse(responseXml);
                    break;

                case ApiResponseType.FixtureChanges:
                    response = FixtureChangeList.Parse(responseXml);
                    break;

                case ApiResponseType.FixturesFixture:
                    response = FixtureList.Parse(responseXml);
                    break;

                case ApiResponseType.MatchSummary:
                    response = MatchSummary.Parse(responseXml);
                    break;

                case ApiResponseType.MarketDescriptions:
                    response = MarketDescriptionList.Parse(responseXml);
                    break;

                case ApiResponseType.MatchTimeline:
                    response = MatchTimeline.Parse(responseXml);
                    break;

                case ApiResponseType.PlayerProfile:
                    response = PlayerProfile.Parse(responseXml);
                    break;

                case ApiResponseType.RaceTournamentInfo:
                case ApiResponseType.SimpleTournamentInfo:
                case ApiResponseType.StandardTournamentInfo:
                case ApiResponseType.TournamentInfo:
                    response = TournamentInfo.Parse(responseXml);
                    break;

                case ApiResponseType.Response:
                    response = Response.Parse(responseXml);
                    break;

                case ApiResponseType.Schedule:
                    response = Schedule.Parse(responseXml);
                    break;

                case ApiResponseType.SportCategories:
                    response = SportCategoriesList.Parse(responseXml);
                    break;

                case ApiResponseType.Sports:
                    response = SportList.Parse(responseXml);
                    break;

                case ApiResponseType.SportTournaments:
                    response = SportTournamentList.Parse(responseXml);
                    break;

                case ApiResponseType.Tournaments:
                    response = TournamentList.Parse(responseXml);
                    break;

                case ApiResponseType.VenueSummary:
                    response = VenueSummary.Parse(responseXml);
                    break;

                default:
                    throw new NotSupportedException(
                              $"Message of specified type ['{responseType}'] can not be parsed.");
                }

                return(new ApiResponseParsed
                {
                    Language = message.Language,
                    Response = response,
                    RequestId = message.RequestId,
                    EventId = message.EventId,
                    ProductType = message.ProductType
                });
            }
            catch (Exception e)
            {
                throw;
                //return new ApiResponseParsingFailed(
                //    failureReason: e,
                //    requestId: message.RequestId,
                //    responseData: message.Data,
                //    responseType: responseType
                //);
            }
        }
Esempio n. 21
0
 private void LogAll(MatchSummary summary)
 {
     _logger.Log(summary);
     _replayLogger.Log(summary);
     _consoleLogger.Log(summary);
 }
Esempio n. 22
0
        /// <summary>
        /// Load a match.
        /// </summary>
        public static MatchDetail LoadMatch(MatchSummary match)
        {
            string filename = GetMatchPath(match);

            return(CompressedJson.ReadFromFile <MatchDetail>(filename));
        }
Esempio n. 23
0
        /// <summary>
        /// Process a match.
        /// </summary>
        private async Task <MatchDetail> ConsumeMatch(MatchSummary match)
        {
            long matchId = match.MatchId;

            // Try to mark the match as being processed
            if (!TryLockMatch(matchId))
            {
                // Another thread has already started processing this match, we don't need to do anything
                return(null);
            }

            // Get the disk path and version of the match
            string      matchPath    = MatchDirectory.GetMatchPath(match);
            RiotVersion matchVersion = new RiotVersion(match.MatchVersion);

            // Check if the match version is older than the current realm version
            if (!StaticDataStore.Version.IsSamePatch(matchVersion))
            {
                TryUnlockMatch(matchId);
                return(null);
            }

            // Check if the match exists on disk
            if (MatchDirectory.MatchFileExists(match))
            {
                // Match file loading will handle this
                TryUnlockMatch(matchId);
                return(null);
            }

            // <TEST> download limiting
            long count = Interlocked.Read(ref testSynchronizer.Count);

            Interlocked.Increment(ref testSynchronizer.Count);
            if (count >= testSynchronizer.Limit)
            {
                return(null);
            }
            // </TEST>

            MatchDetail matchData = null;

            int retriesLeft = 3;

            while (retriesLeft > 0)
            {
                try
                {
                    // Get the match with full timeline data
                    matchData = api.GetMatch(match.Region, matchId, true);

                    // Verify the match
                    if (matchData == null)
                    {
                        throw new RiotSharpException("Null match: " + matchId);
                    }

                    if (matchData.Timeline == null)
                    {
                        throw new RiotSharpException("Null match timeline: " + matchId);
                    }

                    // Save it to disk
                    MatchDirectory.SaveMatch(matchData);

                    // Success, don't retry anymore
                    retriesLeft = 0;

                    Console.WriteLine(count);
                }
                catch (RiotSharpException ex)
                {
                    if (ex.IsRetryable())
                    {
                        --retriesLeft;
                    }
                    else
                    {
                        retriesLeft = 0;
                    }

                    // Don't do anything with the exception yet
                    // TODO: log exceptions

                    Console.ForegroundColor = retriesLeft > 0 ? ConsoleColor.Yellow : ConsoleColor.Red;
                    Console.WriteLine("{0}: Match Error ({1} retries left): {2}", count, retriesLeft, ex.Message);
                    Console.ResetColor();
                }
            }

            // Remove the match from current downloads
            TryUnlockMatch(matchId);

            return(matchData);
        }
Esempio n. 24
0
 /// <summary>
 /// Get the path to a match file.
 /// </summary>
 public static string GetMatchPath(MatchSummary match)
 {
     return(GetMatchPath(match.MatchVersion, match.MatchId));
 }