Exemplo n.º 1
0
        public void WarpTo(Character character, string action)
        {
            string[] command = action.Split(' ');

            //Generate sector coord from command
            //Catch errors
            SectorTransform destination;

            try
            {
                destination = new SectorTransform
                              (
                    int.Parse(command[1]), //x
                    int.Parse(command[2]), //y
                    int.Parse(command[3])  //z
                              );
            }
            catch
            {
                Console.WriteLine("Invalid Warp Command: " + action);
                Pilot.Player.SendInfoMsg("Invalid Warp Command");
                return;
            }

            //TODO Add Functions in galaxy/sector for warping
            //WarpTo Function Surrogate
            Vector3 oldPos = this.Transform.Position;

            Sector.DespawnSpaceObject(this.IdInSector);
            Galaxy.GetSector(destination).SpawnSpaceObject(this, oldPos);
        }
Exemplo n.º 2
0
 //Return Sector reference
 static public Sector GetSector(SectorTransform pos)
 {
     //spawn the sector if it dosn't exist
     if (sectorList.TryGetValue(pos, out Sector sector))
     {
         return(sector);
     }
     else
     {
         Sector newSector = SpawnSector(pos);
         return(newSector);
     }
 }
Exemplo n.º 3
0
        //spawn a sector
        static private Sector SpawnSector(SectorTransform pos)
        {
            //Create the sector
            Sector newSector = new Sector(pos);

            //Store the sector
            sectorList.Add(pos, newSector);

            //Fire the event
            SectorSpawnedEvent?.Invoke(newSector);

            Console.WriteLine("There are " + sectorList.Count + " sectors");
            Console.WriteLine("Spawned New Sector: " + pos.ToString());
            return(newSector);
        }
Exemplo n.º 4
0
        private void Player_WarptoEvent(Player player, string action)
        {
            //Try to call the event first
            //Will only run if there are no subscribers to the warpto event
            //I.E is aboard a ship
            if (WarpToEvent != null)
            {
                WarpToEvent(this, action);
                return;
            }

            string[] command = action.Split(' ');

            //Generate sector coord from command
            //Catch errors
            SectorTransform destination;

            try
            {
                destination = new SectorTransform
                              (
                    int.Parse(command[1]), //x
                    int.Parse(command[2]), //y
                    int.Parse(command[3])  //z
                              );
            }
            catch
            {
                Console.WriteLine("Invalid Warp Command: " + action);
                player.SendInfoMsg("Invalid Warp Command");
                return;
            }

            //TODO Add Functions in galaxy/sector for warping
            //WarpTo Function Surrogate
            Vector3 oldPos = Transform.Position;

            Sector.DespawnSpaceObject(this.IdInSector);
            Galaxy.GetSector(destination).SpawnSpaceObject(this, oldPos);


            player.SendInfoMsg("Arrived at " + destination.ToString());
        }
Exemplo n.º 5
0
        //=============================================================================
        //Constructors
        //=============================================================================

        public Sector(SectorTransform newPos)
        {
            spaceObjectList = new Dictionary <uint, SpaceObject>();

            SectorTransform = newPos;
        }