public void SetData(BattleCharacter character) { NameLabel.text = character.Info.Name; LvLabel.text = character.Info.Lv.ToString(); HpBar.SetValue(character.Info.CurrentHP, character.Info.MaxHP); _foodBuff = character.Info.FoodBuff; _statusList = new List <BattleStatus>(character.Info.StatusDic.Values); if (_foodBuff != null) { FoodBuffIcon.gameObject.SetActive(true); } else { FoodBuffIcon.gameObject.SetActive(false); } for (int i = 0; i < BattleStatusButton.Length; i++) { if (i < _statusList.Count) { BattleStatusButton[i].gameObject.SetActive(true); BattleStatusButton[i].SetData(_statusList[i]); BattleStatusButton[i].Image.overrideSprite = Resources.Load <Sprite>("Image/BattleStatus/" + _statusList[i].Icon); } else { BattleStatusButton[i].SetData(null); BattleStatusButton[i].gameObject.SetActive(false); } } if (character.Info.IsTeamMember) { Image.gameObject.SetActive(true); if (character.Info.JobData.MediumImage != string.Empty) { Image.overrideSprite = Resources.Load <Sprite>("Image/Character/Medium/" + character.Info.JobData.MediumImage); } else { Image.overrideSprite = Resources.Load <Sprite>("Image/Character/Medium/NoImage_M"); } MpBar.gameObject.SetActive(true); MpBar.SetValue(character.Info.CurrentMP, character.Info.MaxMP); } else { Image.gameObject.SetActive(false); MpBar.gameObject.SetActive(false); } }
public void SetData(TeamMember member) { _selectedMember = member; CharacterNameLabel.text = member.Data.GetName(); LvLabel.text = TeamManager.Instance.Lv.ToString(); HPBar.SetValue(member.CurrentHP, member.MaxHP); MPBar.SetValue(member.CurrentMP, member.MaxMP); EXPBar.SetValue(TeamManager.Instance.Exp, TeamManager.Instance.NeedExp(TeamManager.Instance.Lv)); ATKLabel.Label.text = member.ATK.ToString(); DEFLabel.Label.text = member.DEF.ToString(); MTKLabel.Label.text = member.MTK.ToString(); MEFLabel.Label.text = member.MEF.ToString(); AGILabel.Label.text = member.AGI.ToString(); SENLabel.Label.text = member.SEN.ToString(); MOVLabel.Label.text = member.MOV.ToString(); WeaponButton.SetData(member.Weapon.Name, member.Weapon); EquipATKLabel.text = member.Weapon.ATK.ToString(); EquipMTKLabel.text = member.Weapon.MTK.ToString(); ArmorButton.SetData(member.Armor.Name, member.Armor); EquipDEFLabel.text = member.Armor.DEF.ToString(); EquipMEFLabel.text = member.Armor.MEF.ToString(); CharacterImage.overrideSprite = Resources.Load <Sprite>("Image/Character/Origin/" + member.Data.Image); CharacterImage.SetNativeSize(); FoodBuffLabel.text = "料理效果:\n" + member.FoodBuff.Comment; }
// Update is called once per frame void Update() { if (!CDReady) { currentCD += Time.deltaTime; if (currentCD >= CD) { currentCD = CD; CDReady = true; } } manabar.SetValue((int)currentCD); if (Input.GetKeyDown(KeyCode.Space)) { CastSkill(); } }
public void SetData(TeamMember member) { _member = member; Icon.overrideSprite = Resources.Load <Sprite>("Image/Character/Small/" + member.Data.SmallImage); NameLabel.text = member.Data.GetName(); HPBar.SetValue(member.CurrentHP, member.MaxHP); MPBar.SetValue(member.CurrentMP, member.MaxMP); }
private void UpdateDynamicUnitInfo() { if (!_selectionEntityInfo) { return; } unitHealthBar.SetValue(_selectionEntityInfo.health, _selectionEntityInfo.maxHealth); unitManaBar.SetValue(_selectionEntityInfo.mana, _selectionEntityInfo.maxMana); }
// Use this for initialization void Start() { for (int i = 0; i < transform.childCount; i++) { GameObject child = transform.GetChild(i).gameObject; child.SetActive(true); //Debug.Log(child.name); } //获取组件 if (null == player) { player = GameObject.FindObjectOfType <PlayCharacter>(); } // if (null == txt_Energy) txt_Energy = transform.Find("Info/Text_Energy").GetComponent<Text>(); // if (null == txt_Life) txt_Life = transform.Find("Info/Text_Life").GetComponent<Text>(); // if (null == bar_Energy) bar_Energy = transform.Find("Info/Bar_Energy").GetComponent<ValueBar>(); // if (null == bar_Life) bar_Life = transform.Find("Info/Bar_Life").GetComponent<ValueBar>(); // if (null == txt_AttackPower) txt_AttackPower = transform.Find("Info/Text_AttackPower").GetComponent<Text>(); // bar_Life.gameObject.SetActive(true); // bar_Energy.gameObject.SetActive(true); //初始化 bar_Life.SetValue(0); bar_Life.Hide(0.1f, true); bar_Energy.SetValue(0); bar_Energy.Hide(0.1f, true); //赋值 bar_Life.SetValue(player.life / player.maxLife); bar_Life.Display(1, true); txt_Life.text = ((int)player.life).ToString() + "/" + ((int)(player.maxLife)).ToString(); bar_Energy.SetValue(player.energy / player.maxEnergy); bar_Energy.Display(1, true); txt_Energy.text = ((int)player.energy).ToString() + "/" + ((int)(player.maxEnergy)).ToString(); AttackPower.text = player.attackPower.ToString(); }
void InstantiateLIfeBar()//实例化血条 { //生成预制体 enemylife = Instantiate(onEnmyLife); //将该物体赋予目标脚本 enemylife.SetTarget(this.transform); enemylife.h_offset = lifebar_Height; //得到血条 lifeBar = enemylife.GetComponent <ValueBar>(); lifeBar.SetValue(thisLnx.lifeValue / thisLnx.maxLife); }
private void Awake() { // Assign references skillHandler = GetComponent <SkillHandler>(); audioPlayer = GetComponent <AudioSource>(); helpTooltip = GetComponent <HelpTooltipUser>(); healthBar.gameObject.SetActive(false); if (unitClass.Type == UnitType.Guardian) { activeHealthBar = segmentedHealthBar; segmentedHealthBar.gameObject.SetActive(true); healthBar.gameObject.SetActive(false); } else { activeHealthBar = healthBar; segmentedHealthBar.gameObject.SetActive(false); healthBar.gameObject.SetActive(true); } // Initial setup Player.AddUnit(this); Health = unitClass.BaseHealth; resistancesManager = new ResistancesManager(this, unitClass.resistances); statusManager = new StatusManager(this, resistancesManager); spriteMaterial = sprite.material; GetComponentInChildren <ClassIcon>().SetValue(unitClass.Type); shieldBar.SetValue(Shield, baseShield); GraphicsToggle.Instance.DesignerModeChanged.AddListener(UpdateSprite); if (unitClass.Type == UnitType.Guardian) { bgFxAnimator.SetBool("Burning", true); } // Register listeners AddListeners(); }
// public void LossLife(float loseValue)//减血 // { // life -= loseValue; // if (life < 0) life = 0; // lifeValueBar.SetValue(life / maxLife); // } public void ChangeLifeValue(float getValue)//回血,减血 { life += getValue; if (life > maxLife) { life = maxLife; } else if (life < 0) { life = 0; } lifeValueBar.SetValue(life / maxLife); }
public void GetHurt(float Damage)//受伤 { if (!IsLive()) { return; } thisLnx.lifeValue -= Damage; //如果有血条,则血条显示血量 if (lifeBar != null) { lifeBar.SetValue(thisLnx.lifeValue / thisLnx.maxLife); } if (IsLive()) { return; } else { Die(); } }
// Start is called before the first frame update public void TakeDamage(int damage) { currentHealth -= damage; healthBar.SetValue(currentHealth); }