Esempio n. 1
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);
        }
Esempio n. 2
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());
        }
Esempio n. 3
0
 public override string ToString()
 {
     return(SectorTransform.ToString());
 }