Ejemplo n.º 1
0
    void ReadTeamMember(XmlNode node, Team.Side team, GameMatchData matchData)
    {
        foreach (XmlNode child in node.ChildNodes)
        {
            XmlElement element             = child as XmlElement;
            GameMatch.Config.TeamMember tm = new GameMatch.Config.TeamMember();
            tm.pos  = XmlUtils.XmlGetAttr_Int(element, "pos");
            tm.id   = XmlUtils.XmlGetAttr_String(element, "id");
            tm.team = team;

            if (element.Name == "NPC")
            {
                matchData.npcList.Add(tm);
            }
            else if (child.Name == "MainRole")
            {
                matchData.mainRole = tm;
            }
            else if (child.Name == "RemotePlayer")
            {
                matchData.remoteList.Add(tm);
            }
            else
            {
                Debug.Log(ToString() + ": Invalid config.");
                return;
            }
        }
    }
Ejemplo n.º 2
0
    /*
     * -----------------------------------------------------
     *                                              Awake
     * -----------------------------------------------------
     */
    void Awake()
    {
        Debug.Log("Awake");

        if (Instance != null && Instance != this)
        {
            //destroy other instances
            Destroy(gameObject);
        }
        else if (Instance == null)
        {
                        #if USE_ANALYTICS
            flurryService = Flurry.Instance;
            //AssertNotNull(service, "Unable to create Flurry instance!", this);
            //Assert(!string.IsNullOrEmpty(_iosApiKey), "_iosApiKey is empty!", this);
            //Assert(!string.IsNullOrEmpty(_androidApiKey), "_androidApiKey is empty!", this);
            flurryService.StartSession(_iosApiKey, _androidApiKey);
                        #endif

#if PROPELLER_SDK
            m_listener = new fuelSDKListener();
            if (m_listener == null)
            {
                throw new Exception();
            }
#endif

            m_matchData = new GameMatchData();
            m_matchData.ValidMatchData = false;
            m_matchData.MatchComplete  = false;

            socialPost     = SocialPost.NONE;
            socialPostData = null;

            useFaceBook    = true;
            useFuelCompete = true;

            if (useFaceBook)
            {
                Debug.Log("FB.Init");
                FB.Init(SetInit, OnHideUnity);
            }
        }

        Instance = this;

        DontDestroyOnLoad(gameObject);
    }
Ejemplo n.º 3
0
    void Start()
    {
        mGameState = eGameState.Init;


        //set match data
        //FuelHandler _fuelHandlerScript = getFuelHandlerClass();

        //GameMatchData _data = _fuelHandlerScript.getMatchData();


        PropellerProduct _propellerProductScript = getPropellerProductClass();
        GameMatchData    _data = _propellerProductScript.getMatchData();


        if (_data.ValidMatchData == true)
        {
            updateYourAvatarText(_data.YourNickname);
            updateTheirAvatarText(_data.TheirNickname);
            updateMatchRoundText("Round - " + _data.MatchRound.ToString());

            GameObject _gameObj = GameObject.Find("yourAvatar");
            StartCoroutine(downloadImgX(_data.YourAvatarURL, _gameObj));

            _gameObj = GameObject.Find("theirAvatar");
            StartCoroutine(downloadImgX(_data.TheirAvatarURL, _gameObj));
        }
        else         //Single Player
        {
            updateYourAvatarText("You");
            updateTheirAvatarText("Computer");
            updateMatchRoundText("Round - X");
        }

        GameObject _backObj = GameObject.Find("backButton");

        _backObj.GetComponent <Renderer>().enabled = false;


        //Timeup Popup
        GameObject _timeup = GameObject.Find("TimeUpPopup");

        _timeup.GetComponent <Renderer>().enabled = false;
        _timeup = GameObject.Find("finalScore");
        _timeup.GetComponent <Renderer>().enabled = false;

        gameoverTimer = 0.0f;
    }
Ejemplo n.º 4
0
    public void RefreshHiScore()
    {
        if (PlayerPrefs.HasKey("hiScore"))
        {
            PropellerProduct _propellerProductScript = getPropellerProductClass();
            GameMatchData    _gameMatchData          = _propellerProductScript.getMatchData();
            int score  = _gameMatchData.MatchScore;
            var _score = PlayerPrefs.GetInt("hiScore");

            if (score > _score)
            {
                _score = score;
                PlayerPrefs.SetInt("hiScore", _score);
            }

            GameObject gameObj = GameObject.Find("HiScore");
            TextMesh   t       = (TextMesh)gameObj.GetComponent(typeof(TextMesh));
            t.text = _score.ToString();
        }
    }
Ejemplo n.º 5
0
    void ReadMatchCommon(XmlNode root, GameMatchData matchData)
    {
        foreach (XmlNode node in root.ChildNodes)
        {
            if (node.NodeType != XmlNodeType.Element)
            {
                continue;
            }
            XmlElement element = node as XmlElement;
            if (node.Name == "Scene")
            {
                matchData.sceneId = uint.Parse(node.InnerText);
            }
            if (node.Name == "Team")
            {
                foreach (XmlNode teamNode in node.ChildNodes)
                {
                    if (teamNode.Name == "Home")
                    {
                        ReadTeamMember(teamNode, Team.Side.eHome, matchData);
                    }
                    else if (teamNode.Name == "Away")
                    {
                        ReadTeamMember(teamNode, Team.Side.eAway, matchData);
                    }
                }
            }

            if (node.Name == "Time")
            {
                matchData.matchTime = XmlUtils.XmlGetAttr_Number(element, "x");
            }

            if (node.Name == "OppoColorMulti")
            {
                matchData.oppoColorMulti = XmlUtils.XmlGetAttr_Number(element, "x");
            }
        }
        gameMatchData = matchData;
    }
Ejemplo n.º 6
0
 public void LoadMatchConfig(ref GameMatch.Config config, GameMatch.Type matchType = GameMatch.Type.eNone)
 {
     try
     {
         if (matchType == GameMatch.Type.eNone)
         {
             config.sceneId        = gameMatchData.sceneId;
             config.NPCs           = gameMatchData.npcList;
             config.MainRole       = gameMatchData.mainRole;
             config.RemotePlayers  = gameMatchData.remoteList;
             config.MatchTime      = gameMatchData.matchTime;
             config.OppoColorMulti = gameMatchData.oppoColorMulti;
         }
         else
         {
             GameMatchData data = null;
             gameMatchDatas.TryGetValue(matchType, out data);
             if (data != null)
             {
                 config.type           = data.type;
                 config.sceneId        = data.sceneId;
                 config.NPCs           = data.npcList;
                 config.MainRole       = data.mainRole;
                 config.RemotePlayers  = data.remoteList;
                 config.MatchTime      = data.matchTime;
                 config.OppoColorMulti = data.oppoColorMulti;
             }
             else
             {
                 Debug.LogError("Match Config is null!");
             }
         }
     }
     catch (Exception exp)
     {
         Debug.Log("load match config failed: " + exp.Message);
     }
 }
Ejemplo n.º 7
0
    public void ReadMatchConfig()
    {
        for (int i = 3; i < 9; i++)
        {
            string name = "";
            switch (i)
            {
            case 3:
                name = name3;
                break;

            case 4:
                name = name4;
                break;

            case 5:
                name = name5;
                break;

            case 6:
                name = name6;
                break;

            case 7:
                name = name7;
                break;

            case 8:
                name = name8;
                break;
                //case 9:
                //    name = name9;
                //    break;
            }
            Debug.Log("Config reading " + name);
            string text = ResourceLoadManager.Instance.GetConfigText(name);
            if (text == null)
            {
                Debug.LogError("LoadConfig failed: " + name);
                return;
            }
            try
            {
                //读取以及处理XML文本的类
                XmlDocument xmlDoc = CommonFunction.LoadXmlConfig(name, text);
                //解析xml的过程
                XmlNode root = xmlDoc.ChildNodes[0];
                if (root == null)
                {
                    return;
                }

                GameMatchData matchData = new GameMatchData();
                XmlElement    rootElm   = root as XmlElement;
                if (name != GlobalConst.DIR_XML_MATCH_COMMON)
                {
                    int type = XmlUtils.XmlGetAttr_Int(rootElm, "type", 1);
                    matchData.type = (GameMatch.Type)type;
                }
                else
                {
                    ReadMatchCommon(root, matchData);
                    continue;
                }

                foreach (XmlNode node in root.ChildNodes)
                {
                    if (node.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    XmlElement element = node as XmlElement;
                    if (node.Name == "Scene")
                    {
                        matchData.sceneId = uint.Parse(node.InnerText);
                    }
                    if (node.Name == "Team")
                    {
                        foreach (XmlNode teamNode in node.ChildNodes)
                        {
                            if (teamNode.Name == "Home")
                            {
                                ReadTeamMember(teamNode, Team.Side.eHome, matchData);
                            }
                            else if (teamNode.Name == "Away")
                            {
                                ReadTeamMember(teamNode, Team.Side.eAway, matchData);
                            }
                        }
                    }

                    if (node.Name == "Time")
                    {
                        matchData.matchTime = XmlUtils.XmlGetAttr_Number(element, "x");
                    }

                    if (node.Name == "OppoColorMulti")
                    {
                        matchData.oppoColorMulti = XmlUtils.XmlGetAttr_Number(element, "x");
                    }
                }

                gameMatchDatas.Add(matchData.type, matchData);
            }
            catch (XmlException exp)
            {
                Debug.Log("load match config failed: " + exp.Message);
            }
        }
    }