public override void OnEnterState() { base.OnEnterState(); m_attirCom = Entity.GetComponent <CAttributeCom>(); m_moveSpeed = m_attirCom.GetAttr(E_AttributeType.MoveSpeed) / 10f; m_moveGobj = Entity.GetComponent <CRenderCom>().GameObject; var attackCom = Entity.GetComponent <CAttackCom>(); var battleSys = CBattleEntityMgr.Instance.GetSystem <CBattleEntitySys>(); m_targetEntity = battleSys.FindEntityByID(attackCom.TargetID); if (null == m_targetEntity) { //back to idle StateTransite((int)E_RoleState.Idle); return; } //look at target var targetRenderer = m_targetEntity.GetComponent <CRenderCom>(); //m_moveGobj.transform.LookAt(targetRenderer.GameObject.transform); SetLookAt(m_moveGobj.transform, targetRenderer.GameObject.transform); var animCom = this.Entity.GetComponent <CAnimCom>(); animCom.ForcePlayAnim(E_AnimatorState.walk); }
public override void OnEnterState() { base.OnEnterState(); mBattleSys = CBattleEntityMgr.Instance.GetSystem <CBattleEntitySys>(); m_attriCom = Entity.GetComponent <CAttributeCom>(); m_animCom = Entity.GetComponent <CAnimCom>(); m_attackCom = Entity.GetComponent <CAttackCom>(); m_attackInterval = 1f; m_timer = 0f; AttackAction(); }
public void CreateATestEntity(E_BattleGroupType battleGroup) { var attrCom = new CAttributeCom() { Config = new RoleConfig() { Name = "soldier01", AssetName = "black01" } }; attrCom.BattleGroupType = battleGroup; attrCom.ID = ++s_EntityID; attrCom.Config.Name = string.Format("{0}_{1}", attrCom.Config.Name, s_EntityID); var t = typeof(E_AttributeType); foreach (E_AttributeType key in System.Enum.GetValues(t)) { attrCom.SetAttr(key, (uint)UnityEngine.Random.Range(5, 20)); } uint hp = attrCom.GetAttr(E_AttributeType.MaxHp); attrCom.SetAttr(E_AttributeType.CurrentHp, hp); attrCom.SetAttr(E_AttributeType.MoveSpeed, 20); attrCom.Hp = (int)hp; var fsmCom = new CFsmCom(); new CRoleBorn(fsmCom.FsmMgr); new CIdleState(fsmCom.FsmMgr); new CWalkState(fsmCom.FsmMgr); new CAttackState(fsmCom.FsmMgr); new CDeadState(fsmCom.FsmMgr); var attackCom = new CAttackCom(); var transCom = new CTransCom(); var animCom = new CAnimCom(); var entity = CEngine.Instance.CreateEntity(new System.Collections.Generic.List <AComponent> { attrCom, transCom, new CRenderCom(), new CEntityTypeCom() { EntityType = E_EntityType.Role }, fsmCom, attackCom, animCom }); CLog.Log(SysLogType.Battle, "创建角色:{0}, hp = {1}", attrCom.ID, hp); CEngine.Instance.AddEntity(entity); fsmCom.FsmMgr.SetCurrentState((int)E_RoleState.Born); }
public override void OnEnterState() { base.OnEnterState(); m_attirCom = this.Entity.GetComponent <CAttributeCom>(); var animCom = this.Entity.GetComponent <CAnimCom>(); animCom.ForcePlayAnim(E_AnimatorState.walk); //find a target // SearchTarget(); m_timer = 0f; }