private void OnImpactSkill(CharacterInfo sender, int skillId)
        {
            Scene scene = sender.SceneContext.CustomData as Scene;

            if (null != scene)
            {
                SkillInfo skillInfo = sender.GetSkillStateInfo().GetCurSkillInfo();
                if (null == skillInfo || !skillInfo.IsSkillActivated)
                {
                    scene.SkillSystem.StartSkill(sender.GetId(), skillId);

                    Msg_RC_NpcSkill skillBuilder = new Msg_RC_NpcSkill();
                    skillBuilder.npc_id   = sender.GetId();
                    skillBuilder.skill_id = skillId;
                    ArkCrossEngineMessage.Position posBuilder1 = new ArkCrossEngineMessage.Position();
                    posBuilder1.x               = sender.GetMovementStateInfo().GetPosition3D().X;
                    posBuilder1.z               = sender.GetMovementStateInfo().GetPosition3D().Z;
                    skillBuilder.stand_pos      = posBuilder1;
                    skillBuilder.face_direction = (float)sender.GetMovementStateInfo().GetFaceDir();

                    LogSystem.Debug("Send Msg_RC_NpcSkill, EntityId={0}, SkillId={1}",
                                    sender.GetId(), skillId);
                    scene.NotifyAreaUser(sender, skillBuilder);
                }
            }
        }
Exemple #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);
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
    internal static void Execute(object msg, NetConnection conn)
    {
        Msg_RC_NpcSkill targetmsg = msg as Msg_RC_NpcSkill;

        if (null == targetmsg)
        {
            return;
        }
        EntityInfo npc = PluginFramework.Instance.GetEntityById(targetmsg.npc_id);

        if (null == npc)
        {
            return;
        }
        float x = 0.0f;
        float z = 0.0f;

        ProtoHelper.DecodePosition2D(targetmsg.stand_pos, out x, out z);
        float faceDir = ProtoHelper.DecodeFloat(targetmsg.face_direction);
        int   skillId = targetmsg.skill_id;

        LogSystem.Info("Receive Msg_RC_NpcSkill, EntityId={0}, SkillId={1}", targetmsg.npc_id, skillId);

        MovementStateInfo msi = npc.GetMovementStateInfo();

        if (targetmsg.target_id <= 0)
        {
            msi.SetPosition2D(x, z);
            msi.SetFaceDir(faceDir);
            npc.GetAiStateInfo().Target  = 0;
            UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId());
            GameFramework.Skill.Trigers.TriggerUtil.MoveObjTo(actor, new UnityEngine.Vector3(x, actor.transform.position.y, z));
            actor.transform.localRotation = UnityEngine.Quaternion.Euler(0, Utility.RadianToDegree(faceDir), 0);
        }
        else
        {
            npc.GetAiStateInfo().Target = targetmsg.target_id;
        }

        SkillInfo skillInfo = npc.GetSkillStateInfo().GetSkillInfoById(skillId);

        if (null != skillInfo)
        {
            if (skillInfo.ConfigData.skillData.canmove == 0)
            {
                EntityViewModel viewModel = EntityViewModelManager.Instance.GetEntityViewById(targetmsg.npc_id);
                if (null != viewModel)
                {
                    viewModel.StopMove();
                }
            }
            if (GfxSkillSystem.Instance.StartSkill(npc.GetId(), skillInfo.ConfigData, 0))
            {
                Utility.EventSystem.Publish("ui_skill_cooldown", "ui", npc.GetId(), skillId, skillInfo.ConfigData.skillData.cooldown / 1000.0f);
            }
        }
    }
Exemple #4
0
    internal static void Execute(object msg, NetConnection conn, NetworkSystem networkSystem)
    {
        Msg_RC_NpcSkill targetmsg = msg as Msg_RC_NpcSkill;

        if (null == targetmsg)
        {
            return;
        }
        if (networkSystem.Robot.OwnedNpcs.Contains(targetmsg.npc_id))
        {
            networkSystem.Robot.NotifyNpcSkill(targetmsg.npc_id, targetmsg.skill_id, targetmsg.stand_pos.x, targetmsg.stand_pos.z, targetmsg.face_direction);
        }
    }
        public static Msg_RC_NpcSkill BuildNpcSkillMessage(EntityInfo obj, int skillId)
        {
            MovementStateInfo msi = obj.GetMovementStateInfo();

            ScriptRuntime.Vector3 pos = msi.GetPosition3D();

            Msg_RC_NpcSkill msg = new Msg_RC_NpcSkill();

            msg.npc_id         = obj.GetId();
            msg.skill_id       = skillId;
            msg.stand_pos      = ToPosition(pos.X, pos.Z);
            msg.face_direction = msi.GetFaceDir();
            msg.target_id      = obj.GetAiStateInfo().Target;

            return(msg);
        }
Exemple #6
0
        public static void Execute(object msg, User user)
        {
            Msg_CR_Skill use_skill = msg as Msg_CR_Skill;

            if (null == use_skill)
            {
                return;
            }
            EntityInfo userObj = user.Info;

            if (null == userObj)
            {
                LogSys.Log(LOG_TYPE.DEBUG, "UseSkillHandler, charactor {0}({1},{2},{3}) not exist", user.RoleId, user.GetKey(), user.Guid, user.Name);
                return;
            }
            Scene scene = user.OwnRoomUserManager.ActiveScene;

            if (null != scene)
            {
                EntityInfo obj = scene.GetEntityById(use_skill.role_id);
                if (null != obj)
                {
                    AiStateInfo aiInfo = obj.GetAiStateInfo();
                    if (use_skill.target_id > 0)
                    {
                        aiInfo.Target = use_skill.target_id;
                    }
                    else if (use_skill.target_dir > 0)
                    {
                        float dir = use_skill.target_dir;
                        obj.GetMovementStateInfo().SetFaceDir(dir);
                        aiInfo.Target = 0;
                    }
                    Msg_RC_NpcSkill retMsg = DataSyncUtility.BuildNpcSkillMessage(obj, use_skill.skill_id);
                    scene.NotifyAllUser(RoomMessageDefine.Msg_RC_NpcSkill, retMsg);
                }
            }
        }
        private void OnNpcSkill(NpcInfo 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.GetServerMilliseconds();
                        if (!curSkillInfo.IsInCd(curTime / 1000.0f))
                        {
                            curSkillInfo.StartTime = curTime / 1000.0f;
                            curSkillInfo.BeginCD();
                            scene.SkillSystem.StartSkill(npc.GetId(), skillId);

                            Msg_RC_NpcSkill skillBuilder = new Msg_RC_NpcSkill();
                            skillBuilder.npc_id   = npc.GetId();
                            skillBuilder.skill_id = skillId;
                            ArkCrossEngineMessage.Position posBuilder1 = new ArkCrossEngineMessage.Position();
                            posBuilder1.x               = npc.GetMovementStateInfo().GetPosition3D().X;
                            posBuilder1.z               = npc.GetMovementStateInfo().GetPosition3D().Z;
                            skillBuilder.stand_pos      = posBuilder1;
                            skillBuilder.face_direction = (float)npc.GetMovementStateInfo().GetFaceDir();

                            LogSystem.Debug("Send Msg_RC_NpcSkill, EntityId={0}, SkillId={1}",
                                            npc.GetId(), skillId);
                            scene.NotifyAreaUser(npc, skillBuilder);
                        }
                    }
                }
            }
        }