コード例 #1
0
    private void HandleOnlineAward(OperationResponse response)
    {
        GameAward gameAward = null;

        if (response.Parameters.ContainsKey((byte)ParameterCode.GameAward))
        {
            byte[] data = (byte[])response[(byte)ParameterCode.GameAward];
            gameAward = Serialization.LoadStruct <GameAward>(data);
            byte[] itemData = (byte[])response[(byte)ParameterCode.UserItems];

            UserItem[] userItems = Serialization.LoadArray <UserItem>(itemData, true);
            if (userItems != null)
            {
                foreach (UserItem item in userItems)
                {
                    item.GameItem = (GameItem)GameManager.GameItems[item.ItemId];
                }

                GameManager.GameUser.UserItems.Clear();
                GameManager.GameUser.UserItems.AddRange(userItems);
            }
        }

        byte[]            userData = (byte[])response[(byte)ParameterCode.UserBase];
        GameUser.UserBase userBase = Serialization.LoadStruct <GameUser.UserBase>(userData);
        GameManager.GameUser.Base = userBase;


        _uiManager.OnResponseOnlineReward(gameAward);
    }
コード例 #2
0
 public void OnResponseOnlineReward(GameAward gameAward)
 {
     _onlineTime = GameManager.GameUser.Base.CurrentAwardTime;
     if (gameAward != null)
     {
         InitOnlineRewardReview();
         DisableAnimReward();
         uiLogInReward.reviewBtnTakeAll.gameObject.SetActive(false);
     }
 }
コード例 #3
0
    private void HandleUserSync(EventData eventData)
    {
        byte[] gameAward = (byte[])eventData.Parameters[(byte)ParameterCode.GameAward];
        byte[] userData  = (byte[])eventData.Parameters[(byte)ParameterCode.UserData];

        int userLevelOld = GameManager.GameUser.Base.Level;

        GameManager.InitGameUser(userData);

        if (gameAward != null)
        {
            GameAward award = Serialization.LoadStruct <GameAward>(gameAward);

            GameManager.itemReward = award.Items;

            UIBattleManager.Instance.battleResult.battleAward = new UIBattleResultNew.BattleAward()
            {
                name       = GameManager.GameUser.Base.NickName,
                level      = GameManager.GameUser.Base.Level,
                Exp        = award.UserExp,
                silver     = award.Silver,
                gold       = award.Gold,
                honor      = award.Honor,
                HeroEXP    = award.RoleExp,
                EndDungeon = false,
                silverEx   = award.SilverEx
            };


            if (award.Silver < 0)
            {
                UIBattleManager.Instance.battleResult.battleAward.silverSign = -1;
            }
            else
            {
                UIBattleManager.Instance.battleResult.battleAward.silverSign = 1;
            }
        }

        if (GameManager.GameUser.Base.Level > userLevelOld)
        {
            UIBattleManager.Instance.battleResult.battleAward.isLevelUp = true;
        }

        //Debug.Log("Honor = " + UIBattleManager.Instance.battleResult.userResult.honor);
    }
コード例 #4
0
    private void InitOnlineRewardReview()
    {
        foreach (GameObject go in _itemReview)
        {
            NGUITools.Destroy(go);
        }

        _itemReview.Clear();

        if (GameManager.GameUser.Base.OnlineAwardStep < 0 || GameManager.GameUser.Base.OnlineAwardStep >= GameConfig.ONLINE_AWARDS.Length - 1)
        {
            return;
        }

        GameAward gameAward = GameConfig.ONLINE_AWARDS[GameManager.GameUser.Base.OnlineAwardStep + 1][GameManager.GameUser.Base.Level];

        if (gameAward != null)
        {
            foreach (var item in gameAward.Items)
            {
                GameObject go   = NGUITools.AddChild(uiLogInReward.reviewItemRoot.gameObject, uiLogInReward.reviewItemPrefab);
                Texture2D  icon = Helper.LoadTextureForSupportItem(item.Key);
                if (icon == null)
                {
                    icon = Helper.LoadTextureForEquipItem(item.Key);
                }

                go.transform.FindChild("icon").GetComponent <UITexture>().mainTexture = icon;
                go.transform.FindChild("amount").GetComponent <UILabel>().text        = "x" + item.Value;
                go.transform.FindChild("name").GetComponent <UILabel>().text          = GameManager.localization.getItem(item.Key).Name;
                go.transform.FindChild("check").gameObject.SetActive(false);
                go.SetActive(true);
                _itemReview.Add(go);
            }
        }

        if (gameAward.Silver > 0)
        {
            GameObject go   = NGUITools.AddChild(uiLogInReward.reviewItemRoot.gameObject, uiLogInReward.reviewItemPrefab);
            Texture2D  icon = Helper.LoadTextureSilver();
            go.transform.FindChild("icon").GetComponent <UITexture>().mainTexture = icon;
            go.transform.FindChild("amount").GetComponent <UILabel>().text        = "x" + gameAward.Silver;
            go.transform.FindChild("name").GetComponent <UILabel>().text          = "";
            go.transform.FindChild("check").gameObject.SetActive(false);
            go.SetActive(true);
            _itemReview.Add(go);
        }

        if (gameAward.Gold > 0)
        {
            GameObject go   = NGUITools.AddChild(uiLogInReward.reviewItemRoot.gameObject, uiLogInReward.reviewItemPrefab);
            Texture2D  icon = Helper.LoadTextureGold();
            go.transform.FindChild("icon").GetComponent <UITexture>().mainTexture = icon;
            go.transform.FindChild("amount").GetComponent <UILabel>().text        = "x" + gameAward.Gold;
            go.transform.FindChild("name").GetComponent <UILabel>().text          = "";
            go.transform.FindChild("check").gameObject.SetActive(false);
            go.SetActive(true);
            _itemReview.Add(go);
        }

        uiLogInReward.reviewItemRoot.Reposition();
    }
コード例 #5
0
    private void InitDailyReward()
    {
        uiLogInReward.lblLogInRewardHeader.text = GameManager.localization.GetText("LogInReward_Header");
        uiLogInReward.lblLogInRewardDes.text    = Helper.StringToMultiLine(GameManager.localization.GetText("LoginReward_Desc"));

        for (int i = 1; i < GameConfig.DAILY_AWARDS.Length; i++)
        {
            GameObject go = NGUITools.AddChild(uiLogInReward.dailyItemRoot.gameObject, uiLogInReward.dailyItemPrefab);
            go.SetActive(true);

            List <GameAward> gameAwards = GameConfig.DAILY_AWARDS[i];
            GameAward        gameAward  = gameAwards[GameManager.GameUser.Base.Level];

            foreach (var item in gameAward.Items)
            {
                Texture2D icon = Helper.LoadTextureForSupportItem(item.Key);
                if (icon == null)
                {
                    icon = Helper.LoadTextureForEquipItem(item.Key);
                }
                go.transform.FindChild("icon").GetComponent <UITexture>().mainTexture = icon;
                go.transform.FindChild("amount").GetComponent <UILabel>().text        = "x" + item.Value;
            }

            if (gameAward.Silver > 0)
            {
                Texture2D icon = Helper.LoadTextureSilver();
                go.transform.FindChild("icon").GetComponent <UITexture>().mainTexture = icon;
                go.transform.FindChild("amount").GetComponent <UILabel>().text        = "x" + gameAward.Silver;
                go.SetActive(true);
            }

            if (gameAward.Gold > 0)
            {
                Texture2D icon = Helper.LoadTextureGold();
                go.transform.FindChild("icon").GetComponent <UITexture>().mainTexture = icon;
                go.transform.FindChild("amount").GetComponent <UILabel>().text        = "x" + gameAward.Gold;
                go.SetActive(true);
            }

            go.transform.FindChild("day").GetComponent <UILabel>().text = string.Format(GameManager.localization.GetText("LoginReward_Day"), i);

            GameObject check = go.transform.FindChild("check").gameObject;
            if (GameManager.GameUser.DailyLoginCount < i)
            {
                check.SetActive(false);
                go.transform.FindChild("border").gameObject.SetActive(false);
            }
            else
            {
                check.SetActive(true);
                go.transform.FindChild("border").gameObject.SetActive(true);
            }


            if (GameManager.GameUser.DailyLoginCount == i && check.activeInHierarchy)
            {
                Hashtable hash = new Hashtable();
                hash["scale"]    = new Vector3(4, 4, 4);
                hash["time"]     = 0.5;
                hash["delay"]    = 1;
                hash["easetype"] = iTween.EaseType.easeInOutExpo;
                iTween.ScaleFrom(check, hash);

                Helper.FadeIn(check.GetComponent <UISprite>(), 1.2f, uiLogInReward.animCurve, 0, FadeInConplete);
            }
        }
        uiLogInReward.dailyItemRoot.Reposition();
    }