예제 #1
0
 public override void Close()
 {
     UIDelegateManager.RemoveObserver(UIMessageType.RefreshMyHpText, RefreshMyHpText);
     UIDelegateManager.RemoveObserver(UIMessageType.RefreshMyHpBar, RefreshMyHpBar);
     UIDelegateManager.RemoveObserver(UIMessageType.RefreshOpponentHpBar, RefreshOpponentHpBar);
     base.Close();
 }
예제 #2
0
 private int playerHpMax;       //玩家当前血量上限
 // Use this for initialization
 protected override void Init()
 {
     base.Init();
     //获取每格血高度
     hpTextureHeight = HpBarImage.rectTransform.sizeDelta.y;
     //获取Player当前血量上限
     playerHpMax = GameObject.Find("player").GetComponent <PlayerProperties>().HpMaxValue;
     //根据Player血量初始化
     HpBarImage.fillAmount      = (float)playerHpMax / (float)PlayerProperties.HP_MaxLimit_Value;
     HpEmptyBarImage.fillAmount = 0;
     HpEmptyBarImage.rectTransform.localPosition = new Vector3((playerHpMax - PlayerProperties.HP_MaxLimit_Value) * hpTextureHeight, 0, 0);
     //绑定回调
     UIDelegateManager.AddObserver(UIMessageType.Updata_HpMax, OnHpMaxChange);
     UIDelegateManager.AddObserver(UIMessageType.Updata_Hp, OnHpChange);
 }
        private void Save()
        {
            errorText.text = string.Empty;
            List <int> skillIds = new List <int>();

            for (int i = 0; i < skillDPs.Length; i++)
            {
                skillIds.Add(int.Parse(skillDPs[i].captionText.text.Substring(0, 3)));
            }
            //存在重复技能
            if (skillIds.Count() != skillIds.Distinct().Count())
            {
                errorText.text = "技能不能重复选择";
            }
            else
            {
                for (int i = 0; i < skills.Length; i++)
                {
                    skills[i] = PublicDataManager.instance.GetSkillModel(skillIds[i]);
                }
                //各项属性修改为最终能力值
                for (int i = 0; i < abilityValueTexts.Length; i++)
                {
                    switch (i)
                    {
                    case 0: pokemon.hp = int.Parse(abilityValueTexts[i].text); break;

                    case 1: pokemon.attack = int.Parse(abilityValueTexts[i].text); break;

                    case 2: pokemon.defense = int.Parse(abilityValueTexts[i].text); break;

                    case 3: pokemon.sp_attack = int.Parse(abilityValueTexts[i].text); break;

                    case 4: pokemon.sp_defense = int.Parse(abilityValueTexts[i].text); break;

                    case 5: pokemon.speed = int.Parse(abilityValueTexts[i].text); break;
                    }
                }
                Pokemon p = new Pokemon(pokemon, character, personality, item, skills);
                p.isMe = true;
                RuntimeData.SetCurrentMyPokemon(p);
                UIDelegateManager.NotifyUI(UIMessageType.RefreshParty, RuntimeData.GetCurrentMyIndex());
                Close();
            }
        }
예제 #4
0
 public override void Open()
 {
     //初始化Pokemon阵容
     for (int i = 0; i < slots.Length; i++)
     {
         PokemonModel p    = RuntimeData.GetMyPokemonByIndex(i).GetModel();
         Sprite       icon = Resources.Load <Sprite>("PokemonSprites/" + StringUtil.FormatId(p.id) + "/Icon/IMG00000");
         slots[i].SetProperty(icon, p.name_ch, p.hp);
         int index = i;
         //更换Pokemon
         slots[i].gameObject.GetComponent <Button>().onClick.AddListener(() =>
         {
             RuntimeData.SetCurrentMyIndex(index);
             ChangePokemon(RuntimeData.GetCurrentMyPokemon(), true);
         });
     }
     //默认第一个Pokemon先上场
     ChangePokemon(RuntimeData.GetCurrentMyPokemon(), true);
     ChangePokemon(RuntimeData.GetCurrentOppPokemon(), false);
     UIDelegateManager.AddObserver(UIMessageType.RefreshMyHpText, RefreshMyHpText);
     UIDelegateManager.AddObserver(UIMessageType.RefreshMyHpBar, RefreshMyHpBar);
     UIDelegateManager.AddObserver(UIMessageType.RefreshOpponentHpBar, RefreshOpponentHpBar);
     base.Open();
 }
예제 #5
0
 public override void Close()
 {
     UIDelegateManager.RemoveObserver(UIMessageType.RefreshParty, RefreshCurrentParty);
     base.Close();
 }
예제 #6
0
 public override void Open()
 {
     UIDelegateManager.AddObserver(UIMessageType.RefreshParty, RefreshCurrentParty);
     base.Open();
 }