コード例 #1
0
ファイル: Ship.cs プロジェクト: PyroChiliarch/TerminalSpace
        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);
        }
コード例 #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);
     }
 }
コード例 #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);
        }
コード例 #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());
        }
コード例 #5
0
ファイル: Sector.cs プロジェクト: PyroChiliarch/TerminalSpace
        //=============================================================================
        //Constructors
        //=============================================================================

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

            SectorTransform = newPos;
        }