public void Show(DBActorAttributeConf actorConf, float maxHp, float curHp, float preHp, EmMonsterType monsterType) { string prefix = ""; if (monsterType == EmMonsterType.Elite) { prefix = "精英 · "; } else if (monsterType == EmMonsterType.Boss) { prefix = "领主 · "; } gameObject.SetActive(true); nameLvLabel.text = prefix + actorConf.charactorName + " Lv.1"; iconCtrl.Set(actorConf.portraitID); deadIconMark.SetActive(curHp == 0); hpSpriteNormal.fillAmount = curHp / maxHp; this.maxHp = maxHp; hpFrom = preHp; hpTo = curHp; hpSpriteDark.fillAmount = hpFrom / maxHp; hpAnimaTimer = 0; isPlaying = true; autoHide = curHp == 0f; }
//useConfAtt是否使用配表的属性 public void Init(int actorID, int actorLv, bool useConfAtt, EmActorFaction _actorFaction, EmActorType _actorType) { actorConf = DBActorAttributeTable.GetRecord(actorID); actorFaction = _actorFaction; actorType = _actorType; if (useConfAtt) { orgAttribute = TqmDatabase.CreateActorAttributeData(actorConf, actorLv); } else { orgAttribute = ActorAttributeDataCollection.GetActorAttributeData(actorID); } curAttribute = TqmDatabase.CloneActorAttributeData(orgAttribute); objectbase = gameObject.GetComponent <ObjectBase>(); objectcollider = gameObject.GetComponent <ObjectCollider>(); audioSource = gameObject.AddComponent <AudioSource>(); objectbase.x2dAnim = ResourceLoader.GetX2dAniamtion(actorConf.animationName, transform); foreach (int i in actorConf.skillIdList) { activeSkillList.Add(skillStateManager.GetSkillState(i)); } objectcollider.size = actorConf.size; ChangeStatus(EmActorStatus.Idle); }
public void ShowMonsterHP(DBActorAttributeConf actorConf, float maxHp, float curHp, float preHp, EmMonsterType monsterType) { UIHpCtrl hpCtrl = null; if (monsterType == EmMonsterType.Boss) { hpCtrl = bigHpCtrl; smallHpCtrl.gameObject.SetActive(false); } else { hpCtrl = smallHpCtrl; bigHpCtrl.gameObject.SetActive(false); } hpCtrl.gameObject.SetActive(true); hpCtrl.Show(actorConf, maxHp, curHp, preHp, monsterType); }
//获取记录,如果不存在返回null public static DBActorAttributeConf GetRecord(int actorID, bool errorMsg = true) { if (instance == null) { Debug.LogError("表DBActorAttributeTable未加载"); return(null); } DBActorAttributeConf record = null; if (recordDict.TryGetValue(actorID, out record)) { return(record); } if (errorMsg) { Debug.LogErrorFormat("表DBActorAttributeTable没有actorID = {0}的记录", actorID); } return(null); }
public void Init() { //如果recordDict不为null,说明已经初始化了 if (recordDict != null) { return; } recordDict = new Dictionary <int, DBActorAttributeConf>(); for (int i = 0; i < recordArray.Length; i++) { DBActorAttributeConf record = recordArray[i]; if (!recordDict.ContainsKey(record.actorID)) { recordDict.Add(record.actorID, record); } else { Debug.LogErrorFormat("表DBActorAttributeTable有重复的记录,id = {0}", record.actorID); } } }
public static ActorAttributeData CreateActorAttributeData(DBActorAttributeConf conf, int actorLv) { actorLv--; //最终值是基础值 + 成长*(lv-1) ActorAttributeData newConf = new ActorAttributeData(); newConf.actorID = conf.actorID; // newConf.hp = conf.hp + conf.hpGrowth * actorLv; newConf.attack = conf.attack + conf.attackGrowth * actorLv; newConf.mitigation = conf.mitigation + conf.mitigation * actorLv; newConf.defense = conf.defense + conf.defenseGrowth * actorLv; // newConf.walkSpeed = conf.walkSpeed; newConf.runSpeed = conf.runSpeed; newConf.normalAttackDistance = conf.normalAttackDistance; newConf.jumpHeight = conf.jumpHeight; newConf.jumpYSpeed = conf.jumpYSpeed; newConf.jumpBackXSpeed = conf.jumpBackXSpeed; newConf.jumpBackYSpeed = conf.jumpBackYSpeed; newConf.falldownAcc = conf.falldownAcc; newConf.attackSpeed = conf.attackSpeed; return(newConf); }