示例#1
0
        public void AddEntity(IEntity obj)
        {
            (obj as Entity).Scene = this;
            GOESceneEntityContainer container = this.GetComponent <GOESceneEntityContainer>();

            container.AddEntity(obj as Entity);
        }
示例#2
0
        public void DelEntity(IEntity obj)
        {
            GOESceneEntityContainer container = this.GetComponent <GOESceneEntityContainer>();

            container.DelEntity(obj as Entity);
        }
示例#3
0
        //
        public void DelEntity(string id)
        {
            GOESceneEntityContainer container = this.GetComponent <GOESceneEntityContainer>();

            container.DelEntity(id);
        }
示例#4
0
        //
        public IEntity GetEntityByID(string id)
        {
            GOESceneEntityContainer container = this.GetComponent <GOESceneEntityContainer>();

            return(container.GetEntityByID(id));
        }
示例#5
0
        // @xl 添加与其他玩家碰撞的功能 //
        private bool checkCollision()
        {
            //此处主角应该不为0
            if (this.Entity.CollisionRadius < 0.001f)
            {
                return(false);
            }
            GOESceneEntityContainer con = Entity.Scene.GetComponent <GOESceneEntityContainer>();

            for (int i = 0; i < con.GetEntityCount(); ++i)
            {
                Entity ent = con.GetEntityByIndex(i);
                if (ent != null)
                {
                    if (ent.GameObject != null)
                    {
                        //Debug.Log(ent.GameObject.name + "----" + ent.GUID.ToString());
                    }
                    if (ent.CollisionRadius < 0.01f)
                    {
                        continue;
                    }
                    if (isPathfinding && ent.IgnorePathFindingCollision)
                    {
                        continue;
                    }
                    if (!ent.Visible)
                    {
                        continue;
                    }
                    if (ent.GUID == this.Entity.GUID)
                    {
                        //Debug.Log(ent.GUID.ToString() + "continue");
                        continue;
                    }
                    if (!(ent is IGOEActorEntity))
                    {
                        continue;
                    }
                    Vector3 posvec = (ent.Position - Entity.Position);
                    posvec.y = 0;
                    if (posvec.magnitude < (ent.CollisionRadius + Entity.CollisionRadius))
                    {
                        //Debug.Log("zhuangshang =  " + posvec.magnitude.ToString());
                        Vector3 tempdir = _rockDir;
                        tempdir.y = 0;
                        Debug.DrawRay(Entity.Position, tempdir, Color.yellow);
                        tempdir.Normalize();
                        posvec.Normalize();

                        float dotrst = Vector3.Dot(tempdir, posvec);
                        //Debug.Log(dotrst.ToString());
                        //Debug.Log(Entity.Position.ToString() + "---" + ent.Position.ToString());
                        if (ent.GameObject != null)
                        {
                            //Debug.Log(Entity.GameObject.name);
                        }
                        Debug.DrawLine(Entity.Position, ent.Position, Color.red);
                        if (dotrst > 0.3f && dotrst < 1f)
                        {
                            //_currentTarget = end;
                            //endMoveByNextMove();
                            endMove(false);
                            if (Actor.OnCollision != null)
                            {
                                Actor.OnCollision(ent);
                            }
                            //PlayMoveAnim();
                            _lastDegree = -1000;
                            //Debug.Log("zhuangshang ");
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }