GetRadius() public method

public GetRadius ( ) : float
return float
コード例 #1
0
        public static EntityInfo GetNearstAttackerHelper(EntityInfo srcObj, CharacterRelation relation, AiData_General aidata)
        {
            EntityInfo ret        = null;
            float      minDistSqr = 999999;
            Vector2    dir        = srcObj.GetMovementStateInfo().GetFaceDir2D();
            Vector2    pos        = srcObj.GetMovementStateInfo().GetPosition2D();

            if (relation == CharacterRelation.RELATION_ENEMY)
            {
                foreach (var pair in srcObj.AttackerInfos)
                {
                    EntityInfo target = srcObj.SceneContext.GetEntityById(pair.Key);
                    if (null != target)
                    {
                        float distSqr = Geometry.DistanceSquare(pos, target.GetMovementStateInfo().GetPosition2D());
                        if (distSqr <= (srcObj.ViewRange + target.GetRadius()) * (srcObj.ViewRange + target.GetRadius()))
                        {
                            if (distSqr <= minDistSqr)
                            {
                                ret        = target;
                                minDistSqr = distSqr;
                            }
                        }
                    }
                }
            }
            return(ret);
        }
コード例 #2
0
        internal ImpactInfo TrackImpact(TableConfig.Skill cfg, int seq, int curObjId, int srcObjId, int targetId, string emitBone, int emitImpact, Vector3 offset, Dictionary <string, object> args)
        {
            EntityInfo targetObj = m_Scene.EntityManager.GetEntityInfo(targetId);
            EntityInfo srcObj    = m_Scene.EntityManager.GetEntityInfo(srcObjId);

            if (null != targetObj && !targetObj.IsDead())
            {
                if (null != cfg)
                {
                    ImpactInfo impactInfo = null;
                    if (emitImpact <= 0 || emitImpact >= SkillInstance.c_FirstInnerEmitSkillId)
                    {
                        impactInfo = new ImpactInfo(m_Scene.SkillSystem.PredefinedSkill.EmitSkillCfg);
                    }
                    else
                    {
                        impactInfo = new ImpactInfo(emitImpact);
                    }
                    if (TryInitImpactInfo(impactInfo, cfg, seq, curObjId, srcObjId, args))
                    {
                        if (null != srcObj)
                        {
                            Vector3 pos = srcObj.GetMovementStateInfo().GetPosition3D();
                            pos.Y += srcObj.GetRadius();
                            impactInfo.SenderPosition = pos;
                        }
                        targetObj.GetSkillStateInfo().AddImpact(impactInfo);
                        m_Scene.SkillSystem.StartSkill(targetId, impactInfo.ConfigData, impactInfo.Seq, args);
                        return(impactInfo);
                    }
                }
            }
            return(null);
        }
コード例 #3
0
        public ImpactInfo TrackImpact(TableConfig.Skill cfg, int seq, int curObjId, int srcObjId, int targetId, string emitBone, int emitImpact, UnityEngine.Vector3 offset, bool isFinal, Dictionary <string, object> args)
        {
            EntityViewModel view    = GetEntityViewById(targetId);
            EntityViewModel srcView = GetEntityViewById(srcObjId);

            if (null != view && null != view.Entity && null != view.Actor && !view.Entity.IsDeadSkillCasting())
            {
                EntityInfo npc = view.Entity;
                if (null != cfg)
                {
                    ImpactInfo impactInfo = null;
                    if (emitImpact <= 0 || emitImpact >= SkillInstance.c_FirstInnerEmitSkillId)
                    {
                        impactInfo = new ImpactInfo(PredefinedSkill.Instance.EmitSkillCfg);
                    }
                    else
                    {
                        impactInfo = new ImpactInfo(emitImpact);
                    }
                    if (TryInitImpactInfo(impactInfo, cfg, seq, curObjId, srcObjId, args))
                    {
                        UnityEngine.GameObject srcObj = GetGameObject(srcObjId);
                        if (null != srcObj)
                        {
                            UnityEngine.Transform t = Utility.FindChildRecursive(srcObj.transform, emitBone);
                            if (null != t)
                            {
                                UnityEngine.Vector3 pos = t.TransformPoint(offset);
                                impactInfo.SenderPosition = new ScriptRuntime.Vector3(pos.x, pos.y, pos.z);
                            }
                            else
                            {
                                UnityEngine.Vector3 pos = srcObj.transform.TransformPoint(offset);
                                pos.y += npc.GetRadius();
                                impactInfo.SenderPosition = new ScriptRuntime.Vector3(pos.x, pos.y, pos.z);
                            }
                        }
                        impactInfo.DamageData.IsFinal = isFinal;
                        npc.GetSkillStateInfo().AddImpact(impactInfo);
                        GfxSkillSystem.Instance.StartSkill(targetId, impactInfo.ConfigData, impactInfo.Seq, args);
                        return(impactInfo);
                    }
                }
            }
            return(null);
        }
コード例 #4
0
 public void Create(EntityInfo entity)
 {
     if (null != entity)
     {
         m_Entity = entity;
         MovementStateInfo     msi = m_Entity.GetMovementStateInfo();
         ScriptRuntime.Vector3 pos = msi.GetPosition3D();
         float dir = msi.GetFaceDir();
         CreateActor(m_Entity.GetId(), m_Entity.GetModel(), pos.X, pos.Y, pos.Z, dir, m_Entity.Scale, m_Entity.GetRadius(), entity.ActualProperty.GetFloat(CharacterPropertyEnum.x2011_最终速度));
         if (null != Actor)
         {
             m_Agent = Actor.GetComponent <NavMeshAgent>();
             if (m_Agent == null)
             {
                 m_Agent = Actor.AddComponent <NavMeshAgent>();
                 m_Agent.angularSpeed          = c_AngularSpeed;
                 m_Agent.acceleration          = c_Acceleration;
                 m_Agent.radius                = entity.GetRadius();
                 m_Agent.speed                 = entity.ActualProperty.GetFloat(CharacterPropertyEnum.x2011_最终速度);
                 m_Agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance;
             }
             m_Animator = Actor.GetComponentInChildren <Animator>();
             EntityDrawGizmos gizmos = Actor.GetComponent <EntityDrawGizmos>();
             if (null == gizmos)
             {
                 gizmos         = Actor.AddComponent <EntityDrawGizmos>();
                 gizmos.npcInfo = m_Entity;
             }
             else
             {
                 gizmos.npcInfo = m_Entity;
             }
             SetMoveAgentEnable(true);
             try{
                 if (null != m_Agent)
                 {
                     m_Agent.ResetPath();
                 }
             } catch {
                 m_Agent.enabled = true;
             }
         }
     }
 }
コード例 #5
0
        internal static void DoPursuitCommandState(EntityInfo entity, long deltaTime, AbstractAiStateLogic logic)
        {
            AiStateInfo info = entity.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > 200)
            {
                EntityInfo target = AiLogicUtility.GetLivingCharacterInfoHelper(entity, info.Target);
                if (null != target)
                {
                    float   minDist              = entity.GetRadius() + target.GetRadius();
                    float   dist                 = (float)entity.GetActualProperty().AttackRange + minDist;
                    float   distGoHome           = entity.GohomeRange;
                    Vector3 targetPos            = target.GetMovementStateInfo().GetPosition3D();
                    ScriptRuntime.Vector3 srcPos = entity.GetMovementStateInfo().GetPosition3D();
                    float dir = Geometry.GetYRadian(new Vector2(targetPos.X, targetPos.Z), new Vector2(srcPos.X, srcPos.Z));
                    targetPos.X += (float)(minDist * Math.Sin(dir));
                    targetPos.Z += (float)(minDist * Math.Cos(dir));
                    float powDist = Geometry.DistanceSquare(srcPos, targetPos);
                    if (powDist < dist * dist)
                    {
                        logic.AiSendStoryMessage(entity, "npc_pursuit_finish:" + entity.GetUnitId(), entity.GetId());
                        logic.AiSendStoryMessage(entity, "obj_pursuit_finish", entity.GetId());
                        logic.NotifyAiStopPursue(entity);
                        logic.ChangeToState(entity, (int)AiStateId.Idle);
                    }
                    else
                    {
                        logic.NotifyAiPursue(entity, targetPos);
                    }
                }
                else
                {
                    logic.AiSendStoryMessage(entity, "npc_pursuit_exit:" + entity.GetUnitId(), entity.GetId());
                    logic.AiSendStoryMessage(entity, "obj_pursuit_exit", entity.GetId());
                    logic.NotifyAiStopPursue(entity);
                    logic.ChangeToState(entity, (int)AiStateId.Idle);
                }
            }
        }
コード例 #6
0
 public void CopyFrom(EntityInfo obj)
 {
     if (null != obj)
     {
         Object   = obj;
         Position = obj.GetMovementStateInfo().GetPosition3D();
         Radius   = obj.GetRadius();
         MaxX     = Position.X + Radius;
         MinX     = Position.X - Radius;
         MaxZ     = Position.Z + Radius;
         MinZ     = Position.Z - Radius;
         Indexed  = false;
     }
     else
     {
         Object   = null;
         Position = new Vector3();
         Radius   = 0;
         MaxX     = MinX = 0;
         MaxZ     = MinZ = 0;
         Indexed  = false;
     }
 }
コード例 #7
0
        private void GoHomeHandler(EntityInfo entity, long deltaTime)
        {
            AiStateInfo info = entity.GetAiStateInfo();

            info.Time += deltaTime;
            if (info.Time > c_IntervalTime)
            {
                info.Time = 0;
                AiData_General data = GetAiData(entity);
                if (null != data)
                {
                    EntityInfo leader = AiLogicUtility.GetLivingCharacterInfoHelper(entity, info.LeaderID);
                    if (null != leader)
                    {
                        float   minDist              = entity.GetRadius() + leader.GetRadius();
                        Vector3 targetPos            = GetHomePos(entity.GetMovementStateInfo().FormationIndex, leader);
                        ScriptRuntime.Vector3 srcPos = entity.GetMovementStateInfo().GetPosition3D();
                        float powDistToHome          = Geometry.DistanceSquare(srcPos, targetPos);
                        if (powDistToHome <= (minDist + 1) * (minDist + 1))
                        {
                            NotifyAiStopPursue(entity);
                            ChangeToState(entity, (int)AiStateId.Idle);
                        }
                        else
                        {
                            NotifyAiPursue(entity, targetPos);
                        }
                    }
                    else
                    {
                        NotifyAiStopPursue(entity);
                        ChangeToState(entity, (int)AiStateId.Idle);
                    }
                }
            }
        }
コード例 #8
0
 internal static void DoPursuitCommandState(EntityInfo entity, long deltaTime, AbstractAiStateLogic logic)
 {
     AiStateInfo info = entity.GetAiStateInfo();
     info.Time += deltaTime;
     if (info.Time > 200) {
         EntityInfo target = AiLogicUtility.GetLivingCharacterInfoHelper(entity, info.Target);
         if (null != target) {
             float minDist = entity.GetRadius() + target.GetRadius();
             float dist = (float)entity.GetActualProperty().AttackRange + minDist;
             float distGoHome = entity.GohomeRange;
             Vector3 targetPos = target.GetMovementStateInfo().GetPosition3D();
             ScriptRuntime.Vector3 srcPos = entity.GetMovementStateInfo().GetPosition3D();
             float dir = Geometry.GetYRadian(new Vector2(targetPos.X, targetPos.Z), new Vector2(srcPos.X, srcPos.Z));
             targetPos.X += (float)(minDist * Math.Sin(dir));
             targetPos.Z += (float)(minDist * Math.Cos(dir));
             float powDist = Geometry.DistanceSquare(srcPos, targetPos);
             if (powDist < dist * dist) {
                 logic.AiSendStoryMessage(entity, "npc_pursuit_finish:" + entity.GetUnitId(), entity.GetId());
                 logic.AiSendStoryMessage(entity, "obj_pursuit_finish", entity.GetId());
                 logic.NotifyAiStopPursue(entity);
                 logic.ChangeToState(entity, (int)AiStateId.Idle);
             } else {
                 logic.NotifyAiPursue(entity, targetPos);
             }
         } else {
             logic.AiSendStoryMessage(entity, "npc_pursuit_exit:" + entity.GetUnitId(), entity.GetId());
             logic.AiSendStoryMessage(entity, "obj_pursuit_exit", entity.GetId());
             logic.NotifyAiStopPursue(entity);
             logic.ChangeToState(entity, (int)AiStateId.Idle);
         }
     }
 }
コード例 #9
0
 public void CopyFrom(EntityInfo obj)
 {
     if (null != obj) {
         Object = obj;
         Position = obj.GetMovementStateInfo().GetPosition3D();
         Radius = obj.GetRadius();
         MaxX = Position.X + Radius;
         MinX = Position.X - Radius;
         MaxZ = Position.Z + Radius;
         MinZ = Position.Z - Radius;
         Indexed = false;
     } else {
         Object = null;
         Position = new Vector3();
         Radius = 0;
         MaxX = MinX = 0;
         MaxZ = MinZ = 0;
         Indexed = false;
     }
 }
コード例 #10
0
 private void GoHomeHandler(EntityInfo entity, long deltaTime)
 {
     AiStateInfo info = entity.GetAiStateInfo();
     info.Time += deltaTime;
     if (info.Time > c_IntervalTime) {
         info.Time = 0;
         AiData_General data = GetAiData(entity);
         if (null != data) {
             EntityInfo leader = AiLogicUtility.GetLivingCharacterInfoHelper(entity, info.LeaderID);
             if (null != leader) {
                 float minDist = entity.GetRadius() + leader.GetRadius();
                 Vector3 targetPos = GetHomePos(entity.GetMovementStateInfo().FormationIndex, leader);
                 ScriptRuntime.Vector3 srcPos = entity.GetMovementStateInfo().GetPosition3D();
                 float powDistToHome = Geometry.DistanceSquare(srcPos, targetPos);
                 if (powDistToHome <= (minDist + 1) * (minDist + 1)) {
                     NotifyAiStopPursue(entity);
                     ChangeToState(entity, (int)AiStateId.Idle);
                 } else {
                     NotifyAiPursue(entity, targetPos);
                 }
             } else {
                 NotifyAiStopPursue(entity);
                 ChangeToState(entity, (int)AiStateId.Idle);
             }
         }
     }
 }
コード例 #11
0
 internal void Create(EntityInfo entity)
 {
     if (null != entity) {
         m_Entity = entity;
         MovementStateInfo msi = m_Entity.GetMovementStateInfo();
         ScriptRuntime.Vector3 pos = msi.GetPosition3D();
         float dir = msi.GetFaceDir();
         CreateActor(m_Entity.GetId(), m_Entity.GetModel(), pos.X, pos.Y, pos.Z, dir, m_Entity.Scale, m_Entity.GetRadius(), m_Entity.GetActualProperty().MoveSpeed);
         if (null != Actor) {
             m_Agent = Actor.GetComponent<NavMeshAgent>();
             if (m_Agent == null) {
                 m_Agent = Actor.AddComponent<NavMeshAgent>();
                 m_Agent.angularSpeed = c_AngularSpeed;
                 m_Agent.acceleration = c_Acceleration;
                 m_Agent.radius = entity.GetRadius();
                 m_Agent.speed = entity.GetActualProperty().MoveSpeed;
                 m_Agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance;
                 m_Agent.ResetPath();
             }
             m_Animator = Actor.GetComponentInChildren<Animator>();
             EntityDrawGizmos gizmos = Actor.GetComponent<EntityDrawGizmos>();
             if (null == gizmos) {
                 gizmos = Actor.AddComponent<EntityDrawGizmos>();
                 gizmos.npcInfo = m_Entity;
             } else {
                 gizmos.npcInfo = m_Entity;
             }
             SetMoveAgentEnable(true);
         }
     }
 }