IsInCd() публичный Метод

public IsInCd ( long now ) : bool
now long
Результат bool
        public bool CastSkill(int objId, int skillId)
        {
            bool       ret = false;
            EntityInfo obj = GetEntityById(objId);

            if (null != obj)
            {
                SkillInfo skillInfo = obj.GetSkillStateInfo().GetSkillInfoById(skillId);
                if (null != skillInfo)
                {
                    if (!skillInfo.IsInCd(TimeUtility.GetLocalMilliseconds()))
                    {
                        int targetId = 0;
                        if (null != SelectedTarget)
                        {
                            targetId = SelectedTarget.TargetId;
                        }
                        if (!IsBattleState)
                        {
                            Network.NetworkSystem.Instance.SyncPlayerSkill(obj, skillId, targetId, obj.GetMovementStateInfo().GetFaceDir());
                        }
                        else
                        {
                            AiStateInfo aiInfo = obj.GetAiStateInfo();
                            aiInfo.Target = targetId;
                            GfxSkillSystem.Instance.StartSkill(objId, skillInfo.ConfigData, 0);
                        }
                        ret = true;
                    }
                }
            }
            return(ret);
        }
Пример #2
0
        private void OnAiSkill(EntityInfo npc, int skillId)
        {
            Scene scene = npc.SceneContext.CustomData as Scene;

            if (null != scene)
            {
                SkillInfo skillInfo = npc.GetSkillStateInfo().GetCurSkillInfo();
                if (null == skillInfo || !skillInfo.IsSkillActivated)
                {
                    SkillInfo curSkillInfo = npc.GetSkillStateInfo().GetSkillInfoById(skillId);
                    if (null != curSkillInfo)
                    {
                        long curTime = TimeUtility.GetLocalMilliseconds();
                        if (!curSkillInfo.IsInCd(curTime))
                        {
                            if (scene.SkillSystem.StartSkill(npc.GetId(), curSkillInfo.ConfigData, 0))
                            {
                                Msg_RC_NpcSkill skillBuilder = DataSyncUtility.BuildNpcSkillMessage(npc, skillId);

                                LogSystem.Info("Send Msg_RC_NpcSkill, EntityId={0}, SkillId={1}",
                                               npc.GetId(), skillId);
                                scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcSkill, skillBuilder);
                            }
                        }
                    }
                }
            }
        }
        internal static SkillInfo NpcFindCanUseSkill(EntityInfo npc, AiData_General aidata, bool includeManualSkill)
        {
            SkillInfo      selectSkill = null;
            SkillStateInfo skStateInfo = npc.GetSkillStateInfo();
            int            priority    = -1;
            SkillInfo      skInfo      = null;
            long           curTime     = TimeUtility.GetLocalMilliseconds();

            if (includeManualSkill && npc.ManualSkillId > 0)
            {
                skInfo = skStateInfo.GetSkillInfoById(npc.ManualSkillId);
                if (null != skInfo && !skInfo.IsInCd(curTime))
                {
                    selectSkill = skInfo;
                }
            }
            if (null == selectSkill)
            {
                if (npc.AutoSkillIds.Count <= 0)
                {
                    return(null);
                }
                int randIndex = Helper.Random.Next(0, npc.AutoSkillIds.Count);
                skInfo = skStateInfo.GetSkillInfoById(npc.AutoSkillIds[randIndex]);
                if (null != skInfo && !skInfo.IsInCd(curTime))
                {
                    selectSkill = skInfo;
                }
                else
                {
                    for (int i = 0; i < npc.AutoSkillIds.Count; i++)
                    {
                        skInfo = skStateInfo.GetSkillInfoById(npc.AutoSkillIds[i]);
                        if (null != skInfo && !skInfo.IsInCd(curTime) && skInfo.InterruptPriority > priority)
                        {
                            selectSkill = skInfo;
                            priority    = skInfo.InterruptPriority;
                        }
                    }
                }
            }
            if (null != selectSkill)
            {
                aidata.LastUseSkillTime = TimeUtility.GetLocalMilliseconds();
            }
            return(selectSkill);
        }
        public bool CastSkill(int objId, int skillId)
        {
            bool       ret = false;
            EntityInfo obj = GetEntityById(objId);

            if (null != obj)
            {
                SkillInfo skillInfo = obj.GetSkillStateInfo().GetSkillInfoById(skillId);
                if (null != skillInfo)
                {
                    if (obj.Energy >= obj.GetActualProperty().EnergyMax)
                    {
                        if (!skillInfo.IsInCd(TimeUtility.GetLocalMilliseconds()))
                        {
                            int targetId = 0;
                            if (null != SelectedTarget)
                            {
                                targetId = SelectedTarget.TargetId;
                            }
                            if (IsRoomScene)
                            {
                                Network.NetworkSystem.Instance.SyncPlayerSkill(obj, skillId, targetId, obj.GetMovementStateInfo().GetFaceDir());
                            }
                            else
                            {
                                AiStateInfo aiInfo = obj.GetAiStateInfo();
                                aiInfo.Target = targetId;
                                if (aiInfo.AiLogic == (int)AiStateLogicId.Entity_Leader)
                                {
                                    AiData_Leader data = aiInfo.AiDatas.GetData <AiData_Leader>();
                                    if (null == data)
                                    {
                                        data = new AiData_Leader();
                                        aiInfo.AiDatas.AddData(data);
                                    }
                                    data.ManualSkillId = skillId;
                                }
                                else
                                {
                                    AiData_General data = aiInfo.AiDatas.GetData <AiData_General>();
                                    if (null == data)
                                    {
                                        data = new AiData_General();
                                        aiInfo.AiDatas.AddData(data);
                                    }
                                    data.ManualSkillId = skillId;
                                }
                                aiInfo.ChangeToState((int)AiStateId.SkillCommand);
                            }
                            ret = true;
                        }
                    }
                }
            }
            return(ret);
        }
 static public int IsInCd(IntPtr l)
 {
     try {
         GameFramework.SkillInfo self = (GameFramework.SkillInfo)checkSelf(l);
         System.Int64            a1;
         checkType(l, 2, out a1);
         var ret = self.IsInCd(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }