Beispiel #1
0
 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();
 }
Beispiel #2
0
        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);
        }