public override void Initialize() { randomGenerator = GameServiceManager.GetService <IRandomGenerator>(); ResetTimer(); base.Initialize(); }
public override void Initialize() { CameraManager = GameServiceManager.GetService <ICameraService>(); ParentGameObject.OnMove += OnMove; base.Initialize(); }
public override void Initialize() { //Subscribe to the game object added and removed events. gameObjectManager = GameServiceManager.GetService <IGameObjectManager>(); gameObjectManager.OnGameObjectAdded += OnGameObjectAdded; gameObjectManager.OnGameObjectRemoved += OnGameObjectRemovedHandler; }
public override void Initialize() { //Grab a reference to the IInputHandler service. InputHandler = GameServiceManager.GetService <IInputHandler>(); base.Initialize(); }
public override void Initialize() { ComponentFactory = (IComponentFactory)GameServiceManager.GetService(typeof(IComponentFactory)); rawPool = new PoolNew <IGameObject>(typeof(GameObject), 1024); gameObjectTemplates = new Dictionary <string, IGameObject>(); }
public override void PostInitialize() { gameObjectFactory = GameServiceManager.GetService <IGameObjectFactory>(); LoadLevel("testLevel"); base.PostInitialize(); }
public override void PostInitialize() { var goManager = GameServiceManager.GetService <IGameObjectManager>(); goManager.OnGameObjectAdded += OnGameObjectAdded; player = goManager.FindWithMetadata("player"); base.PostInitialize(); }
public override void Initialize() { var gameObjectManager = GameServiceManager.GetService <IGameObjectManager>(); if (gameObjectManager != null) { gameObjectManager.OnGameObjectAdded += OnGameObjectAdded; } ResumeSimulation(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { var manager = (PlayerManager)GameServiceManager.GetService(typeof(PlayerManager)); manager.SetPlayer(LogicalPlayerIndex.One, PlayerIndex.One); foreach (var service in GameServiceManager.Services) { service.PostInitialize(); } }
public override void Initialize() { var gameObjectManager = GameServiceManager.GetService <IGameObjectManager>(); if (gameObjectManager != null) { gameObjectManager.OnGameObjectAdded += OnGameObjectAddedHandler; } PhysicsWorld.BodyRemoved += OnBodyRemoved; }
public override void Deserialize(XElement element) { IEnumerable <XElement> behaviorElements = element.Element("behaviors").Elements("behavior"); behaviorFactory = GameServiceManager.GetService <IBehaviorFactory>(); foreach (var behaviorElement in behaviorElements) { var behavior = behaviorFactory.LoadBehaviorFromXML(behaviorElement); AddBehavior(behavior); } }
public override void Initialize() { //Tell the collision manager we want to subscribe... IPhysicsManager collisionManager = GameServiceManager.GetService <IPhysicsManager>(); if (collisionManager != null) { collisionManager.SubscribeCollisionEvent(this.ParentGameObject.GUID, OnCollision); } base.Initialize(); }
public void Initialize() { var factory = GameServiceManager.GetService <IGameObjectManager>(); if (factory != null) { factory.OnGameObjectAdded += OnGameObjectAdded; factory.OnGameObjectRemoved += OnGameObjectRemoved; } BodyRemoved += OnBodyRemoved; }
public override void Update(GameTime gameTime) { var gameObjects = GameServiceManager.GetService <IGameObjectManager>().GetAll(); foreach (var gameObject in gameObjects) { if (gameObject.Active) { gameObject.Update(gameTime); } } }
public override void Deserialize(XElement element) { //Read in all of our renderables. if (element.Element("renderables") != null) { RenderableFactory factory = (RenderableFactory)GameServiceManager.GetService(typeof(RenderableFactory)); if (factory != null) { renderables = factory.GenerateRenderables(element.Element("renderables"), this); } } }
public override void Initialize() { foreach (var behavior in behaviors) { behavior.Value.Initialize(); } actionManager = GameServiceManager.GetService <IActionManager>(); ActionFactory = GameServiceManager.GetService <IActionFactory>(); behaviorFactory = GameServiceManager.GetService <IBehaviorFactory>(); base.Initialize(); }
public override void Initialize() { var gameObjectManager = GameServiceManager.GetService <IGameObjectManager>(); if (gameObjectManager != null) { gameObjectManager.OnGameObjectAdded += OnGameObjectAdded; gameObjectManager.OnGameObjectRemoved += OnGameObjectRemoved; } layerManager = GameServiceManager.GetService <ILayerManager>(); Active = true; }
public void Initialize() { GUID = Guid.NewGuid(); componentFactory = GameServiceManager.GetService <IComponentFactory>(); foreach (var component in components.Values) { component.Initialize(); component.Active = Active; } if (OnInitialize != null) { OnInitialize(this); } }
public void LoadLevel(string levelName) { var test = gameObjectFactory.GetGameObject("player", 400f, 400f); var manager = (PlayerManager)GameServiceManager.GetService(typeof(PlayerManager)); var player = manager.GetPlayer(LogicalPlayerIndex.One); test.UpdateMetadata("player", player); test.PostInitialize(); test.Active = true; test = gameObjectFactory.GetGameObject("EnemySpawner"); test.PostInitialize(); test.Active = true; test = gameObjectFactory.GetGameObject("ScoreDisplay", 100f, 100f); test.PostInitialize(); test.Active = true; }
public override void Start() { _badWordHandler = new BadWordHandler(); _emoticonHandler = new EmoticonHandler(); _chatTerminal = Object.FindObjectOfType <Computer>(); _networkClient = GameServiceManager.GetService <NetworkClient>(); _configHandler = GameServiceManager.GetService <ConfigHandler>(); _networkClient.OnClientConnectionSuccessful += OnConnected; _networkClient.OnClientDisconnected += OnDisconnected; // register network data function for the message type _networkClient.MessagePipe.On("say", SayMessageReceived); _networkClient.MessagePipe.On("UserInfo", SetUserInformation); _networkClient.MessagePipe.On("ChannelUpdate", OnChannelUpdate); _networkClient.MessagePipe.On("OnServerNotification", OnServerNotification); // Connect Connect(); }
public ServerChatManager() : base("chat service") { _globalChannel = new ChatChannel { Name = "Global", Participants = new List <User>(), }; Channels.Add(_globalChannel); // random name generator _nameGenerator = new PersonNameGenerator(); // server configuration for the messages we need to handle _server = GameServiceManager.GetService <NetworkServer>(); // connection handlers - mapping connections to user information _server.OnClientConnectionSuccessful += OnClientConnected; _server.OnClientDisconnected += OnClientDisconnected; }
public override void Deserialize(XElement element) { Color color = new Color(); if (element.Element("filledColor") != null) { color = color.ConvertColorFromString(element.Element("filledColor").Value); } Offset = Offset.DeserializeOffset(element.Element("offset")); //Retrieve the asset elements List <XElement> elements = element.Elements("renderable").ToList(); RenderableFactory factory = (RenderableFactory)GameServiceManager.GetService(typeof(RenderableFactory)); for (int i = 0; i < elements.Count; i++) { if (elements[i].Attribute("name") != null) { //Loading the bar element... if (elements[i].Attribute("name").Value.Equals("bar", StringComparison.InvariantCultureIgnoreCase)) { Bar = (ITexturedRenderable)factory.GenerateRenderable(elements[i], this); Bar.Parent = this; Bar.Offset = Offset; } else if (elements[i].Attribute("name").Value.Equals("border", StringComparison.InvariantCultureIgnoreCase)) { Border = (ITexturedRenderable)factory.GenerateRenderable(elements[i], this); Border.Parent = this; Border.Offset = Offset; } } } FilledColor = color; this.Visible = true; }
//bool show_debugging = false; //bool setting = false; void OnGUI() { GUILayout.Label("Serilog Debugging Settings", EditorStyles.boldLabel); if (!Application.isPlaying) { GUILayout.Label("You can't change this unless the game is running!"); } GUI.enabled = Application.isPlaying; EditorGUILayout.BeginHorizontal(); { var service = GameServiceManager.GetService <Logging>(); if (GUILayout.Button("Debug")) { service.SetLoggingLevel(LogEventLevel.Debug); } if (GUILayout.Button("Error")) { service.SetLoggingLevel(LogEventLevel.Error); } if (GUILayout.Button("Fatal")) { service.SetLoggingLevel(LogEventLevel.Fatal); } if (GUILayout.Button("Info")) { service.SetLoggingLevel(LogEventLevel.Information); } if (GUILayout.Button("Verbose")) { service.SetLoggingLevel(LogEventLevel.Verbose); } } EditorGUILayout.EndHorizontal(); }
public override void Initialize() { Parent.OnMove += OnMove; physicsManager = GameServiceManager.GetService <IPhysicsManager>(); foreach (var body in Bodies.Values) { body.Position = ConvertUnits.ToSimUnits(Parent.Position + ((FarseerUserData)body.UserData).Offset) - ((FarseerUserData)body.UserData).TopLeftOffset; body.Enabled = true; } physicsManager.PhysicsWorld.Step(0.000001f); foreach (var joint in copyJoints) { var data = joint.Value.UserData as FarseerJointUserData; var bodyA = !string.IsNullOrWhiteSpace(data.BodyAName) && Bodies.ContainsKey(data.BodyAName) ? Bodies[data.BodyAName] : null; var bodyB = !string.IsNullOrWhiteSpace(data.BodyBName) && Bodies.ContainsKey(data.BodyBName) ? Bodies[data.BodyBName] : null; var newJoint = FarseerDeserialization.CopyJoint(joint.Value, bodyA, bodyB, physicsManager.PhysicsWorld); physicsManager.PhysicsWorld.AddJoint(newJoint); Joints.Add(joint.Key, newJoint); } copyJoints.Clear(); base.Initialize(); }
public override void Deserialize(XElement element) { IPhysicsManager physicsManager = GameServiceManager.GetService <IPhysicsManager>(); if (physicsManager != null && element != null) { //Read in the max velocity value. float maxVelocity = float.PositiveInfinity; if (element.Element("maxVelocity") != null) { float.TryParse(element.Element("maxVelocity").Value, NumberStyles.Float, CultureInfo.InvariantCulture, out maxVelocity); } MaxVelocity = ConvertUnits.ToSimUnits(maxVelocity); if (element.Element("bodies") != null) { Bodies = FarseerDeserialization.DeserializeBodies(element.Element("bodies"), physicsManager, this); } //Record the primary body primaryBody = GetPrimaryBody(); foreach (var body in Bodies.Values) { body.Enabled = false; body.Position = new Vector2(-10f, -10f); } //A single-body physics component only supports joints that require only a single body (for obvious reasons...) //But we'll expect the FarseerDeserialization class to handle any user error with this. if (element.Element("joints") != null) { this.Joints = FarseerDeserialization.DeserializeJoints(Parent, element.Element("joints"), physicsManager, Bodies); } } }
/// <summary> /// Say Text Handler /// </summary> /// <param name="name"></param> /// <param name="sender"></param> /// <param name="msg"></param> public bool SayMessageReceived(string name, NetConnection sender, NetPipeMessage msg) { // Retrieve the message var chatMessage = msg.GetMessage <Message>(); // this can be null if someone is sending data which is erroneous or they're sending the wrong arguments if (chatMessage == null) { return(false); } // get the sender user var senderUser = GetUser(sender); // make sure this user has been registered properly and has a valid session if (senderUser != null) { // apply the user info to the message (only safe to do serverside) chatMessage.User = senderUser; Log.Debug("Found valid user for {sender} attaching User to message for retransmission", sender); } else { // exit, someone is probably trying to fake being another user Log.Error("Someone caught trying to be another user: {sender}", sender); return(false); } // process message and send to clients which should recieve the message var server = GameServiceManager.GetService <NetworkServer>(); Log.Information("Recieved message:" + chatMessage.Text); // todo: add other channel support // if channel is not supplied then it's for the global channel var channel = GetChannelByName(chatMessage.ChannelName) ?? _globalChannel; if (channel == null) { Log.Error("Error channel not found"); } // add conversation message to history channel.Messages.Add(chatMessage); var participantsCount = channel.Participants.Count; var userConnections = new List <NetConnection>(); // send message to all participants of the channel foreach (var user in channel.Participants) { if (Users.ContainsKey(user)) { userConnections.Add(Users[user]); } } // send message to all clients server.NetworkPipe.SendReliable("say", chatMessage, userConnections); return(true); }
public override void Initialize() { cachedProjectiles = new Dictionary <string, IGameObject>(32); gameObjectFactory = GameServiceManager.GetService <IGameObjectFactory>(); }
public override void Initialize() { gameObjectFactory = GameServiceManager.GetService <IGameObjectFactory>(); base.Initialize(); }
public override void Initialize() { BoundingBox2D.Position = Parent.Position; collisionManager = GameServiceManager.GetService <ICollisionManager>(); base.Initialize(); }
public override void Initialize() { particleManager = GameServiceManager.GetService <IParticleManager>(); base.Initialize(); }