Esempio n. 1
0
        internal GfxSkillSenderInfo BuildSkillInfo(int objId, TableConfig.Skill configData, int seq, Scene scene)
        {
            GfxSkillSenderInfo ret    = null;
            EntityInfo         entity = m_Scene.EntityManager.GetEntityInfo(objId);

            if (null != entity && null != configData)
            {
                int targetId = 0;
                if (configData.type == (int)SkillOrImpactType.Skill)
                {
                    targetId = entity.GetAiStateInfo().Target;
                }
                else
                {
                    ImpactInfo impactInfo = entity.GetSkillStateInfo().GetImpactInfoBySeq(seq);
                    if (null != impactInfo)
                    {
                        targetId = impactInfo.ImpactSenderId;
                    }
                }
                EntityInfo targetObj = m_Scene.EntityManager.GetEntityInfo(targetId);
                if (null != targetObj)
                {
                    ret = new GfxSkillSenderInfo(configData, seq, objId, entity, targetId, targetObj, scene);
                }
                else
                {
                    ret = new GfxSkillSenderInfo(configData, seq, objId, entity, scene);
                }
            }
            return(ret);
        }
Esempio n. 2
0
        public GfxSkillSenderInfo BuildSkillInfo(int objId, TableConfig.Skill configData, int seq)
        {
            GfxSkillSenderInfo ret  = null;
            EntityViewModel    view = GetEntityViewById(objId);

            if (null != view && null != view.Actor && null != view.Entity && null != configData)
            {
                EntityInfo entity   = view.Entity;
                int        targetId = 0;
                if (configData.type == (int)SkillOrImpactType.Skill)
                {
                    targetId = entity.GetAiStateInfo().Target;
                }
                else
                {
                    ImpactInfo impactInfo = entity.GetSkillStateInfo().GetImpactInfoBySeq(seq);
                    if (null != impactInfo)
                    {
                        targetId = impactInfo.ImpactSenderId;
                    }
                }
                UnityEngine.GameObject targetObj = GetGameObject(targetId);
                if (null != targetObj)
                {
                    ret = new GfxSkillSenderInfo(configData, seq, objId, view.Actor, targetId, targetObj);
                }
                else
                {
                    ret = new GfxSkillSenderInfo(configData, seq, objId, view.Actor);
                }
            }
            return(ret);
        }
        public void DeactivateSkill(GfxSkillSenderInfo sender, SkillInstance instance)
        {
            int objId   = sender.ObjId;
            int skillId = sender.SkillId;
            int seq     = sender.Seq;

            if (objId <= 0)
            {
                return;
            }

            //LogSystem.Warn("{0} DeactivateSkill {1} {2}", objId, skillId, seq);

            EntityViewModel view = GetEntityViewById(objId);

            if (null != view && null != view.Entity)
            {
                SkillInfo skillInfo = view.Entity.GetSkillStateInfo().GetSkillInfoById(skillId);
                if (null != skillInfo)
                {
                    if (skillId == view.Entity.ManualSkillId)
                    {
                        LogSystem.Warn("ManualSkill {0} deactivate.", skillId);
                    }
                    skillInfo.IsSkillActivated    = false;
                    view.Entity.IsControlByManual = false;
                }
                else
                {
                    view.Entity.GetSkillStateInfo().RemoveImpact(seq);
                }
            }
        }
Esempio n. 4
0
        public void CalcSenderAndTarget(GfxSkillSenderInfo senderObj, out int senderId, out int targetId)
        {
            senderId = 0;
            targetId = 0;

            int targetType = GetTargetType(senderObj.ActorId, senderObj.ConfigData, senderObj.Seq);

            if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill)
            {
                senderId = senderObj.ActorId;
                targetId = senderObj.TargetActorId;
                if (targetType == (int)SkillTargetType.RandEnemy)
                {
                    targetId = GetRandEnemyId(GetCampId(senderId));
                }
                else if (targetType == (int)SkillTargetType.RandFriend)
                {
                    targetId = GetRandFriendId(GetCampId(senderId));
                }
                else if (targetType == (int)SkillTargetType.Friend)
                {
                    targetId = senderObj.ActorId;
                }
                else if (targetType == (int)SkillTargetType.Self)
                {
                    targetId = senderObj.ActorId;
                }
            }
            else
            {
                senderId = senderObj.TargetActorId;
                targetId = senderObj.ActorId;
                if (targetType == (int)SkillTargetType.RandEnemy)
                {
                    targetId = GetRandEnemyId(GetCampId(senderId));
                }
                else if (targetType == (int)SkillTargetType.RandFriend)
                {
                    targetId = GetRandFriendId(GetCampId(senderId));
                }
                else if (targetType == (int)SkillTargetType.Friend)
                {
                    targetId = senderObj.TargetActorId;
                }
                else if (targetType == (int)SkillTargetType.Self)
                {
                    targetId = senderObj.TargetActorId;
                }
            }
        }
        internal SkillInstance GetActiveSkillInfo(int index, out GfxSkillSenderInfo sender)
        {
            int ct = m_SkillLogicInfos.Count;

            if (index >= 0 && index < ct)
            {
                var info = m_SkillLogicInfos[index];
                sender = info.Sender;
                return(info.SkillInst);
            }
            else
            {
                sender = null;
                return(null);
            }
        }
        public void ActivateSkill(GfxSkillSenderInfo sender, SkillInstance instance)
        {
            int objId   = sender.ObjId;
            int skillId = sender.SkillId;
            int seq     = sender.Seq;

            if (objId <= 0)
            {
                return;
            }
            //LogSystem.Warn("{0} ActivateSkill {1} {2}", objId, skillId, seq);

            EntityViewModel view = GetEntityViewById(objId);

            if (null != view && null != view.Entity)
            {
                EntityInfo entity    = view.Entity;
                SkillInfo  skillInfo = entity.GetSkillStateInfo().GetSkillInfoById(skillId);
                if (null != skillInfo)
                {
                    SkillInfo curSkillInfo = entity.GetSkillStateInfo().GetCurSkillInfo();
                    if (null != curSkillInfo && (curSkillInfo.ConfigData.skillData.interruptPriority < skillInfo.ConfigData.skillData.interruptPriority))
                    {
                        GfxSkillSystem.Instance.StopSkill(objId, curSkillInfo.SkillId, 0, true);
                        if (skillId == view.Entity.ManualSkillId)
                        {
                            LogSystem.Warn("ManualSkill {0} interrupt {1}.", skillId, curSkillInfo.SkillId);
                        }
                    }
                    if (skillId == view.Entity.ManualSkillId)
                    {
                        LogSystem.Warn("ManualSkill {0} activate.", skillId);
                    }
                    entity.GetSkillStateInfo().SetCurSkillInfo(skillId);
                    skillInfo.IsSkillActivated = true;
                    skillInfo.CdEndTime        = TimeUtility.GetLocalMilliseconds() + (long)skillInfo.ConfigData.skillData.cooldown;
                    if (skillInfo.ConfigData.skillData.addsc > 0 && PluginFramework.Instance.IsBattleState)
                    {
                        //回蓝
                        entity.Energy += skillInfo.ConfigData.skillData.addsc;
                        entity.EntityManager.FireDamageEvent(objId, 0, false, false, 0, -skillInfo.ConfigData.skillData.addsc);
                    }
                }
            }
        }
        public bool IsLocalSkillEffect(GfxSkillSenderInfo info)
        {
            if (info.ObjId == m_LeaderId || info.TargetObjId == m_LeaderId)
            {
                return(true);
            }
            EntityInfo sender = GetEntityById(info.ObjId);

            if (null != sender && !sender.IsServerEntity)
            {
                return(true);
            }
            EntityInfo target = GetEntityById(info.TargetObjId);

            if (null != target && !target.IsServerEntity)
            {
                return(true);
            }
            return(false);
        }
        internal SkillInstance FindSkillInstanceForSkillViewer(int skillId, out GfxSkillSenderInfo sender)
        {
            SkillInstance  ret       = null;
            SkillLogicInfo logicInfo = m_SkillLogicInfos.Find(info => info.SkillId == skillId);

            if (null != logicInfo)
            {
                sender = logicInfo.Sender;
                ret    = logicInfo.SkillInst;
            }
            else
            {
                sender = null;
                var instInfo = GetUnusedSkillInstanceInfoFromPool(skillId);
                if (null != instInfo)
                {
                    ret = instInfo.m_SkillInstance;
                }
            }
            return(ret);
        }
        internal bool StartSkill(int actorId, TableConfig.Skill configData, int seq, params Dictionary <string, object>[] locals)
        {
            bool ret = false;

            if (null == configData)
            {
                LogSystem.Error("{0} can't cast skill, config is null !", actorId, seq);
                Helper.LogCallStack();
                return(false);
            }
            if (!m_Scene.EntityController.CanCastSkill(actorId, configData, seq))
            {
                m_Scene.EntityController.CancelCastSkill(actorId);
                LogSystem.Warn("{0} can't cast skill {1} {2}, cancel.", actorId, configData.id, seq);
                m_Scene.EntityController.CancelIfImpact(actorId, configData, seq);
                return(false);
            }
            GfxSkillSenderInfo senderInfo = m_Scene.EntityController.BuildSkillInfo(actorId, configData, seq, m_Scene);

            if (null != senderInfo && null != senderInfo.GfxObj)
            {
                int            skillId   = senderInfo.SkillId;
                EntityInfo     obj       = senderInfo.GfxObj;
                SkillLogicInfo logicInfo = m_SkillLogicInfos.Find(info => info.GfxObj == obj && info.SkillId == skillId && info.Seq == seq);
                if (logicInfo != null)
                {
                    LogSystem.Warn("{0} is casting skill {1} {2}, cancel.", actorId, skillId, seq);
                    m_Scene.EntityController.CancelIfImpact(actorId, configData, seq);
                    return(false);
                }
                SkillInstanceInfo inst          = null;
                SkillInstance     innerInstance = null;
                if (skillId == PredefinedSkill.c_EmitSkillId)
                {
                    for (int i = 0; i < locals.Length; ++i)
                    {
                        object instObj;
                        if (locals[i].TryGetValue("emitskill", out instObj))
                        {
                            innerInstance = instObj as SkillInstance;
                        }
                    }
                    if (null == innerInstance)
                    {
                        LogSystem.Warn("{0} use predefined skill {1} {2} but not found emitskill, cancel.", actorId, skillId, seq);
                        //m_Scene.EntityController.CancelIfImpact(actorId, configData, seq);
                        //return false;
                    }
                }
                else if (skillId == PredefinedSkill.c_HitSkillId)
                {
                    for (int i = 0; i < locals.Length; ++i)
                    {
                        object instObj;
                        if (locals[i].TryGetValue("hitskill", out instObj))
                        {
                            innerInstance = instObj as SkillInstance;
                        }
                    }
                    if (null == innerInstance)
                    {
                        LogSystem.Warn("{0} use predefined skill {1} {2} but not found hitskill, cancel.", actorId, skillId, seq);
                        //m_Scene.EntityController.CancelIfImpact(actorId, configData, seq);
                        //return false;
                    }
                }
                if (null == innerInstance)
                {
                    inst = NewSkillInstance(skillId, senderInfo.ConfigData);
                }
                else
                {
                    inst = NewInnerSkillInstance(skillId, innerInstance);
                }
                if (null != inst)
                {
                    m_SkillLogicInfos.Add(new SkillLogicInfo(senderInfo, inst));
                }
                else
                {
                    LogSystem.Warn("{0} cast skill {1} {2}, alloc failed.", actorId, skillId, seq);
                    m_Scene.EntityController.CancelIfImpact(actorId, configData, seq);
                    return(false);
                }

                logicInfo = m_SkillLogicInfos.Find(info => info.GfxObj == obj && info.SkillId == skillId && info.Seq == seq);
                if (null != logicInfo)
                {
                    if (null != locals)
                    {
                        int localCount = locals.Length;
                        for (int i = 0; i < localCount; ++i)
                        {
                            foreach (KeyValuePair <string, object> pair in locals[i])
                            {
                                logicInfo.SkillInst.SetVariable(pair.Key, pair.Value);
                            }
                        }
                    }
                    EntityInfo target = senderInfo.TargetGfxObj;
                    if (null != target && target != obj && configData.type == (int)SkillOrImpactType.Skill)
                    {
                        TriggerUtil.Lookat(m_Scene, obj, target.GetMovementStateInfo().GetPosition3D());
                    }
                    m_Scene.EntityController.ActivateSkill(actorId, skillId, seq);
                    logicInfo.SkillInst.Context = m_Scene;
                    logicInfo.SkillInst.Start(logicInfo.Sender);
                    ret = true;
                }
            }
            return(ret);
        }
        internal SkillInstance FindActiveSkillInstance(int actorId, int skillId, int seq, out GfxSkillSenderInfo sender)
        {
            SkillLogicInfo logicInfo = m_SkillLogicInfos.Find(info => info.ActorId == actorId && info.SkillId == skillId && info.Seq == seq);

            if (null != logicInfo)
            {
                sender = logicInfo.Sender;
                return(logicInfo.SkillInst);
            }
            sender = null;
            return(null);
        }
        internal SkillInstance FindInnerSkillInstanceForSkillViewer(int skillId, SkillInstance innerInstance, out GfxSkillSenderInfo sender)
        {
            SkillInstance  ret       = null;
            SkillLogicInfo logicInfo = m_SkillLogicInfos.Find(info => info.SkillId == skillId && info.SkillInst.InnerDslSkillId == innerInstance.InnerDslSkillId && info.SkillInst.OuterDslSkillId == innerInstance.OuterDslSkillId);

            if (null != logicInfo)
            {
                sender = logicInfo.Sender;
                ret    = logicInfo.SkillInst;
            }
            else
            {
                int newSkillId = CalcUniqueInnerSkillId(skillId, innerInstance);
                sender = null;
                var instInfo = GetUnusedSkillInstanceInfoFromPool(newSkillId);
                if (null != instInfo)
                {
                    ret = instInfo.m_SkillInstance;
                }
            }
            return(ret);
        }
 internal SkillLogicInfo(GfxSkillSenderInfo sender, SkillInstanceInfo info)
 {
     m_Sender    = sender;
     m_SkillInfo = info;
 }