Exemple #1
0
        private static bool IsWantedTargetForRandomTarget(CharacterInfo srcObj, CharacterRelation relation, AiTargetType type, ISpaceObject obj)
        {
            if (type == AiTargetType.USER && obj.GetObjType() != SpatialObjType.kUser)
            {
                return(false);
            }
            if (type == AiTargetType.NPC && obj.GetObjType() != SpatialObjType.kNPC)
            {
                return(false);
            }
            CharacterInfo target = GetSeeingLivingCharacterInfoHelper(srcObj, (int)obj.GetID());

            if (null != target && !target.IsDead())
            {
                if (target.IsControlMecha)
                {
                    return(false);
                }
                NpcInfo npcTarget = target.CastNpcInfo();
                if (null != npcTarget && npcTarget.NpcType == (int)NpcTypeEnum.Skill)
                {
                    return(false);
                }
                if (relation == CharacterInfo.GetRelation(srcObj, target))
                {
                    if (CanSee(srcObj, target))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        private void OnSendImpact(CharacterInfo sender, int targetId, int impactId, Vector3 srcPos, float srcDir)
        {
            CharacterView senderView = EntityManager.Instance.GetCharacterViewById(sender.GetId());
            CharacterView targetView = EntityManager.Instance.GetCharacterViewById(targetId);

            if (null != senderView && null != targetView)
            {
                CharacterInfo target = WorldSystem.Instance.GetCharacterById(targetId);
                if (null != target)
                {
                    // 施法者能造成硬直且受击方没有霸体
                    ImpactInfo impactInfo = target.GetSkillStateInfo().GetImpactInfoById(impactId);
                    if (null == impactInfo)
                    {
                        return;
                    }
                    int forceLogicId = -1;
                    if (sender.CauseStiff && !target.SuperArmor && !target.UltraArmor)
                    {
                        // 正常造成硬直
                    }
                    else
                    {
                        forceLogicId = 0;
                        impactInfo.m_IsGfxControl = false;
                    }
                    // Npc需要根据体型和类型判定
                    if (target.IsNpc)
                    {
                        NpcInfo npcInfo = target.CastNpcInfo();
                        // 场景破坏物体单独处理
                        if (npcInfo.NpcType == (int)NpcTypeEnum.SceneObject)
                        {
                            forceLogicId = 1;
                            impactInfo.m_IsGfxControl = true;
                        }
                        // 处理体型
                        if (!impactInfo.ConfigData.TargetFigure.Contains(npcInfo.NpcFigure))
                        {
                            forceLogicId = 0;
                            impactInfo.m_IsGfxControl = false;
                        }
                    }
                    // 打断技能
                    if ((null != impactInfo && 0 != impactInfo.ConfigData.ImpactGfxLogicId && forceLogicId < 0) || forceLogicId > 0)
                    {
                        if (null != target.SkillController)
                        {
                            target.SkillController.ForceInterruptCurSkill();
                        }
                        else
                        {
                            LogSystem.Warn("{0} does't have a skillcontroller", target.GetName());
                        }
                    }
                    GfxSystem.QueueGfxAction(GfxModule.Impact.GfxImpactSystem.Instance.SendImpactToCharacter, senderView.Actor, targetView.Actor, impactId, srcPos.X, srcPos.Y, srcPos.Z, srcDir, forceLogicId);
                }
            }
        }
Exemple #3
0
        private static void GetInterestestTarget(CharacterInfo srcObj, CharacterRelation relation, AiTargetType type, float powDist, ISpaceObject obj, ref float minPowDist, ref CharacterInfo interestestTarget)
        {
            if (type == AiTargetType.USER && obj.GetObjType() != SpatialObjType.kUser)
            {
                return;
            }
            if (type == AiTargetType.TOWER && obj.GetObjType() != SpatialObjType.kNPC)
            {
                return;
            }
            if (type == AiTargetType.SOLDIER && obj.GetObjType() != SpatialObjType.kNPC)
            {
                return;
            }
            CharacterInfo target = GetSeeingLivingCharacterInfoHelper(srcObj, (int)obj.GetID());

            if (null != target && !target.IsDead())
            {
                if (target.IsControlMecha)
                {
                    return;
                }
                NpcInfo npcTarget = target.CastNpcInfo();
                if (null != npcTarget && npcTarget.NpcType == (int)NpcTypeEnum.Skill)
                {
                    return;
                }
                if (type == AiTargetType.SOLDIER && npcTarget.IsPvpTower)
                {
                    return;
                }
                if (type == AiTargetType.TOWER && !npcTarget.IsPvpTower)
                {
                    return;
                }

                if (relation == CharacterInfo.GetRelation(srcObj, target))
                {
                    if (powDist < minPowDist)
                    {
                        if (powDist > c_MaxViewRangeSqr || CanSee(srcObj, target))
                        {
                            interestestTarget = target;
                            minPowDist        = powDist;
                        }
                    }
                }
            }
        }
Exemple #4
0
        protected void UpdateMovement()
        {
            CharacterInfo obj = GetOwner();

            if (null != obj && !obj.IsDead() && null != ObjectInfo)
            {
                if (obj.IsNpc && !obj.CastNpcInfo().CanMove)
                {
                    return;
                }
                MovementStateInfo msi = obj.GetMovementStateInfo();
                ObjectInfo.FaceDir     = msi.GetFaceDir();
                ObjectInfo.WantFaceDir = msi.GetWantFaceDir();
                if (msi.IsMoving)
                {
                    Vector3 pos = msi.GetPosition3D();
                    ObjectInfo.MoveCos   = (float)msi.MoveDirCosAngle;
                    ObjectInfo.MoveSin   = (float)msi.MoveDirSinAngle;
                    ObjectInfo.MoveSpeed = (float)obj.GetActualProperty().MoveSpeed *(float)obj.VelocityCoefficient;

                    if (obj is UserInfo)
                    {
                        if (msi.TargetPosition.LengthSquared() < Geometry.c_FloatPrecision)
                        {
                            ObjectInfo.MoveTargetDistanceSqr = 100.0f;
                        }
                        else
                        {
                            ObjectInfo.MoveTargetDistanceSqr = msi.CalcDistancSquareToTarget();
                        }
                    }
                    else
                    {
                        ObjectInfo.MoveTargetDistanceSqr = msi.CalcDistancSquareToTarget();
                    }

                    ObjectInfo.IsLogicMoving = true;
                }
                else
                {
                    ObjectInfo.IsLogicMoving = false;
                }
            }
            else
            {
                ObjectInfo.IsLogicMoving = false;
            }
        }
Exemple #5
0
        public void VisitWatchingObjUsers(CharacterInfo obj, MyAction <UserInfo> visitor)
        {
            int     objId = obj.GetId();
            NpcInfo npc   = obj.CastNpcInfo();

            if (null != npc && npc.NpcType == (int)NpcTypeEnum.PvpTower)
            {
                for (LinkedListNode <UserInfo> node = obj.UserManager.Users.FirstValue; null != node; node = node.Next)
                {
                    UserInfo user = node.Value;
                    if (null != user)
                    {
                        visitor(user);
                    }
                }
            }
            else
            {
                if (obj.CurBlueCanSeeMe)
                {
                    int campId = (int)CampIdEnum.Blue;
                    if (camp_users_.ContainsKey(campId))
                    {
                        List <UserInfo> list = camp_users_[campId];
                        int             ct   = list.Count;
                        for (int i = 0; i < ct; ++i)
                        {
                            visitor(list[i]);
                        }
                    }
                }
                if (obj.CurRedCanSeeMe)
                {
                    int campId = (int)CampIdEnum.Red;
                    if (camp_users_.ContainsKey(campId))
                    {
                        List <UserInfo> list = camp_users_[campId];
                        int             ct   = list.Count;
                        for (int i = 0; i < ct; ++i)
                        {
                            visitor(list[i]);
                        }
                    }
                }
            }
        }
        private bool HasNoPartnerOrPartnerInArea(UserInfo user, IList <Vector3> pts)
        {
            CharacterInfo partner = user.SceneContext.GetCharacterInfoById(user.PartnerId);

            if (null == partner)
            {
                return(true);
            }
            else
            {
                NpcInfo npc = partner.CastNpcInfo();
                if (null == npc || npc.NpcType != (int)NpcTypeEnum.Partner)
                {
                    return(true);
                }
                Vector3 point = partner.GetMovementStateInfo().GetPosition3D();
                if (Geometry.PointInPolygon(point, pts, 0, pts.Count) == 1)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #7
0
            public void Visit(CharacterInfo obj)
            {
                if (self_ == obj)
                {
                    return;
                }
                NpcInfo npc = obj.CastNpcInfo();

                if (null != npc && npc.NpcType == (int)NpcTypeEnum.PvpTower)//塔不需要放在可见对象表中(全场景可见)
                {
                    return;
                }

                /*if (self_.IsUser && obj.IsUser) {
                 * LogSystem.Debug("Sight:{0}({1},{2}) see {3}({4},{5})", self_.GetLinkId(), self_.SightCell.row, self_.SightCell.col, obj.GetLinkId(), obj.SightCell.row, obj.SightCell.col);
                 * }*/
                bool isblue = (sight_camp_ == (int)CampIdEnum.Blue);
                int  objId  = obj.GetId();

                if (obj.GetCampId() != sight_camp_ && (isblue && !obj.CurBlueCanSeeMe || !isblue && !obj.CurRedCanSeeMe))
                {
                    Vector3 posd    = obj.GetMovementStateInfo().GetPosition3D();
                    float   distSqr = DashFire.Geometry.DistanceSquare(pos_, posd);
                    if (CharacterInfo.CanSee(self_, obj, distSqr, pos_, posd))
                    {
                        if (isblue)
                        {
                            obj.CurBlueCanSeeMe = true;
                        }
                        else
                        {
                            obj.CurRedCanSeeMe = true;
                        }
                    }
                }
            }
Exemple #8
0
        private bool SendImpactImpl(CharacterInfo sender, int impactId, int targetId, int skillId, int duration)
        {
            //LogSystem.Debug("character {0} send impact {1} to character {2}", sender.GetId(), impactId, targetId);
            if (null != sender)
            {
                CharacterInfo target = sender.SceneContext.GetCharacterInfoById(targetId);
                if (null != target)
                {
                    if (target.IsUser && target.IsDead())
                    {
                        return(false);
                    }
                    if (target.IsNpc && target.IsDead())
                    {
                        NpcInfo npc = target.CastNpcInfo();
                        if ((int)NpcTypeEnum.SceneObject == npc.NpcType)
                        {
                            return(false);
                        }
                    }
                    ImpactLogicData impactLogicData = SkillConfigProvider.Instance.ExtractData(SkillConfigType.SCT_IMPACT, impactId) as ImpactLogicData;
                    if (null != impactLogicData)
                    {
                        IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(impactLogicData.ImpactLogicId);
                        if (null != logic)
                        {
                            ImpactInfo oldImpactInfo = target.GetSkillStateInfo().GetImpactInfoById(impactId);
                            if (null != oldImpactInfo)
                            {
                                logic.OnInterrupted(target, impactId);
                                target.GetSkillStateInfo().RemoveImpact(impactId);
                            }
                            ImpactInfo impactInfo = new ImpactInfo();
                            impactInfo.m_IsActivated    = true;
                            impactInfo.m_SkillId        = skillId;
                            impactInfo.m_ImpactId       = impactLogicData.ImpactId;
                            impactInfo.m_ImpactType     = impactLogicData.ImpactType;
                            impactInfo.m_BuffDataId     = impactLogicData.BuffDataId;
                            impactInfo.ConfigData       = impactLogicData;
                            impactInfo.m_StartTime      = TimeUtility.GetServerMilliseconds();
                            impactInfo.m_ImpactDuration = impactLogicData.ImpactTime;
                            if (-1 == duration || duration > impactLogicData.ImpactTime)
                            {
                                impactInfo.m_ImpactDuration = impactLogicData.ImpactTime;
                            }
                            else
                            {
                                impactInfo.m_ImpactDuration = duration;
                            }
                            impactInfo.m_HasEffectApplyed = false;
                            if (0 == impactInfo.ConfigData.ImpactGfxLogicId)
                            {
                                impactInfo.m_IsGfxControl = false;
                            }
                            else
                            {
                                impactInfo.m_IsGfxControl = true;
                            }
                            impactInfo.m_ImpactSenderId  = sender.GetId();
                            impactInfo.m_MaxMoveDistance = impactLogicData.CalcMaxMoveDistance();
                            if (impactLogicData.ImpactGfxLogicId == 0)
                            {
                                impactInfo.m_LeftEnableMoveCount = 0;//禁止位移
                            }
                            else
                            {
                                impactInfo.m_LeftEnableMoveCount = 1;//允许位移
                            }

                            //LogSystem.Warn("impact {0} EnableMoveCount {1} MaxMoveDistanceSqr {2}", impactId, impactInfo.m_LeftEnableMoveCount, impactInfo.m_MaxMoveDistanceSqr);

                            target.GetSkillStateInfo().AddImpact(impactInfo);
                            logic.StartImpact(target, impactId);

                            if ((int)ImpactType.INSTANT == impactInfo.m_ImpactType)
                            {
                                impactInfo.m_IsActivated = false;
                            }
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }