public ServerShipManager(World serverWorld, EventManager eventManager, YmfasServer _server) { serverShipLog = Mogre.LogManager.Singleton.CreateLog("server-ship.log"); serverShipLog.LogMessage("creating ssm"); world = serverWorld; eventMgr = eventManager; server = _server; //init ships ShipTypeData curShipType = new ShipTypeData(); curShipType.Class = ShipClass.Interceptor; curShipType.Model = ShipModel.MogreFighter; //player ships foreach (int id in server.PlayerIds ) { Vector3 curPosition = Vector3.ZERO;//new Vector3(Mogre.Math.RangeRandom(-TestEngine.WorldSizeParam / 1.5f, TestEngine.WorldSizeParam / 1.5f), Mogre.Math.RangeRandom(-TestEngine.WorldSizeParam / 1.5f, TestEngine.WorldSizeParam / 1.5f), Mogre.Math.RangeRandom(-TestEngine.WorldSizeParam / 1.5f, TestEngine.WorldSizeParam / 1.5f)); Quaternion curOrientation = Quaternion.IDENTITY; ShipInit curShipInit = new ShipInit(id, curShipType, curPosition, curOrientation, server.GetPlayerName(id)); eventMgr.SendEvent(curShipInit); Util.Log("sent init for ship " + id); //put them in world Ship s = new Ship(world, id, curPosition, curOrientation); shipTable.Add(id, s); } //init listeners ShipControlStatus.FiringEvent += new GameEventFiringHandler(handleShipControlStatus); }
/// <summary> /// Creates the event to initialize a ship /// </summary> /// <param name="playerId">The owner of the ship</param> /// <param name="shipType">The type of the ship</param> /// <param name="position">The position of the ship</param> /// <param name="orientation">The orientation of the ship</param> public ShipInit(int playerId, ShipTypeData shipType, Vector3 position, Quaternion orientation, String playerName) { PlayerId = playerId; ShipType = shipType; Position = position; Orientation = orientation; PlayerName = playerName; }
/// <summary> /// Default constructor /// </summary> public ShipInit() { PlayerId = -1; ShipType = new ShipTypeData(); ShipType.Class = ShipClass.Interceptor; ShipType.Model = ShipModel.MogreFighter; Position = new Vector3(); Orientation = new Quaternion(); PlayerName = ""; }