Esempio n. 1
0
        public void processMatchAction(NetworkResponse response)
        {
            ResponseMatchAction args = response as ResponseMatchAction;
            short actionID           = args.actionID;

            if (actionID != 0)
            {
                TurnAction action = args.action;
                action.execute();
            }
            Debug.Log("Match Action code:= " + args.actionID);
        }
        public static NetworkResponse Parse(MemoryStream dataStream)
        {
            ResponseMatchAction response = new ResponseMatchAction();
            response.actionID =  DataReader.ReadShort(dataStream);
            response.intCount = DataReader.ReadInt (dataStream);
            response.stringCount = DataReader.ReadInt (dataStream);
            Debug.Log("Action Protocol: length of ints " + response.intCount + " stringCount :" + response.stringCount);
            for (int i = 0; i < response.intCount; i++){
            response.intList.Add(DataReader.ReadInt(dataStream));
            }
            for (int i = 0; i < response.stringCount; i++){
            response.stringList.Add(DataReader.ReadString(dataStream));
            Debug.Log("Action Protocol : read string " + response.stringList[i] + " actionID: " + response.actionID);
            }

            // This could be done in a better way
            // Status no match indicates failure to successfully enter a valid match
             if (response.actionID == Constants.STATUS_NO_MATCH){
            response.action = new InvalidMatchAction(response.intCount, response.stringCount,
                                                    response.intList, response.stringList);
            }
            else if (response.actionID == NetworkCode.DEAL_CARD){
            response.action = new DealCardAction(response.intCount, response.stringCount,
                                                 response.intList, response.stringList);
            }else if(response.actionID == NetworkCode.SUMMON_CARD){
            response.action = new SummonCardAction(response.intCount, response.stringCount,
                                                 response.intList, response.stringList);
            }else if(response.actionID == NetworkCode.END_TURN){
            response.action = new EndTurnAction(response.intCount, response.stringCount,
                                                response.intList, response.stringList);
            }else if (response.actionID == NetworkCode.CARD_ATTACK){
            response.action = new CardAttackAction(response.intCount, response.stringCount,
                                                response.intList, response.stringList);
            }else if (response.actionID == NetworkCode.TREE_ATTACK){
            response.action = new TreeAttackAction(response.intCount, response.stringCount,
                                                   response.intList, response.stringList);
            }else if (response.actionID == NetworkCode.QUIT_MATCH){
            response.action = new QuitMatchAction(response.intCount, response.stringCount,
                                                   response.intList, response.stringList);
            }else if (response.actionID == NetworkCode.MATCH_OVER){
            response.action = new MatchOverAction(response.intCount, response.stringCount,
                                               response.intList, response.stringList);
             }else if (response.actionID == NetworkCode.MATCH_STATUS){
            response.action = new MatchStatusAction(response.intCount, response.stringCount,
                                              response.intList, response.stringList);
            }
            return response;
        }
Esempio n. 3
0
        public static NetworkResponse Parse(MemoryStream dataStream)
        {
            ResponseMatchAction response = new ResponseMatchAction();

            response.actionID    = DataReader.ReadShort(dataStream);
            response.intCount    = DataReader.ReadInt(dataStream);
            response.stringCount = DataReader.ReadInt(dataStream);
            Debug.Log("Action Protocol: length of ints " + response.intCount + " stringCount :" + response.stringCount);
            for (int i = 0; i < response.intCount; i++)
            {
                response.intList.Add(DataReader.ReadInt(dataStream));
            }
            for (int i = 0; i < response.stringCount; i++)
            {
                response.stringList.Add(DataReader.ReadString(dataStream));
                Debug.Log("Action Protocol : read string " + response.stringList[i] + " actionID: " + response.actionID);
            }

            // This could be done in a better way
            // Status no match indicates failure to successfully enter a valid match
            if (response.actionID == Constants.STATUS_NO_MATCH)
            {
                response.action = new InvalidMatchAction(response.intCount, response.stringCount,
                                                         response.intList, response.stringList);
            }
            else if (response.actionID == NetworkCode.DEAL_CARD)
            {
                response.action = new DealCardAction(response.intCount, response.stringCount,
                                                     response.intList, response.stringList);
            }
            else if (response.actionID == NetworkCode.SUMMON_CARD)
            {
                response.action = new SummonCardAction(response.intCount, response.stringCount,
                                                       response.intList, response.stringList);
            }
            else if (response.actionID == NetworkCode.END_TURN)
            {
                response.action = new EndTurnAction(response.intCount, response.stringCount,
                                                    response.intList, response.stringList);
            }
            else if (response.actionID == NetworkCode.CARD_ATTACK)
            {
                response.action = new CardAttackAction(response.intCount, response.stringCount,
                                                       response.intList, response.stringList);
            }
            else if (response.actionID == NetworkCode.TREE_ATTACK)
            {
                response.action = new TreeAttackAction(response.intCount, response.stringCount,
                                                       response.intList, response.stringList);
            }
            else if (response.actionID == NetworkCode.QUIT_MATCH)
            {
                response.action = new QuitMatchAction(response.intCount, response.stringCount,
                                                      response.intList, response.stringList);
            }
            else if (response.actionID == NetworkCode.MATCH_OVER)
            {
                response.action = new MatchOverAction(response.intCount, response.stringCount,
                                                      response.intList, response.stringList);
            }
            else if (response.actionID == NetworkCode.MATCH_STATUS)
            {
                response.action = new MatchStatusAction(response.intCount, response.stringCount,
                                                        response.intList, response.stringList);
            }
            return(response);
        }