public NpaTalkAgent(PeEntity entity)
 {
     _msgs       = new AgentInfo[(int)ENpcTalkType.Max];
     _romveCases = new List <AgentInfo>();
     m_npcCmpt   = entity.GetComponent <NpcCmpt>();
     //m_entityInfo = entity.GetComponent<EntityInfoCmpt>();
 }
    protected override void OnStart()
    {
        base.OnStart();
        entity = GetComponent <Pathea.PeEntity>();

        MousePickablePeEntity tmp = entity.GetComponent <MousePickablePeEntity>();

        if (null != tmp)
        {
            Component.Destroy(tmp);
        }

        operateDistance = 5f;
    }
Example #3
0
 bool MatchStoryAssetId(PeEntity entity, int storyAssetId)
 {
     if (entity != null)
     {
         if (entity.proto != EEntityProto.Doodad)
         {
             return(false);
         }
         if (entity.GetComponent <SceneDoodadLodCmpt>().Index == storyAssetId)
         {
             return(true);
         }
     }
     return(false);
 }
Example #4
0
        public override void Deserialize(System.IO.BinaryReader r)
        {
            base.Deserialize(r);

            if (PeEntity.CURRENT_VERSION >= PeEntity.VERSION_0001)
            {
                /*int version = */
                r.ReadInt32();
                int length = r.ReadInt32();
                //int forcedLength = r.ReadInt32();

                initReq = new List <NpcCmpt>();

                for (int i = 0; i < length; i++)
                {
                    int      npcID  = r.ReadInt32();
                    PeEntity entity = EntityMgr.Instance.Get(npcID);
                    if (entity != null)
                    {
                        NpcCmpt npc = entity.GetComponent <NpcCmpt>();
                        if (npc != null)
                        {
                            AddServant(npc);
                            //							if(mSenventsInfo == null)
                            //								mSenventsInfo = new AddServrntInfo();
                            //							mSenventsInfo.AddServrnt(npc);
                            initReq.Add(npc);
                        }
                    }
                }

                //for (int i = 0; i < forcedLength; i++)
                //{
                //    int npcID = r.ReadInt32();
                //    PeEntity entity = EntityMgr.Instance.Get(npcID);
                //    if(entity != null)
                //    {
                //        NpcCmpt npc = entity.GetComponent<NpcCmpt>();
                //        if(npc != null)
                //        {
                //            AddForcedServant(npc);
                //        }
                //    }
                //}
            }
        }
Example #5
0
        public PeEntity Create(int entityId, string path, Vector3 pos, Quaternion rot, Vector3 scl, bool isnpc = false)
        {
            if (entityId == IdGenerator.Invalid)
            {
                Debug.LogError("[CreateEntity]Failed to create entity : Invalid entity id " + entityId);
                return(null);
            }

            if (null != EntityMgr.Instance.Get(entityId))
            {
                Debug.LogError("[CreateEntity]Failed to create entity : Existed entity with id:" + entityId);
                return(null);
            }

            PeEntity entity = PeEntity.Create(path, pos, rot, scl);

            if (null == entity)
            {
                Debug.LogError("[CreateEntity]Failed to create entity!");
                return(null);
            }

            bool isPlayer = entity.GetComponent <MainPlayerCmpt>() != null;
            //NpcCmpt npccmpt = entity.GetComponent<NpcCmpt>();

            Transform root;

            if (entity.NpcCmpt == null || isPlayer)
            {
                root = EntityRoot;
            }
            else
            {
                root = npcEntityRoot;
            }

            entity.transform.parent = root;
            InitEntity(entityId, entity.gameObject);
            return(entity);
        }
Example #6
0
        void OnCollisionEnter(Collision colInfo)
        {
            GameObject go = colInfo.collider.gameObject;

            if (go.layer == Layer.TreeStatic)
            {
                // Proceed one each time

                /*
                 * ContactPoint point = colInfo.contacts[0];
                 * Vector3 vPt = point.point;
                 * int x = Mathf.CeilToInt(vPt.x);
                 * int y = Mathf.CeilToInt(vPt.y);
                 * int z = Mathf.CeilToInt(vPt.z);
                 * for(int dx = 0; dx < 2; dx++) {
                 *  for(int dy = 0; dx < 2; dx++) {
                 *      for(int dx = 0; dx < 2; dx++) {
                 *      }
                 *  }
                 * }
                 */
            }
            else if (go.layer == Layer.NearTreePhysics)
            {
                if (Pathea.PeGameMgr.IsStory || Pathea.PeGameMgr.IsAdventure)
                {
                    PeEntity entity = GetComponentInParent <PeEntity>();

                    if (Pathea.PeGameMgr.IsStory)
                    {
                        if (entity != null)
                        {
                            if (entity.Field == MovementField.Sky && entity.commonCmpt.entityProto.proto == EEntityProto.Monster)
                            {
                                if (entity.maxRadius < MinCmpt(colInfo.collider.bounds.extents) * 2f)
                                {
                                    return;
                                }
                            }

                            else if (entity.carrier)
                            {
                                if (colInfo.relativeVelocity.magnitude * entity.carrier.rigidbody.mass
                                    < MinCmpt(colInfo.collider.bounds.extents) * PEVCConfig.instance.treeHardness)
                                {
                                    return;
                                }
                            }

                            GlobalTreeInfo tree = LSubTerrainMgr.TryGetTreeInfo(go);
                            if (tree != null)
                            {
                                LSubTerrainMgr.DeleteTree(go);
                                LSubTerrainMgr.RefreshAllLayerTerrains();
                                SkEntitySubTerrain.Instance.SetTreeHp(tree.WorldPos, 0);
                                StroyManager.Instance.TreeCutDown(entity.position, tree._treeInfo, tree.WorldPos);
                            }
                        }
                    }
                    else                     // Pathea.PeGameMgr.IsAdventure
                    {
                        if (entity != null)
                        {
                            if (entity.Field == MovementField.Sky && entity.commonCmpt.entityProto.proto == EEntityProto.Monster)
                            {
                                if (entity.maxRadius < MinCmpt(colInfo.collider.bounds.extents) * 2f)
                                {
                                    return;
                                }
                            }

                            else if (entity.carrier)
                            {
                                if (colInfo.relativeVelocity.magnitude * entity.carrier.rigidbody.mass
                                    < MinCmpt(colInfo.collider.bounds.extents) * PEVCConfig.instance.treeHardness)
                                {
                                    return;
                                }
                            }

                            TreeInfo tree = RSubTerrainMgr.TryGetTreeInfo(go);
                            if (tree != null)
                            {
                                RSubTerrainMgr.DeleteTree(go);
                                RSubTerrainMgr.RefreshAllLayerTerrains();
                                SkEntitySubTerrain.Instance.SetTreeHp(tree.m_pos, 0);
                                StroyManager.Instance.TreeCutDown(entity.position, tree, tree.m_pos);
                            }
                        }
                    }
                }
            }
            //50吨以15米/秒速度撞击的伤害缩放为1 50 * 15 * 15 = 11250
            else if (go.layer == Layer.AIPlayer || go.layer == Layer.Player)
            {
                PeEntity target = go.GetComponentInParent <PeEntity>();
                if (target != null && m_Entity != null && m_Entity.carrier != null && colInfo.relativeVelocity.sqrMagnitude > 2.0f * 2.0f)
                {
                    NetCmpt net = m_Entity.GetComponent <NetCmpt>();
                    if (net == null || net.IsController)
                    {
                        float scale = 1.0f / 11250.0f;
                        float mass  = m_Entity.carrier.creationController.creationData.m_Attribute.m_Weight * 0.001f;
                        float speed = colInfo.relativeVelocity.sqrMagnitude;

                        float damageScale = Mathf.Clamp(mass * speed * scale, 0.0f, 2.0f);
                        //Debug.LogError("Mass:" + mass + " Speed:" + speed + " Scale:" + damageScale);
                        if (m_RigidBody == null || m_RigidBody.velocity.sqrMagnitude < 5.0f * 5.0f || damageScale < 0.01)
                        {
                            damageScale = 0.0f;
                        }
                        else
                        {
                            PECapsuleHitResult hitResult = new PECapsuleHitResult();
                            hitResult.selfTrans   = transform;
                            hitResult.hitTrans    = go.transform;
                            hitResult.hitPos      = colInfo.contacts[0].point;
                            hitResult.hitDir      = -colInfo.contacts[0].normal;
                            hitResult.damageScale = damageScale;

                            m_Entity.skEntity.CollisionCheck(hitResult);

                            //if(go.layer == Layer.Player && target.NpcCmpt != null && speed > 10.0f*10.0f)
                            //{
                            //    if(target.biologyViewCmpt != null)
                            //    {
                            //        RagdollHitInfo hitInfo = new RagdollHitInfo();
                            //        hitInfo.hitTransform = target.biologyViewCmpt.monoRagdollCtrlr.ragdollRootBone;
                            //        hitInfo.hitPoint = colInfo.contacts[0].point;
                            //        hitInfo.hitNormal = colInfo.contacts[0].normal;
                            //        hitInfo.hitForce = colInfo.impulse;
                            //        target.biologyViewCmpt.ActivateRagdoll(hitInfo);
                            //    }
                            //}
                        }
                    }
                }
            }

            //50吨以15米/秒速度撞击的伤害缩放为1 50 * 15 * 15 = 11250
            if (go.layer == Layer.VFVoxelTerrain ||
                go.layer == Layer.TreeStatic
                //|| go.layer == Layer.NearTreePhysics
                || go.layer == Layer.Building ||
                go.layer == Layer.SceneStatic ||
                go.layer == Layer.Unwalkable ||
                go.layer == Layer.GIEProductLayer)
            {
                bool isWheel = false;
                if (go.layer == Layer.VFVoxelTerrain)
                {
                    for (int i = 0; i < colInfo.contacts.Length; i++)
                    {
                        if (colInfo.contacts[i].thisCollider.gameObject.GetComponentInParent <VCPVehicleWheel>() != null)
                        {
                            isWheel = true;
                        }
                    }
                }

                if (!isWheel && m_Entity != null && m_Entity.carrier != null && colInfo.relativeVelocity.sqrMagnitude > 2.0f * 2.0f)
                {
                    NetCmpt net = m_Entity.GetComponent <NetCmpt>();
                    if (net == null || net.IsController)
                    {
                        float scale = 1.0f / 11250.0f;
                        float mass  = m_Entity.carrier.creationController.creationData.m_Attribute.m_Weight * 0.001f;
                        float speed = colInfo.relativeVelocity.sqrMagnitude;

                        float   damageScale = Mathf.Clamp(mass * speed * scale, 0.0f, 2.0f);
                        Vector3 v           = m_RigidBody.velocity;
                        float   curSpeed    = Mathf.Sqrt(v.x * v.x + v.z * v.z) * 3.6f;
                        //Debug.LogError("Mass:" + mass + " Speed:" + speed + " Scale:" + damageScale);
                        if (curSpeed < 45f || damageScale < 0.01)
                        {
                            damageScale = 0.0f;
                        }
                        else
                        {
                            SkillSystem.SkEntity.MountBuff(m_Entity.skEntity, 30200174, new List <int> {
                                0
                            }, new List <float>()
                            {
                                damageScale
                            });

                            //PECapsuleHitResult hitResult = new PECapsuleHitResult();
                            //hitResult.selfTrans = transform;
                            //hitResult.hitTrans = go.transform;
                            //hitResult.hitPos = colInfo.contacts[0].point;
                            //hitResult.hitDir = -colInfo.contacts[0].normal;
                            //hitResult.damageScale = damageScale;

                            //m_Entity.skEntity.CollisionCheck(hitResult);

                            //Debug.LogError(go.name + " --> " + colInfo.relativeVelocity.magnitude);
                        }
                    }
                }
            }
        }