//Converti un point en worldLocation
        public static WorldLocation ToWorldLocation(this Point Location)
        {
            WorldLocation WipLocation = new WorldLocation();

            Point ChunkXY = new Point();
            Point TileXY  = new Point();

            ChunkXY.X = Location.X / 16;
            TileXY.X  = Location.X % 16;
            if (TileXY.X < 0)
            {
                TileXY.X = 0;
            }


            ChunkXY.Y = Location.Y / 16;
            TileXY.Y  = Location.Y % 16;
            if (TileXY.Y < 0)
            {
                TileXY.Y = 0;
            }

            WipLocation.tile  = TileXY;
            WipLocation.chunk = ChunkXY;

            return(WipLocation);
        }
        public void AddEntity(Obj.ObjEntity _Entity, WorldLocation _WorldLocation)
        {
            Obj.ObjChunk Chunk    = W.chunkManager.GetChunk(_WorldLocation.chunk);
            int          EntityID = _WorldLocation.tile.X + _WorldLocation.tile.Y * 16;

            Chunk.Entities.Add(EntityID, _Entity);
            Chunk.Tiles[_WorldLocation.tile.X, _WorldLocation.tile.Y].Entity = EntityID;
        }
        public bool TileIsFree(WorldLocation _WorldLocation)
        {
            Obj.ObjTile ThisTile = W.chunkManager.GetTile(_WorldLocation);
            if (ThisTile.Entity == -1)
            {
                return(true);
            }

            return(false);
        }
        //ajoute les cooordonné d'un point a une worldLOcation
        public static WorldLocation AddPoint(this WorldLocation _WorldLocation, Point _Point)
        {
            Point pt = ToPoint(_WorldLocation);

            pt = pt + _Point;

            WorldLocation NewWorldLocation = ToWorldLocation(pt);

            return(NewWorldLocation);
        }
        public void RemoveEntity(WorldLocation _WorldLocation)
        {
            ObjTile Tile = W.chunkManager.GetTile(_WorldLocation);

            if (Tile.Entity == -1)
            { // do nothing
            }
            else
            {
                ObjChunk Chunk = W.chunkManager.GetChunk(_WorldLocation);
                Chunk.Entities.Remove(Tile.Entity);
                Tile.Entity = -1;
            }
        }
        public GameObject.Event.GameObjectEventArgs GetEventArgs(WorldLocation Location, Point _OnScreenLocation)
        {
            GameObject.Event.GameObjectEventArgs args = new GameObject.Event.GameObjectEventArgs();

            args.CurrentLocation = Location;

            args.ParrentTile = W.chunkManager.GetTile(Location);

            if (args.ParrentTile.Entity == -1)
            {
                args.ParrentEntity = new Obj.ObjEntity(-1, -1);
            }
            else
            {
                args.ParrentEntity = W.chunkManager.GetEntity(Location);
            }

            args.World            = W;
            args.OnScreenLocation = _OnScreenLocation;

            return(args);
        }
 //Converti une worldLocation en un point
 public static Point ToPoint(this WorldLocation WorldLocation)
 {
     return(new Point(WorldLocation.chunk.X * 16 + WorldLocation.tile.X, WorldLocation.chunk.Y * 16 + WorldLocation.tile.Y));
 }
Exemple #8
0
        public ObjEntity GetEntity(WorldLocation _WorldLocation)
        {
            ObjChunk chk = GetChunk(_WorldLocation);

            return(chk.Entities[GetTile(_WorldLocation).Entity]);
        }
Exemple #9
0
 public ObjTile GetTile(WorldLocation _WorldLocation)
 {
     Obj.ObjChunk Chunk = GetChunk(_WorldLocation.chunk);
     return(Chunk.Tiles[_WorldLocation.tile.X, _WorldLocation.tile.Y]);
 }