Ejemplo n.º 1
0
    public void TryPlaySkill(int id,Ilife user,Ilife lockedTarget = null)
    {
        SkillConfig config = ConfigManager.Instance.GetSkillConfig(id);
        if (null == config)
        {
            Debuger.Log("can't load skill id: " + id);
            return;
        }

        //check cd
        SkillCd cd = null;
        if (m_CdStore.TryGetValue(id, out cd))
        {
            if (cd.cd > 0)
            {
                // can't play skill 
                return;
            }
        }

        if (m_BeginCdStore.TryGetValue(id, out cd))
        {
            if (cd.cd > 0)
            {
                // can't play skill 
                return;
            }
        }

        if (m_PlayingSkill.ContainsKey(id))
        {
            //can't play
            return;
        }

        //per handle
        HandleTarget target = HandleTarget.GetHandleTarget(user);
        if (LimitMethods.HandleLimitExec(target, config.PerLimitId, null))
        {
            FuncMethods.HandleFuncExec(target, config.PerFuncId, null);

            m_LockedTargetList.Add(id, lockedTarget);

            if (config.BeginCd <= 0)
            {
                TriggerExecSkill(user, config);
            }
            else
            {
                if (m_BeginCdStore.ContainsKey(config.Id))
                {
                    m_BeginCdStore.Add(config.Id, new SkillCd(config.InitCd, config, user));
                }
                else
                {
                    m_BeginCdStore[config.Id] = new SkillCd(config.InitCd, config, user);
                }
            }
        }
    }
    public override List <Ilife> GetTargetList(Ilife thisUnit, TargetData data, FuncContext context)
    {
        List <Ilife> res = new List <Ilife>();

        if (thisUnit == null)
        {
            return(res);
        }
        Vector3 point    = ((ITransformBehaviour)(thisUnit)).GetTransformData().GetPosition();
        float   r        = ((ITransformBehaviour)(thisUnit)).GetTransformData().GetScale().x;
        var     lifeList = LifeManager.GetLifeList();

        foreach (var elem in lifeList)
        {
            if (elem.Key == thisUnit.GetInstanceId())
            {
                continue;
            }
            Ilife   otherLifes = elem.Value;
            Vector3 point1     = ((ITransformBehaviour)(otherLifes)).GetTransformData().GetPosition();
            if (Vector3.Distance(point, point1) < r)
            {
                // add to target list
                res.Add(otherLifes);
            }
        }
        return(res);
    }
Ejemplo n.º 3
0
    virtual public void Initialize(Ilife lifeData, string resourcePath, AssetType resourceType)
    {
        m_LifeData    = lifeData;
        m_iInstanceId = lifeData.GetInstanceId();

        m_ObjectInstance = GameObject.Instantiate(ResourceManager.Instance.LoadBuildInResource <GameObject>(resourcePath, resourceType));

        //load material
        string localpath = resourcePath.Substring(0, resourcePath.LastIndexOf('/'));

        m_NormalMaterial    = ResourceManager.Instance.LoadBuildInResource <Material>(localpath + "/Normal", AssetType.Char);
        m_HighlightMaterial = ResourceManager.Instance.LoadBuildInResource <Material>(localpath + "/SelectedHighlight", AssetType.Char);
        m_MeshRender        = ComponentTool.FindChildComponent <SkinnedMeshRenderer>("Body", m_ObjectInstance);
        if (null == m_NormalMaterial || null == m_HighlightMaterial || null == m_MeshRender)
        {
            Debuger.LogWarning("can't load mesh render or normal&highlight materials !");
        }

        //mark transform
        m_CharContainer = m_ObjectInstance.AddComponent <CharTransformContainer>();
        m_CharContainer.Initialize(lifeData.GetInstanceId(), lifeData);

        if (null == m_ObjectInstance)
        {
            Debuger.LogError("Can't load resource " + resourcePath);
        }
        m_AnimatorAgent = new AnimatorAgent(m_ObjectInstance);
    }
Ejemplo n.º 4
0
    virtual public void Initialize(Ilife lifeData, string resourcePath, AssetType resourceType)
    {
        m_LifeData = lifeData;
        m_iInstanceId = lifeData.GetInstanceId();

        m_ObjectInstance = GameObject.Instantiate(ResourceManager.Instance.LoadBuildInResource<GameObject>(resourcePath, resourceType));

        //load material
        string localpath = resourcePath.Substring(0, resourcePath.LastIndexOf('/'));
        m_NormalMaterial = ResourceManager.Instance.LoadBuildInResource<Material>(localpath + "/Normal", AssetType.Char);
        m_HighlightMaterial = ResourceManager.Instance.LoadBuildInResource<Material>(localpath + "/SelectedHighlight", AssetType.Char);
        m_MeshRender = ComponentTool.FindChildComponent<SkinnedMeshRenderer>("Body", m_ObjectInstance);
        if (null == m_NormalMaterial || null == m_HighlightMaterial || null == m_MeshRender)
        {
            Debuger.LogWarning("can't load mesh render or normal&highlight materials !");
        }

        //mark transform
        m_CharContainer = m_ObjectInstance.AddComponent<CharTransformContainer>();
        m_CharContainer.Initialize(lifeData.GetInstanceId(), lifeData);

        if (null == m_ObjectInstance)
        {
            Debuger.LogError("Can't load resource " + resourcePath);
        }
        m_AnimatorAgent = new AnimatorAgent(m_ObjectInstance);
    }
Ejemplo n.º 5
0
 public StateMachine(int uid, int registerClientMsgId, Ilife lifeInstance)
 {
     m_lifeInstance     = lifeInstance;
     m_nCurrentListenId = registerClientMsgId;
     MessageDispatcher.Instance.RegistMessage(registerClientMsgId, OnTriggerChangeState);
     //m_CurrentCharStateConflictMap = ConfigManager.Instance.GetStateConflicMap(uid);
 }
    public override List<Ilife> GetTargetList(Ilife thisUnit, TargetData data, FuncContext context)
    {
        List<Ilife> res = new List<Ilife>();

        if (thisUnit == null)
        {
            return res;
        }
        Vector3 point = ((ITransformBehaviour) (thisUnit)).GetTransformData().GetPosition();
        float r = ((ITransformBehaviour)(thisUnit)).GetTransformData().GetScale().x;
        var lifeList = LifeManager.GetLifeList();
        foreach (var elem in lifeList)
        {
            if (elem.Key == thisUnit.GetInstanceId())
            {
                continue;
            }
           Ilife otherLifes = elem.Value;
           Vector3 point1 = ((ITransformBehaviour)(otherLifes)).GetTransformData().GetPosition();
           if (Vector3.Distance(point, point1) < r)
           {
               // add to target list
               res.Add(otherLifes);
           }
        }
        return res;
    }
Ejemplo n.º 7
0
        public override EBTState Tick()
        {
            EBTState res;

            do
            {
                Ilife Owner = m_Database.GetData <Ilife>(EDataBaseKey.Owner);
                if (null == Owner)
                {
                    res = EBTState.False;
                    break;
                }
                HandleTarget handleTarget = HandleTarget.GetHandleTarget(Owner);
                if (LimitMethods.HandleLimitExec(handleTarget, m_iLimitId, null))
                {
                    res = EBTState.True;
                    break;
                }
                res = EBTState.False;
            } while (false);

            //mark current status
            CurrentStatus = res;

            return(res);
        }
Ejemplo n.º 8
0
 public StateMachine(int uid,int registerClientMsgId,Ilife lifeInstance )
 {
     m_lifeInstance = lifeInstance;
     m_nCurrentListenId = registerClientMsgId;
     MessageDispatcher.Instance.RegistMessage(registerClientMsgId, OnTriggerChangeState);
     //m_CurrentCharStateConflictMap = ConfigManager.Instance.GetStateConflicMap(uid);
 }
Ejemplo n.º 9
0
    protected override void OnPlay()
    {
        GameObject obj = null;

        switch (m_Config.EntityType)
        {
        case EntityType.Camera:
            obj = GlobalScripts.Instance.mGameCamera.transform.parent.gameObject;
            break;

        case EntityType.Npc:
            Ilife npc = LifeManager.GetLife(m_Config.CharId);
            if (null == npc || (!(npc is Npc)))
            {
                Debuger.LogError("EntityPlayanim : can't load npc by id " + m_Config.CharId);
                return;
            }
            obj = ((CharTransformData)((Npc)(npc)).GetTransformData()).GetGameObject();
            break;

        case EntityType.Player:
            if (null == PlayerManager.Instance.GetPlayerInstance())
            {
                Debuger.LogError("EntityPlayanim : can't load npc by id " + m_Config.CharId);
                return;
            }
            obj =
                ((CharTransformData)(PlayerManager.Instance.GetPlayerInstance().GetTransformData())).GetGameObject();
            break;
        }
        Animation desAnim = obj.GetComponent <Animation>();

        if (null == desAnim)
        {
            desAnim = obj.AddComponent <Animation>();
        }
        GameObject animsource = ResourceManager.Instance.LoadBuildInResource <GameObject>("AnimationStore", AssetType.Animation);

        if (null == animsource)
        {
            Debuger.LogError("EntityPlayanim : can't load animation source store");
            return;
        }
        Animation sourceAnim = animsource.GetComponent <Animation>();

        if (null == sourceAnim)
        {
            Debuger.LogError("EntityPlayanim : can't load animation source store");
            return;
        }
        AnimationClip clip = sourceAnim.GetClip(m_Config.AnimName);

        if (null == clip)
        {
            Debuger.LogError("EntityPlayanim : can't load target clip on source anim store");
            return;
        }
        desAnim.clip = clip;
        desAnim.Play();
    }
    private void OnTrigger()
    {
        //try get target
        var param = m_ActionPlayer.GetActionParam();

        if (null != param && null != param.Object && param.Object is FuncContext)
        {
            FuncContext context = param.Object as FuncContext;

            Ilife userInstance = context.Get(FuncContext.ContextKey.Target) as Ilife;
            if (null == userInstance)
            {
                return;
            }
            m_TargetObj  = ((CharTransformData)(((ITransformBehaviour)(userInstance)).GetTransformData())).GetGameObject();
            m_EffectObj  = EffectContainer.GetInstance(uint.Parse(m_FrameConfig.InstanceId));
            m_vTargetPos = m_TargetObj.transform.position;
            m_fLeftTime  = (float)(m_FrameConfig.Time);
            m_fHigh      = (float)(m_FrameConfig.High);

            m_fInitTime = TimeManager.Instance.GetTime();
            m_fLastTime = m_fInitTime;
            m_fLastVx   = Vector3.Distance(m_EffectObj.transform.position, m_vTargetPos) / m_fLeftTime;
            m_fLastVy   = (float)(0.5f * 9.8 * m_fLeftTime);
            m_vInitPos  = m_EffectObj.transform.position;
            m_vDir      = m_vTargetPos - m_vInitPos;

            m_vDeltaSpace.Normalize();

            m_bIsRunning = true;
        }
    }
Ejemplo n.º 11
0
    public static  HandleTarget GetHandleTarget(Ilife userTarget, List<Ilife> targetList)
    {
        HandleTarget instance = new HandleTarget();
        instance.m_lstUser.Add(userTarget);
        instance.m_lstTarget = targetList;

        return instance;
    }
Ejemplo n.º 12
0
    public static HandleTarget GetHandleTarget(Ilife userTarget, List <Ilife> targetList)
    {
        HandleTarget instance = new HandleTarget();

        instance.m_lstUser.Add(userTarget);
        instance.m_lstTarget = targetList;

        return(instance);
    }
Ejemplo n.º 13
0
    public static Ilife GetLife(int id)
    {
        Ilife elem = null;

        if (!m_LifeMap.TryGetValue(id, out elem))
        {
            return(null);
        }
        return(elem);
    }
Ejemplo n.º 14
0
 public static void RegisterLife(int id, Ilife life)
 {
     if (m_LifeMap.ContainsKey(id))
     {
         m_LifeMap[id] = life;
     }
     else
     {
         m_LifeMap.Add(id, life);
     }
 }
Ejemplo n.º 15
0
 public static void RegisterLife(int id, Ilife life)
 {
     if (m_LifeMap.ContainsKey(id))
     {
         m_LifeMap[id] = life;
     }
     else
     {
         m_LifeMap.Add(id, life);
     }
 }
Ejemplo n.º 16
0
    private void OnTrigger()
    {
        if (m_FrameConfig.IsAttach)
        {
            // try get attach obj
            GameObject obj = null;
            switch (m_FrameConfig.EntityType)
            {
            case EntityType.Camera:
                obj = GlobalScripts.Instance.mGameCamera.transform.parent.gameObject;
                break;

            case EntityType.Npc:
                Ilife npc = LifeManager.GetLife(m_FrameConfig.AttachNpcId);
                if (null == npc || (!(npc is Npc)))
                {
                    Debuger.LogError("Play audio : can't load npc by id " + m_FrameConfig.AttachNpcId);
                    return;
                }
                obj = ((CharTransformData)((Npc)(npc)).GetTransformData()).GetGameObject();
                break;

            case EntityType.Player:
                if (null == PlayerManager.Instance.GetPlayerInstance())
                {
                    Debuger.LogError("Play audio : can't load player");
                    return;
                }
                obj =
                    ((CharTransformData)(PlayerManager.Instance.GetPlayerInstance().GetTransformData())).GetGameObject();
                break;
            }
            var objInstance = CreateEffect();
            if (null == objInstance)
            {
                return;
            }
            var root = GetAttachPoint(obj);

            objInstance.transform.parent           = root == null ? null: root.transform;
            objInstance.transform.localPosition    = m_FrameConfig.Pos.GetVector3();
            objInstance.transform.localEulerAngles = m_FrameConfig.Rot.GetVector3();
        }
        else
        {
            var objInstance = CreateEffect();
            if (null == objInstance)
            {
                return;
            }
            objInstance.transform.position    = m_FrameConfig.Pos.GetVector3();
            objInstance.transform.eulerAngles = m_FrameConfig.Rot.GetVector3();
        }
    }
Ejemplo n.º 17
0
    public static HandleTarget GetHandleTarget(Ilife userTarget, params Ilife[] targetList)
    {
        HandleTarget instance = new HandleTarget();
        instance.m_lstUser.Add(userTarget);
        if (null != targetList)
        {
            foreach (Ilife Child in targetList)
            {
                instance.m_lstTarget.Add(Child);
            }
        }

        return instance;
    }
Ejemplo n.º 18
0
 public override EFuncRet FuncExecHandler(HandleTarget Target, FuncData funcdata, FuncContext context)
 {
     List<Ilife> target = Target.GetTarget((EFuncTarget) (funcdata.Target));
     for (int i = 0; i < target.Count; ++i)
     {
         Ilife elem = target[i];
         if (!(elem is PlayerCharacter))
         {
             continue;
         }
         bool newValue = funcdata.ParamIntList[1] != 0;
         PlayerManager.Instance.GetCharCounterData().SetFlag(funcdata.ParamIntList[0], newValue);
     }
     return EFuncRet.Continue;
 }
Ejemplo n.º 19
0
        protected override EBTState OnEnter()
        {
            Debuger.Log("enter move to player");
            Ilife owner = m_Database.GetData <Ilife>(EDataBaseKey.Owner);

            if (null == owner)
            {
                return(EBTState.False);
            }

            m_TargetNpc = (Npc)(owner);
            m_TargetNpc.MoveTo(PlayerManager.Instance.GetPlayerInstance().GetFollowPoint(m_iFollowPintId).transform.position);
            m_fDeltaTime = 0.0f;
            return(EBTState.Running);
        }
Ejemplo n.º 20
0
    private static IState CreateStateInstance(ELifeState stateId, Ilife unit)
    {
        if (null == m_StateFactory)
        {
            StateDefine.RegisterState();
        }
        IState result = null;
        Type   type   = null;

        if (m_StateFactory.TryGetValue(stateId, out type))
        {
            result = Activator.CreateInstance(type, unit, stateId) as IState;
        }
        return(result);
    }
Ejemplo n.º 21
0
    public static HandleTarget GetHandleTarget(Ilife userTarget, params Ilife[] targetList)
    {
        HandleTarget instance = new HandleTarget();

        instance.m_lstUser.Add(userTarget);
        if (null != targetList)
        {
            foreach (Ilife Child in targetList)
            {
                instance.m_lstTarget.Add(Child);
            }
        }

        return(instance);
    }
Ejemplo n.º 22
0
    public override EFuncRet FuncExecHandler(HandleTarget Target, FuncData funcdata, FuncContext context)
    {
        List <Ilife> target = Target.GetTarget((EFuncTarget)(funcdata.Target));

        for (int i = 0; i < target.Count; ++i)
        {
            Ilife elem = target[i];
            if (!(elem is PlayerCharacter))
            {
                continue;
            }
            sbyte newValue = 0;
            OperationFunc.FuncOperatorValue((EFuncOperator)(funcdata.Oper), ref newValue, (sbyte)(funcdata.ParamIntList[1]));
            PlayerManager.Instance.GetCharCounterData().SetBit8Count(funcdata.ParamIntList[0], newValue);
        }
        return(EFuncRet.Continue);
    }
Ejemplo n.º 23
0
        protected override EBTState OnEnter()
        {
            Ilife owner = m_Database.GetData <Ilife>(EDataBaseKey.Owner);

            if (null == owner)
            {
                return(EBTState.False);
            }

            IStateMachineBehaviour state = (IStateMachineBehaviour)(owner);

            if (!state.GetStateController().TryEnterState(ELifeState.Idle, false))
            {
                return(EBTState.False);
            }

            return(EBTState.True);
        }
Ejemplo n.º 24
0
        //
        public void Active(bool bActive, Ilife Owner)
        {
            if (null == m_Root)
            {
                return;
            }

            if (bActive)
            {
                m_Root.Active(new BTDatabase());
                m_Root.Database.SetData <Ilife>(EDataBaseKey.Owner, Owner);
                m_Root.Database.SetData <bool>(EDataBaseKey.IsLock, false);
            }
            else
            {
                m_Root.active = false;
            }
        }
Ejemplo n.º 25
0
		//
		public void Active( bool bActive, Ilife Owner )
		{
			if( null == m_Root )
			{
				return;
			}

			if( bActive )
			{
				m_Root.Active( new BTDatabase() );
                m_Root.Database.SetData<Ilife>(EDataBaseKey.Owner, Owner);
                m_Root.Database.SetData<bool>(EDataBaseKey.IsLock, false);
			}
			else
			{
				m_Root.active = false;
			}
		}
Ejemplo n.º 26
0
    protected override void Execute()
    {
        if (m_FrameConfig.IsAttach)
        {
            // try get attach obj
            GameObject obj = null;
            switch (m_FrameConfig.EntityType)
            {
            case EntityType.Camera:
                obj = GlobalScripts.Instance.mGameCamera.transform.parent.gameObject;
                break;

            case EntityType.Npc:
                Ilife npc = LifeManager.GetLife(m_FrameConfig.AttachNpcId);
                if (null == npc || (!(npc is Npc)))
                {
                    Debuger.LogError("Play audio : can't load npc by id " + m_FrameConfig.AttachNpcId);
                    return;
                }
                obj = ((CharTransformData)((Npc)(npc)).GetTransformData()).GetGameObject();
                break;

            case EntityType.Player:
                if (null == PlayerManager.Instance.GetPlayerInstance())
                {
                    Debuger.LogError("Play audio : can't load player");
                    return;
                }
                obj =
                    ((CharTransformData)(PlayerManager.Instance.GetPlayerInstance().GetTransformData())).GetGameObject();
                break;
            }
            AudioPlayer.Instance.PlayAudio(m_FrameConfig.AudioSource, obj.transform, m_FrameConfig.IsLoop);
        }
        else
        {
            AudioPlayer.Instance.PlayAudio(m_FrameConfig.AudioSource, m_FrameConfig.PlayPosition.GetVector3(),
                                           m_FrameConfig.IsLoop);
        }
    }
Ejemplo n.º 27
0
    private void TriggerExecSkill(Ilife user, SkillConfig config)
    {
        bool isLockedTarget = m_LockedTargetList.ContainsKey(config.Id) && m_LockedTargetList[config.Id] != null;

        //add to playing list
        m_PlayingSkill.Add(config.Id, config);

        // play animation
        FuncContext context = FuncContext.Create();

        if (!isLockedTarget)
        {
            context.Put(FuncContext.ContextKey.TargetId, config.TargeteId);
        }
        else
        {
            context.Put(FuncContext.ContextKey.Target, m_LockedTargetList[config.Id]);
        }

        context.Put(FuncContext.ContextKey.User, user);
        context.Put(FuncContext.ContextKey.LimitId, config.LimitId);
        context.Put(FuncContext.ContextKey.FunctionId, config.FuncId);

        ActionParam param = new ActionParam();

        param.Id     = config.Id;
        param.Object = context;

        ActionManager.Instance.PlayAction(config.ActionId, param);

        if (m_CdStore.ContainsKey(config.Id))
        {
            m_CdStore.Add(config.Id, new SkillCd(config.InitCd));
        }
        else
        {
            m_CdStore[config.Id] = new SkillCd(config.InitCd);
        }
    }
    private void OnTrigger()
    {
        //try get target
        var param = m_ActionPlayer.GetActionParam();

        if (null != param && null != param.Object && param.Object is FuncContext)
        {
            FuncContext context = param.Object as FuncContext;
            if (!context.ContainsKey(FuncContext.ContextKey.LimitId) ||
                !context.ContainsKey(FuncContext.ContextKey.FunctionId))
            {
                return;
            }

            int          limitId = (int)(context.Get(FuncContext.ContextKey.LimitId));
            int          funcId  = (int)(context.Get(FuncContext.ContextKey.LimitId));
            HandleTarget target  = null;
            Ilife        user    = context.Get(FuncContext.ContextKey.User) as Ilife;
            if (context.ContainsKey(FuncContext.ContextKey.Target))
            {
                //locked skill
                target = HandleTarget.GetHandleTarget(user, context.Get(FuncContext.ContextKey.Target) as Ilife);
            }
            else
            {
                //target is null,unlocked skill
                int targetId = (int)(context.Get(FuncContext.ContextKey.TargetId));
                target = TargetMethods.GetTargetList(user, targetId, null);
            }

            //exec attack
            if (LimitMethods.HandleLimitExec(target, limitId, null))
            {
                FuncMethods.HandleFuncExec(target, funcId, null);
            }
        }
    }
Ejemplo n.º 29
0
    public static HandleTarget GetTargetList(Ilife srcLife, int iTargetGroupId, FuncContext context)
    {
        HandleTarget handle = HandleTarget.GetHandleTarget(srcLife);

        if (iTargetGroupId == 0)
        {
            return(handle);
        }

        TargetGroup targetGroup = ConfigManager.Instance.GetTargetGroup(iTargetGroupId);

        if (null == targetGroup)
        {
            Debug.LogError("target groupId:" + iTargetGroupId + " is not found.");
            return(handle);
        }
        if (null == targetGroup.TargetDataList || 0 == targetGroup.TargetDataList.Count)
        {
            Debug.LogError("target groupId:" + iTargetGroupId + " targetDataList is null.");
            return(handle);
        }
        TargetMethodBase handler = null;

        foreach (TargetData data in targetGroup.TargetDataList)
        {
            if (!TargetExec.TryGetValue(data.TargetId, out handler))
            {
                continue;
            }

            List <Ilife> targetUnitList = handler.GetTargetList(srcLife, data, context);
            handle.AddTarget(targetUnitList);
        }

        return(handle);
    }
Ejemplo n.º 30
0
    private void TriggerExecSkill(Ilife user,SkillConfig config)
    {
        bool isLockedTarget = m_LockedTargetList.ContainsKey(config.Id) && m_LockedTargetList[config.Id] != null;

        //add to playing list
        m_PlayingSkill.Add(config.Id, config);
        
        // play animation
        FuncContext context = FuncContext.Create();
        if (!isLockedTarget)
        {
            context.Put(FuncContext.ContextKey.TargetId, config.TargeteId);
        }
        else
        {
            context.Put(FuncContext.ContextKey.Target, m_LockedTargetList[config.Id]);
        }

        context.Put(FuncContext.ContextKey.User, user);
        context.Put(FuncContext.ContextKey.LimitId, config.LimitId);
        context.Put(FuncContext.ContextKey.FunctionId, config.FuncId);

        ActionParam param = new ActionParam();
        param.Id = config.Id;
        param.Object = context;

        ActionManager.Instance.PlayAction(config.ActionId, param);

        if (m_CdStore.ContainsKey(config.Id))
        {
            m_CdStore.Add(config.Id, new SkillCd(config.InitCd));
        }
        else
        {
            m_CdStore[config.Id] = new SkillCd(config.InitCd);
        }
    }
Ejemplo n.º 31
0
 public SkillCd(int cd,SkillConfig config,Ilife user)
 {
     this.cd = cd;
     this.config = config;
     this.user = user;
 }
Ejemplo n.º 32
0
 public IState(Ilife unit, ELifeState state)
 {
     this.unit  = unit;
     this.state = state;
 }
Ejemplo n.º 33
0
 private static IState CreateStateInstance(ELifeState stateId, Ilife unit)
 {
     if (null == m_StateFactory)
     {
         StateDefine.RegisterState();
     }
     IState result = null;
     Type type = null;
     if (m_StateFactory.TryGetValue(stateId, out type))
     {
         result = Activator.CreateInstance(type, unit,stateId) as IState;
     }
     return result;
 }
Ejemplo n.º 34
0
    public void TryPlaySkill(int id, Ilife user, Ilife lockedTarget = null)
    {
        SkillConfig config = ConfigManager.Instance.GetSkillConfig(id);

        if (null == config)
        {
            Debuger.Log("can't load skill id: " + id);
            return;
        }

        //check cd
        SkillCd cd = null;

        if (m_CdStore.TryGetValue(id, out cd))
        {
            if (cd.cd > 0)
            {
                // can't play skill
                return;
            }
        }

        if (m_BeginCdStore.TryGetValue(id, out cd))
        {
            if (cd.cd > 0)
            {
                // can't play skill
                return;
            }
        }

        if (m_PlayingSkill.ContainsKey(id))
        {
            //can't play
            return;
        }

        //per handle
        HandleTarget target = HandleTarget.GetHandleTarget(user);

        if (LimitMethods.HandleLimitExec(target, config.PerLimitId, null))
        {
            FuncMethods.HandleFuncExec(target, config.PerFuncId, null);

            m_LockedTargetList.Add(id, lockedTarget);

            if (config.BeginCd <= 0)
            {
                TriggerExecSkill(user, config);
            }
            else
            {
                if (m_BeginCdStore.ContainsKey(config.Id))
                {
                    m_BeginCdStore.Add(config.Id, new SkillCd(config.InitCd, config, user));
                }
                else
                {
                    m_BeginCdStore[config.Id] = new SkillCd(config.InitCd, config, user);
                }
            }
        }
    }
Ejemplo n.º 35
0
    public IState(Ilife unit,ELifeState state)
	{
		this.unit = unit;
        this.state = state;
	}
Ejemplo n.º 36
0
 public StateIdle(Ilife unit, ELifeState state) : base(unit, state)
 {
 }
Ejemplo n.º 37
0
 public void Initialize(int id, Ilife data)
 {
     m_iId  = id;
     m_Data = data;
 }
Ejemplo n.º 38
0
 public StateMove(Ilife unit, ELifeState state)
     : base(unit, state)
 {
 }
Ejemplo n.º 39
0
 public StateRun(Ilife unit, ELifeState state)
     : base(unit, state)
 {
 }
 public void Initialize(int id, Ilife data)
 {
     m_iId = id;
     m_Data = data;
 }
Ejemplo n.º 41
0
    public static HandleTarget GetTargetList(Ilife srcLife, int iTargetGroupId, FuncContext context)
    {
        HandleTarget handle = HandleTarget.GetHandleTarget(srcLife);

        if (iTargetGroupId == 0)
        {
            return handle;
        }

        TargetGroup targetGroup =  ConfigManager.Instance.GetTargetGroup(iTargetGroupId);
        if (null == targetGroup)
        {
            Debug.LogError("target groupId:" + iTargetGroupId + " is not found.");
            return handle;
        }
        if (null == targetGroup.TargetDataList || 0 == targetGroup.TargetDataList.Count)
        {
            Debug.LogError("target groupId:" + iTargetGroupId + " targetDataList is null.");
            return handle;
        }
        TargetMethodBase handler = null;
        foreach (TargetData data in targetGroup.TargetDataList)
        {
            if (!TargetExec.TryGetValue(data.TargetId,out handler))
            {
                continue;
            }

            List<Ilife> targetUnitList = handler.GetTargetList(srcLife, data,context);
            handle.AddTarget(targetUnitList);
        }

        return handle;
    }
Ejemplo n.º 42
0
 public override List <Ilife> GetTargetList(Ilife thisUnit, TargetData data, FuncContext context)
 {
     return(null);
 }
Ejemplo n.º 43
0
 public abstract List<Ilife> GetTargetList(Ilife thisUnit, TargetData data, FuncContext context);
Ejemplo n.º 44
0
 public override List<Ilife> GetTargetList(Ilife thisUnit, TargetData data, FuncContext context)
 {
     return null;
 }
Ejemplo n.º 45
0
 public SkillCd(int cd, SkillConfig config, Ilife user)
 {
     this.cd     = cd;
     this.config = config;
     this.user   = user;
 }
Ejemplo n.º 46
0
 public abstract List <Ilife> GetTargetList(Ilife thisUnit, TargetData data, FuncContext context);
Ejemplo n.º 47
0
 public StateRun(Ilife unit, ELifeState state)
     : base(unit, state)
 {
 }