void CheckInput() { Point direction = new Point(0, 0); if (InputManager.KeyDown(GameSettings.Up) || InputManager.KeyDown(GameSettings.Alt_Up)) { direction.Y = -1; startingFrame = new Point(0, 3); } else if (InputManager.KeyDown(GameSettings.Down) || InputManager.KeyDown(GameSettings.Alt_Down)) { direction.Y = 1; startingFrame = new Point(0, 0); } if (InputManager.KeyDown(GameSettings.Right) || InputManager.KeyDown(GameSettings.Alt_Right)) //Detta är en "if" så man ska kunna gå diagonalt. Map klassen har stöd för det. { direction.X = 1; startingFrame = new Point(0, 2); } else if (InputManager.KeyDown(GameSettings.Left) || InputManager.KeyDown(GameSettings.Alt_Left)) { direction.X = -1; startingFrame = new Point(0, 1); } //Här ska frames bytas senare när vi har en sprite if (direction != new Point(0, 0)) { ActorEventArgs args = new ActorEventArgs(PlayerEventType.CheckDirection); args.Direction = direction; args.Position = position; OnAction(args); } }
private void ctlActors_ActorDrop(object sender, ActorEventArgs e) { ctlWait.Show("Saving actor information..."); BuilderServiceClient client = ServiceManager.CreateBuilderServiceClient(); client.SaveActorCompleted += new EventHandler <SaveActorCompletedEventArgs>(client_SaveActorCompleted); client.SaveActorAsync(_token, e.Actor.ToString()); }
public virtual void Render(FrameEventArgs frameEventArgs) { FramebufferScene.Use(); GL.PushMatrix(); GL.ClearColor(Color.Black); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); // RenderOriginAxes(); // Set up uniforms ShaderDefault.Uniforms.SetValue("lightPos", LightPosition); ShaderDefault.Uniforms.SetValue("cameraPos", Camera.Position); ShaderDefault.Uniforms.SetValue("v", Camera.GetTransformation()); ShaderDefault.Uniforms.SetValue("p", ProjectionMatrix); GL.ActiveTexture(TextureUnit.Texture1); GL.BindTexture(TextureTarget.Texture2D, TextureRandom.Id); foreach (var actor in Scene.Actors) { if (!actor.RenderOutsideFrustum && !Camera.FrustumContains(actor.BoundingBox)) { continue; } var e = new ActorEventArgs(actor); ActorPreRender?.Invoke(this, e); actor.Render(this, Camera); ActorPostRender?.Invoke(this, e); } GL.PopMatrix(); FramebufferScene.Release(); FramebufferInterface.Use(); GL.ClearColor(0, 0, 0, 0); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); Nvg.BeginFrame(Window.Width, Window.Height, 1); Nvg.Save(); UserInterface.Render(this, Nvg, frameEventArgs); Nvg.Restore(); Nvg.EndFrame(); FramebufferInterface.Release(); ShaderScreen.Use(); DrawFullscreenQuad(FramebufferScene.Texture, FramebufferInterface.Texture); ShaderScreen.Release(); }
/// <summary> /// Allt som skickas av player via events. /// </summary> /// <param name="args"></param> private void HandlePlayer(ActorEventArgs args) { if (args.EventType == PlayerEventType.CheckDirection) //spelaren försöker gå i en viss riktning. { world.PlayerEvent(args); } else if (args.EventType == PlayerEventType.EnterTile) //spelaren är framme på en tile. { world.PlayerEvent(args); } }
/// <summary> /// Om map tar emot ett event från spelaren, t.ex om spelaren /// försöker gå i en viss riktning eller hamnat på en ny tile. /// </summary> /// <param name="args"></param> public void PlayerEvent(ActorEventArgs args) { if (args.EventType == PlayerEventType.CheckDirection) { CheckMovement(args.Position, args.Direction); } else if (args.EventType == PlayerEventType.EnterTile) { TileCheck(args.Position); } }
public void Move(GameTime gameTime) { Vector2 dir = new Vector2(destination.X - position.X, destination.Y - position.Y); Vector2 norm = Vector2.Normalize(dir); //Kolla avstånd till målet eller om actorn råkat gå för långt. if (Vector2.Distance(position, destination) > speed * gameTime.ElapsedGameTime.TotalSeconds) { position += speed * norm * (float)gameTime.ElapsedGameTime.TotalSeconds; } else //är framme och ska sluta röra sig. Kallar ett event att actorn är framme på en tile. { position = destination; moving = false; ActorEventArgs args = new ActorEventArgs(PlayerEventType.EnterTile); args.Position = position; OnAction(args); } }
private void tile_ActorDrop(object sender, ActorEventArgs e) { Tile tile = sender as Tile; if (tile != null) { ctlWait.Show("Saving actor information..."); e.Actor.OwnerID = tile.Place.ID; tile.Place.Actors.Add(e.Actor); this.PlaceChanged(new PlaceEventArgs(tile.Place)); RdlTagCollection tags = new RdlTagCollection(); tags.Add(e.Actor); tags.AddRange(e.Actor.Properties.ToArray()); //BuilderServiceClient client = ServiceManager.CreateBuilderServiceClient(); //client.SaveActorCompleted += new EventHandler<SaveActorCompletedEventArgs>(client_SaveActorCompleted); //client.SaveActorAsync(_token, tags.ToString()); this.TileClick(tile); } }
public virtual void Update(FrameEventArgs frameEventArgs) { Camera.Update(this); foreach (var actor in Scene.Lights) { actor.Update(this); } foreach (var actor in Scene.Actors) { if (!actor.UpdateOutsideFrustum && !Camera.FrustumContains(actor.BoundingBox)) { continue; } var e = new ActorEventArgs(actor); ActorPreUpdate?.Invoke(this, e); actor.Update(this); ActorPostUpdate?.Invoke(this, e); } UserInterface.Update(this, frameEventArgs); }
private void lstActors_ActorDrop(object sender, ActorEventArgs e) { // Add the actor to the current place and reload the place. ServerManager.Instance.SendCommand("ADMINADDACTOR", e.Actor.Name, this.Player.X, this.Player.Y, this.Player.Z); }
/// <summary> /// Handles the creation of a new actor within an <see cref="ICast"/> instance. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Arguments.</param> protected virtual void HandleActorCreatedInCast(object sender, ActorEventArgs args) { SubscribeReporter(args.Actor); }
void OnBeginThen(object sender, ActorEventArgs ev) { handler.BeginThen(ev.Actor, ev.Actor.ScenarioIdentity); }
void OnEndGiven(object sender, ActorEventArgs ev) { handler.EndGiven(ev.Actor, ev.Actor.ScenarioIdentity); }
/// <summary> /// Handles the addition of a new actor to an <see cref="ICast"/> instance. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Arguments.</param> protected virtual void HandleActorAddedToCast(object sender, ActorEventArgs args) { // Intentional no-op, method is here for subclasses to override. }
public void OnAction(ActorEventArgs e) { //Om detta vissar fel så måste du uppdatera visual studio. Det är korrekt, ändra inte. Action.Invoke(this, e); }
private void OnAvatarListItemClick(object sender, ActorEventArgs e) { this.ActorClick(this, e); }
private void OnAvatarListItemActorDrop(object sender, ActorEventArgs e) { this.ActorDrop(this, e); }
private void ctlActors_ActorClick(object sender, ActorEventArgs e) { ctlActorDetails.Actor = e.Actor; this.SetMainPanel(PanelType.ActorDetails); }