예제 #1
0
        public void SetAndRefresh(Communication.Proto.Equip equip, bool worn, int count)
        {
            _equip = equip;
            _worn  = worn;
            _count = count;

            if (_equip != null)
            {
                //var lbl = GetComponentInChildren<UILabel>();
                //if (lbl) lbl.text = _equip.EquipCode.ToString() + " " + (_worn ? "√" : "×");
                LblCount.text = "×" + _count;

                SprEquip.atlas = MorlnDownloadResources.Load <UIAtlas>("ResourcesForDownload/Equip/EquipIcon/Atlas-EquipIcons");
                var sprName = EquipUtil.GetEquipSpriteName(_equip.EquipCode, _equip.Type);

                //var spr = Resources.Load<Sprite>("Sprites/Equip/" + sprName);
                //SprEquip.sprite = spr;
                SprEquip.spriteName = sprName;
                SprEquip.MakePixelPerfect();
            }
            else
            {
                LblCount.text    = null;
                SprEquip.enabled = false;
            }
        }
예제 #2
0
        public void SetAndRefresh(Communication.Proto.Equip equip)
        {
            Equip = equip;
            if (Equip != null)
            {
                SprEquip.atlas = MorlnDownloadResources.Load <UIAtlas>("ResourcesForDownload/Equip/EquipIcon/Atlas-EquipIcons");
                var sprName = EquipUtil.GetEquipSpriteName(Equip.EquipCode, Equip.Type);

                SprEquip.spriteName = sprName;
            }
            else
            {
                SprEquip.atlas      = MorlnResources.Load <UIAtlas>("atlases/Atlas-PushLevelUI");
                SprEquip.spriteName = "未获得装备";
            }
        }
예제 #3
0
        public static GameObject Dequeue(int code)
        {
            var index = code - 90001;//TODO: Fix

            if (index < 0 || index >= Character.MaxCharacterKindCount)
            {
                Debug.LogError("code错误,code=" + index);
                return(null);
            }
            if (Instance.CodeCharacterBAPoolList[index].Count > 0)
            {
                var go = Instance.CodeCharacterBAPoolList[index].Dequeue();
                go.SetActive(true);
                return(go);
            }
            var prefab = MorlnDownloadResources.Load <GameObject>("ResourcesForDownload/Character/Character" + code);

            return(PrefabHelper.InstantiateAndReset(prefab, Instance.transform));
        }
예제 #4
0
        /// <summary>
        /// 穿装备。
        /// </summary>
        /// <param name="type">0:头盔,1:盔甲,2:剑,3:盾,4:鞋子。</param>
        /// <param name="equipCode">null则脱掉</param>
        public void WearEquip(int type, int?equipCode)
        {
            if (!AnimationInfo)
            {
                return;
            }
            var equipSprite = equipCode != null?MorlnDownloadResources.Load <Sprite>("ResourcesForDownload/Equip/EquipSprite/Equip" + equipCode) : null;

            SpriteRenderer sr;

            switch (type)
            {
            case 2:
                sr = AnimationInfo.Weapon;
                break;

            case 3:
                sr = AnimationInfo.Shield;
                break;

            default:
                return;
            }
            if (equipSprite)
            {
                if (sr)
                {
                    sr.sprite = equipSprite;
                }
            }
            else
            {
                if (sr)
                {
                    sr.sprite = null;
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 第一次调用时创建新的岛屿内容,之后调用不会再改动。
        /// </summary>
        /// <param name="pushLevelUI"></param>
        /// <param name="majorLevelId"></param>
        /// <param name="majorLevel"></param>
        /// <param name="majorLevelData"></param>
        public void SetAndRefresh(PushLevelUI pushLevelUI, int majorLevelId, MajorLevelUnlockInfo majorLevel, MajorLevelData majorLevelData)
        {
            PushLevelUI           = pushLevelUI;
            MajorLevelId          = majorLevelId;
            _majorLevelUnlockInfo = majorLevel;
            _majorLevelData       = majorLevelData;

            if (!_artContent)
            {
                var prefab = MorlnDownloadResources.Load <GameObject>("ResourcesForDownload/Island/Island" + (majorLevelId - 1));
                _artContent = PrefabHelper.InstantiateAndReset(prefab, transform);
                //_artContent.transform.localScale = new Vector3(0.5f, 0.5f, 1);
                IslandInfo = _artContent.GetComponent <IslandInfo>();
                if (IslandInfo)
                {
                    IslandInfo.Island = this;
                    IslandInfo.transform.SetSortingLayer("Planet");
                }
            }
            if (!IslandInfo)
            {
                Debug.LogError("没有岛屿内容则不能玩游戏,请检查");
                return;
            }

            if (_majorLevelData == null)
            {
                Debug.LogError("没有_majorLevelData。不用显示了,玩不了!");
                return;
            }
            if (_majorLevelData.SubLevelList == null)
            {
                Debug.LogError("没有_majorLevelData.SubLevelList。不用显示了,玩不了!");
                return;
            }

            while (SubLevelPointList.Count < _majorLevelData.SubLevelList.Count)//确保 小关点 数量足够
            {
                var subLevelPoint = PrefabHelper.InstantiateAndReset <SubLevelPoint>(SubLevelPointTemplate, SubLevelPointContainer);
                subLevelPoint.name = "SubLevel " + SubLevelPointList.Count;
                SubLevelPointList.Add(subLevelPoint);
            }
            var subLevelPointPosList = Route.GetPointsUniformly(_majorLevelData.SubLevelList.Count);

            for (int subId = 1; subId <= SubLevelPointList.Count; subId++)
            {
                var pointI = subId - 1;
                var dataI  = _majorLevelData != null
                                ? _majorLevelData.SubLevelList.FindIndex(x => x.SubLevelId == subId)
                                : -1;

                var unlockI = _majorLevelUnlockInfo != null
                                  ? _majorLevelUnlockInfo.SubLevelUnlockInfoList.FindIndex(x => x.SubLevelId == subId)
                                  : -1;

                if (dataI >= 0) //后者必然true,只为彻底保险
                {
                    var go = SubLevelPointList[pointI].gameObject;
                    go.SetActive(true);
                    go.transform.localPosition = subLevelPointPosList[pointI];
                    SubLevelPointList[pointI].SetAndRefresh(_majorLevelData.MajorLevelId,
                                                            unlockI >= 0 ? _majorLevelUnlockInfo.SubLevelUnlockInfoList[unlockI] : null,
                                                            dataI >= 0 ? _majorLevelData.SubLevelList[dataI] : null);//指数大于0则一定不为null,放心,别管波浪线
                }
                else
                {
                    SubLevelPointList[pointI].gameObject.SetActive(false);
                }
            }
            SubLevelPointTemplate.SetActive(false);

            var locked = _majorLevelUnlockInfo == null || !_majorLevelUnlockInfo.Unlocked;

            IslandInfo.CloudsContainer.SetActive(locked);
        }
예제 #6
0
        private void UpperSetAndRefresh(int index)
        {
            LblLevel.text = string.Format("{0}", CommonData.MyUser.Level);
            LblExp.text   = string.Format("{0}/{1}", CommonData.MyUser.Exp, CommonData.MyUser.ExpCeil);
            SldExp.value  = 1f * CommonData.MyUser.Exp / CommonData.MyUser.ExpCeil;

            var attack      = 0;
            var health      = CommonData.MyUser.RoundInitHealth;
            var equipConfig = ConfigManager.GetConfig(ConfigManager.ConfigType.EquipConfig) as EquipConfig;

            if (equipConfig != null)
            {
                var myUserCharacter =
                    CommonData.MyCharacterList.Find(x => x.CharacterCode == CommonData.MyUser.CharacterCode);
                if (myUserCharacter != null)
                {
                    foreach (var equip in myUserCharacter.WearEquipList.Select(equipCode => equipConfig.EquipList.Find(x => x.EquipCode == equipCode)).Where(equip => equip != null))
                    {
                        attack += (int)equip.AttackAdd;
                        health += (int)equip.HealthAdd;
                        MyCharacter.WearEquip(equip.Type, equip.EquipCode);//角色穿装备
                    }
                }
            }
            LblAttack.text  = attack.ToString();
            LblDefense.text = health.ToString();


            if (_characterList.Count == 0)
            {
                Debug.LogError("_characterList.Count == 0 ERROR");
                return;
            }
            if (_equipConfig == null)
            {
                return;
            }

            _index = Mathf.Clamp(index, 0, _characterList.Count - 1);
            MyCharacter.CharacterCode = CurCharacterCode;
            MyCharacter.Refresh();
            MyCharacter.TakeOffAllEquip();
            var sprs = MyCharacter.GetComponentsInChildren <SpriteRenderer>(true);

            foreach (var spriteRenderer in sprs)
            {
                spriteRenderer.sortingLayerName = "Foreground";
            }
            var curUserCharacter = CommonData.MyCharacterList.Find(x => x.CharacterCode == CurCharacterCode);

            if (curUserCharacter == null) //未解锁
            {
                GrpLockedCharacter.SetActive(true);
                GrpUnlockedCharacter.SetActive(false);

                if (_characterIntroTextConfig == null)
                {
                    _characterIntroTextConfig =
                        ConfigManager.GetConfig(ConfigManager.ConfigType.CharacterIntroTextConfig) as
                        CharacterIntroTextConfig;
                }
                if (_characterIntroTextConfig != null)
                {
                    var intro = _characterIntroTextConfig.IntroList.Find(x => x.CharacterCode == CurCharacterCode);
                    if (intro != null)
                    {
                        LblCharacterDescription.text = intro.Description;
                        LblCharacterTalent.text      = intro.TalentIntro;
                    }
                    else
                    {
                        Debug.LogError("没有CharacterIntro。Code:" + CurCharacterCode);
                        LblCharacterDescription.text = null;
                        LblCharacterTalent.text      = null;
                    }
                }
                else
                {
                    Debug.LogError("没有CharacterIntroTextConfig");
                    LblCharacterDescription.text = null;
                    LblCharacterTalent.text      = null;
                }
            }
            else//已解锁
            {
                GrpUnlockedCharacter.SetActive(true);
                GrpLockedCharacter.SetActive(false);

                //出战按钮
                if (CommonData.MyUser.CharacterCode == CurCharacterCode)
                {
                    BtnChuzhan.isEnabled = false;
                    Tick.enabled         = true;
                }
                else
                {
                    BtnChuzhan.isEnabled = true;
                    Tick.enabled         = false;
                }

                for (int type = 0; type < 5; type++)
                {
                    SprEquips[type].enabled = false;
                }
                foreach (var code in curUserCharacter.WearEquipList)
                {
                    var equip = _equipConfig.EquipList.Find(x => x.EquipCode == code);

                    if (equip == null)
                    {
                        Debug.LogError("找不到配置Equip:" + code);
                        continue;
                    }

                    var type = equip.Type;
                    SprEquips[type].atlas =
                        MorlnDownloadResources.Load <UIAtlas>("ResourcesForDownload/Equip/EquipIcon/Atlas-EquipIcons");
                    var sprName = EquipUtil.GetEquipSpriteName(code, type);
                    //var spr = Resources.Load<Sprite>("Sprites/Equip/" + sprName);
                    SprEquips[type].enabled = true;
                    //SprEquips[type].sprite = spr;
                    SprEquips[type].spriteName = sprName;

                    MyCharacter.WearEquip(type, code);
                }
            }

            BtnLeft.SetActive(_index > 0);
            BtnRight.SetActive(_index < _characterList.Count - 1);
        }
예제 #7
0
        public void Execute(LoginOk cmd)
        {
            _loginOk = true;

            Requester.Instance.Send(new RequestMyHeartInfo());

            //申请好友列表
            Requester.Instance.Send(new RequestSNSFriendInfoList());

            //申请信件
            Requester.Instance.Send(new RefreshMailList(2));

            //淡入音乐
            MusicManager.Instance.CrossFadeIn();

            //检测大型Config有无变化
            var configIdList = new List <int>();
            var values       = Enum.GetValues(typeof(ConfigManager.ConfigType)) as ConfigManager.ConfigType[];

            if (values != null)
            {
                for (int i = 0; i < values.Length; i++)
                {
                    if (i < cmd.ConfigHash.ConfigHashList.Count)
                    {
                        if (cmd.ConfigHash.ConfigHashList[i] != ConfigManager.GetHash((ConfigManager.ConfigType)i))
                        {
                            configIdList.Add(i);
                        }
                    }
                    else
                    {
                        Debug.LogError("服务端ConfigHash.ConfigHashList长度不对.count:" + cmd.ConfigHash.ConfigHashList.Count);
                    }
                }
            }
            else
            {
                Debug.LogError("这怎么能是null,那还怎么获取Config");
            }
            if (configIdList.Count > 0)
            {
                _syncConfigOk = false;
                Requester.Instance.Send(new RequestConfig
                {
                    ConfigIdList = configIdList
                });
            }
            else
            {
                _syncConfigOk = true;
            }

            CommonData.FirstTimeGuide = cmd.HasFirstTimeGuide && cmd.FirstTimeGuide;
            if (CommonData.FirstTimeGuide)
            {
                Requester.Instance.Send(new RequestNickname()); //提前准备好随机昵称列表
                MenuUI.HighlightAdventureBtn = true;            //让冒险模式的按钮可以弹起来强调

                UMengPlugin.UMengEvent(EventId.VERY_BEGINNING, new Dictionary <string, object> {
                    { "hour", DateTime.Now.Hour }
                });
            }

            //推送模块设置
            PushInfoManager.Instance.Init();

            //下载动态资源
            if (!MorlnDownloadResources.DownloadAssetBundle)
            {
                StartCoroutine(MorlnDownloadResources.ForceLoadAssetBundle());
            }
        }