예제 #1
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);
 }
예제 #2
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();
 }
예제 #3
0
 public override void Open()
 {
     UIDelegateManager.AddObserver(UIMessageType.RefreshParty, RefreshCurrentParty);
     base.Open();
 }