public RheinwerkGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.IsFullScreen = false; // Objektinstanzen erzeugen Input = new InputComponent(this); Input.UpdateOrder = 0; Scene = new SceneComponent(this); Scene.UpdateOrder = 2; Scene.DrawOrder = 0; Simulation = new SimulationComponent(this); Simulation.UpdateOrder = 1; // Komponenten hinzufügen Components.Add(Input); Components.Add(Scene); Components.Add(Simulation); // Update Order bestimmt in welcher Reihenfolge die Komponenten gemalt werden Input.UpdateOrder = 0; Simulation.UpdateOrder = 1; Scene.UpdateOrder = 2; }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; ScreenHeight = graphics.PreferredBackBufferHeight; ScreenWidth = graphics.PreferredBackBufferWidth; Input = new InputComponent(this) { UpdateOrder = 0 }; Components.Add(Input); Simulation = new SimulationComponent(this) { UpdateOrder = 1 }; Components.Add(Simulation); Scene = new SceneComponent(this) { UpdateOrder = 2, DrawOrder = 0 }; Components.Add(Scene); graphics.IsFullScreen = true; }
public RheinwerkGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.IsFullScreen = false; // Fenstergrösse festlegen. graphics.PreferredBackBufferHeight = 2000; graphics.PreferredBackBufferWidth = 3000; // Objektinstanzen erzeugen Input = new InputComponent(this); Input.UpdateOrder = 0; Scene = new SceneComponent(this); Scene.UpdateOrder = 2; Scene.DrawOrder = 0; Simulation = new SimulationComponent(this); Simulation.UpdateOrder = 1; // Komponenten hinzufügen Components.Add(Input); Components.Add(Scene); Components.Add(Simulation); // Update Order bestimmt in welcher Reihenfolge die Komponenten gemalt werden Input.UpdateOrder = 0; Simulation.UpdateOrder = 1; Scene.UpdateOrder = 2; Hud = new HudComponent(this); Hud.UpdateOrder = 3; Hud.DrawOrder = 1; Components.Add(Hud); }
public override bool Equals(SimulationComponent other) { var otherComponent = other as MindsetComponent; if (otherComponent == null) return false; return true; }
public override bool Equals(SimulationComponent other) { var otherComponent = other as AgeingComponent; if (otherComponent == null) return false; return this.TicksPerYear == otherComponent.TicksPerYear && this.AgeLimit == otherComponent.AgeLimit; }
public override bool Equals(SimulationComponent other) { var otherComponent = other as InfectionComponent; if (otherComponent == null) return false; throw new NotImplementedException(); }
public override bool Equals(SimulationComponent other) { var otherComponent = other as DiseaseHealingComponent; if (otherComponent == null) return false; return true; }
public OctoGame() : base() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; Window.Title = "OctoAwesome"; graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; IsMouseVisible = true; Window.AllowUserResizing = false; TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 15); int viewrange; if (int.TryParse(ConfigurationManager.AppSettings["Viewrange"], out viewrange)) { if (viewrange < 1) { throw new NotSupportedException("Viewrange in app.config darf nicht kleiner 1 sein"); } SceneControl.VIEWRANGE = viewrange; } //int viewheight; //if (int.TryParse(ConfigurationManager.AppSettings["Viewheight"], out viewheight)) //{ // if (viewheight < 1) // throw new NotSupportedException("Viewheight in app.config darf nicht kleiner 1 sein"); // SceneComponent.VIEWHEIGHT = viewheight; //} ResourceManager.CacheSize = ((viewrange * 2) + 1) * ((viewrange * 2) + 1) * 5 * 2; input = new InputComponent(this); input.UpdateOrder = 1; Components.Add(input); simulation = new SimulationComponent(this); simulation.UpdateOrder = 3; Components.Add(simulation); player = new PlayerComponent(this, input, simulation); player.UpdateOrder = 2; Components.Add(player); camera = new CameraComponent(this, player); camera.UpdateOrder = 4; Components.Add(camera); screens = new ScreenComponent(this, player, camera); screens.UpdateOrder = 8; screens.DrawOrder = 4; Components.Add(screens); }
public RheinwerkGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.IsFullScreen = false; IsMouseVisible = true; Input = new InputComponent(this); Input.UpdateOrder = 0; Components.Add(Input); Screen = new ScreenComponent(this); Screen.UpdateOrder = 1; Screen.DrawOrder = 2; Components.Add(Screen); Local = new LocalComponent(this); Local.UpdateOrder = 2; Components.Add(Local); var client = new ClientComponent(this); Client = client; client.UpdateOrder = 3; Components.Add(client); var server = new ServerComponent(this); Server = server; server.UpdateOrder = 4; Components.Add(server); Simulation = new SimulationComponent(this); Simulation.UpdateOrder = 5; Components.Add(Simulation); Scene = new SceneComponent(this); Scene.UpdateOrder = 6; Scene.DrawOrder = 0; Components.Add(Scene); Hud = new HudComponent(this); Hud.UpdateOrder = 7; Hud.DrawOrder = 1; Components.Add(Hud); Music = new MusicComponent(this); Music.UpdateOrder = 8; Components.Add(Music); Sound = new SoundComponent(this); Sound.UpdateOrder = 9; Components.Add(Sound); // Einstellungen laden Settings = Settings.LoadSettings(); }
private void DoInteract(SimulationComponent simulation, IInteractor interactor, IInteractable interactable) { var quest = simulation.World.Quests.SingleOrDefault(q => q.Name == "Heidis Quest"); before.Visible = quest.State == QuestState.Inactive; after.Visible = quest.State == QuestState.Active && quest.CurrentProgress.Id == "return"; Game1 game = simulation.Game as Game1; simulation.ShowInteractionScreen(interactor as Player, new DialogScreen(game.Screen, this, interactor as Player, dialog)); }
public void Tick() { while (this.updatedComponents.Count > 0) { try { SimulationComponent component = this.updatedComponents.Dequeue(); Console.WriteLine($"Updating Component {component.GetType().Name}"); component.Update(); } catch (Exception e) { Console.WriteLine($"An error occurred{Environment.NewLine}{e}"); } } }
public RheinWerkGameWindows() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; Input = new InputComponent(this); Input.UpdateOrder = 0; Components.Add(Input); Simulation = new SimulationComponent(this); Simulation.UpdateOrder = 1; Components.Add(Simulation); Scene = new SceneComponent(this); Scene.UpdateOrder = 2; Components.Add(Scene); Hud = new HudComponent(this); Hud.UpdateOrder = 3; Hud.DrawOrder = 1; Components.Add(Hud); }
public AdventureGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; World = new GameWorld(this); Input = new InputComponent(this); Input.UpdateOrder = 0; Components.Add(Input); Simulation = new SimulationComponent(this); Simulation.UpdateOrder = 1; Components.Add(Simulation); Scene = new SceneComponent(this); Scene.UpdateOrder = 2; Scene.DrawOrder = 0; Components.Add(Scene); }
public OctoGame() : base() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 1080; graphics.PreferredBackBufferHeight = 720; Content.RootDirectory = "Content"; Window.Title = "OctoAwesome"; IsMouseVisible = true; Window.AllowUserResizing = true; TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 15); int viewrange; if (int.TryParse(SettingsManager.Get("Viewrange"), out viewrange)) { if (viewrange < 1) { throw new NotSupportedException("Viewrange in app.config darf nicht kleiner 1 sein"); } SceneControl.VIEWRANGE = viewrange; } Simulation = new SimulationComponent(this); Simulation.UpdateOrder = 4; Components.Add(Simulation); Player = new PlayerComponent(this); Player.UpdateOrder = 2; Components.Add(Player); Camera = new CameraComponent(this); Camera.UpdateOrder = 3; Components.Add(Camera); Screen = new ScreenComponent(this); Screen.UpdateOrder = 1; Screen.DrawOrder = 1; Components.Add(Screen); KeyMapper = new KeyMapper(Screen); Window.ClientSizeChanged += (s, e) => { if (Window.ClientBounds.Height == graphics.PreferredBackBufferHeight && Window.ClientBounds.Width == graphics.PreferredBackBufferWidth) { return; } graphics.PreferredBackBufferHeight = Window.ClientBounds.Height; graphics.PreferredBackBufferWidth = Window.ClientBounds.Width; graphics.ApplyChanges(); }; KeyMapper.RegisterBinding("octoawesome:debugBinding", "Debug"); KeyMapper.AddKey("octoawesome:debugBinding", Keys.F); KeyMapper.AddAction("octoawesome:debugBinding", type => { Console.WriteLine(type); }); KeyMapper.RegisterBinding("octoawesome:forward", "Forward"); KeyMapper.AddKey("octoawesome:forward", Keys.W); }
/// <summary> /// Update /// </summary> /// <param name="simulation">Simulation.</param> /// <param name="items">Items.</param> public void Update(SimulationComponent simulation, Dictionary <int, ItemCacheEntry> items) { Message m; while (messages.TryDequeue(out m)) { switch (m.MessageType) { case MessageType.ClientClose: Close(null, true); break; case MessageType.ClientUpdateVelocity: Player.Velocity = new Vector2( BitConverter.ToSingle(m.Payload, 0), BitConverter.ToSingle(m.Payload, 4)); break; case MessageType.ClientTriggerAttack: Player.AttackSignal = true; break; case MessageType.ClientQuestUpdate: using (MemoryStream stream = new MemoryStream(m.Payload)) { using (BinaryReader br = new BinaryReader(stream)) { string quest = br.ReadString(); string progress = br.ReadString(); QuestState state = (QuestState)br.ReadByte(); switch (state) { case QuestState.Active: simulation.SetQuestProgress(quest, progress); break; case QuestState.Failed: simulation.SetQuestFail(quest, progress); break; case QuestState.Succeeded: simulation.SetQuestSuccess(quest, progress); break; } } } break; case MessageType.ClientTransferItem: int itemId = BitConverter.ToInt32(m.Payload, 0); int senderId = BitConverter.ToInt32(m.Payload, 4); int receiverId = BitConverter.ToInt32(m.Payload, 8); Item item = null; if (items.ContainsKey(itemId)) { item = items[itemId].Item; } Item sender = null; if (items.ContainsKey(senderId)) { sender = items[senderId].Item; } Item receiver = null; if (items.ContainsKey(receiverId)) { receiver = items[receiverId].Item; } if (item != null && sender != null) { simulation.Transfer(item, sender as IInventory, receiver as IInventory); } break; } } }
public override bool Equals(SimulationComponent other) { return (other as DebugInfectionComponent) != null; }
private void DoInteract(SimulationComponent simulation, IInteractor interactor, IInteractable interactable) { RheinwerkGame game = simulation.Game as RheinwerkGame; simulation.ShowInteractionScreen(interactor as Player, new ShoutScreen(game.Screen, this, "Bleib ein Weilchen und hoer zu!")); }
public void UpdateComponent(SimulationComponent component) { this.updatedComponents.Enqueue(component); }
private SimulationComponent[] GetSimComponents(EComponentTag[] tags) { SimulationComponent[] comps = new SimulationComponent[tags.Length]; for (int i = 0; i < tags.Length; ++i) { SimulationComponent c = null; // | dj | not the most secure way but it should work. switch (tags[i]) { case EComponentTag.AgeingComponent: c = new AgeingComponent(110); break; case EComponentTag.InfectionComponent: c = new InfectionComponent(); break; case EComponentTag.DiseaseTickComponent: c = new DiseaseTickComponent(); break; case EComponentTag.DiseaseDeathComponent: c = new DiseaseDeathComponent(); break; case EComponentTag.DiseaseHealingComponent: c = new DiseaseHealingComponent(); break; case EComponentTag.MindsetComponent: c = new MindsetComponent(); break; case EComponentTag.MovementComponent: c = new MovementComponent(); break; } comps[i] = c; } // if no (diseasetick-)component given: debug-infection //if (comps.Length == 0) comps = new SimulationComponent[1] { new DebugInfectionComponent() }; if (!comps.Any(x => x is InfectionComponent)) { SimulationComponent[] temp = new SimulationComponent[comps.Length + 1]; comps.CopyToOtherArray(temp); temp[comps.Length] = new DebugInfectionComponent(); comps = temp; temp = null; } return comps; }
public OctoGame() { //graphics = new GraphicsDeviceManager(this); //graphics.PreferredBackBufferWidth = 1080; //graphics.PreferredBackBufferHeight = 720; //Content.RootDirectory = "Content"; Title = "OctoAwesome"; IsMouseVisible = true; Icon = Properties.Resources.octoawesome; //Window.AllowUserResizing = true; Settings = new Settings(); ResourceManager.Settings = Settings; //TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 15); int width = 1080, height = 720; if (Settings.KeyExists("Width")) { width = Settings.Get <int>("Width"); } if (Settings.KeyExists("Height")) { height = Settings.Get <int>("Height"); } Window.ClientSize = new Size(width, height); if (Settings.KeyExists("EnableFullscreen") && Settings.Get <bool>("EnableFullscreen")) { Window.Fullscreen = true; } if (Settings.KeyExists("Viewrange")) { var viewrange = Settings.Get <int>("Viewrange"); if (viewrange < 1) { throw new NotSupportedException("Viewrange in app.config darf nicht kleiner 1 sein"); } SceneControl.VIEWRANGE = viewrange; } Assets = new AssetComponent(this); Components.Add(Assets); Simulation = new SimulationComponent(this); Simulation.UpdateOrder = 4; Components.Add(Simulation); Player = new PlayerComponent(this); Player.UpdateOrder = 2; Components.Add(Player); Camera = new CameraComponent(this); Camera.UpdateOrder = 3; Components.Add(Camera); Screen = new ScreenComponent(this); Screen.UpdateOrder = 1; Screen.DrawOrder = 1; Components.Add(Screen); KeyMapper = new KeyMapper(Screen, Settings); /*Resize += (s, e) => * { * //if (Window.ClientBounds.Height == graphics.PreferredBackBufferHeight && * // Window.ClientBounds.Width == graphics.PreferredBackBufferWidth) * // return; * * //graphics.PreferredBackBufferHeight = Window.ClientBounds.Height; * //graphics.PreferredBackBufferWidth = Window.ClientBounds.Width; * //graphics.ApplyChanges(); * };*/ SetKeyBindings(); }
public OctoGame() : base() { graphics = new GraphicsDeviceManager(this); int width; if (int.TryParse(SettingsManager.Get("Width"), out width)) { if (width < 1) { throw new NotSupportedException("Width in app.config darf nicht kleiner 1 sein"); } graphics.PreferredBackBufferWidth = width; } else { graphics.PreferredBackBufferWidth = 1080; } int height; if (int.TryParse(SettingsManager.Get("Height"), out height)) { if (height < 1) { throw new NotSupportedException("Height in app.config darf nicht kleiner 1 sein"); } graphics.PreferredBackBufferHeight = height; } else { graphics.PreferredBackBufferHeight = 720; } Content.RootDirectory = "Content"; Window.Title = "OctoAwesome"; IsMouseVisible = true; Window.AllowUserResizing = true; TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 15); bool enablefullscreen; if (bool.TryParse(SettingsManager.Get("EnableFullscreen"), out enablefullscreen) && enablefullscreen) { Fullscreen(); } int viewrange; if (int.TryParse(SettingsManager.Get("Viewrange"), out viewrange)) { if (viewrange < 1) { throw new NotSupportedException("Viewrange in app.config darf nicht kleiner 1 sein"); } SceneControl.VIEWRANGE = viewrange; } Simulation = new SimulationComponent(this); Simulation.UpdateOrder = 4; Components.Add(Simulation); Player = new PlayerComponent(this); Player.UpdateOrder = 2; Components.Add(Player); Camera = new CameraComponent(this); Camera.UpdateOrder = 3; Components.Add(Camera); Screen = new ScreenComponent(this); Screen.UpdateOrder = 1; Screen.DrawOrder = 1; Components.Add(Screen); KeyMapper = new KeyMapper(Screen); Window.ClientSizeChanged += (s, e) => { if (Window.ClientBounds.Height == graphics.PreferredBackBufferHeight && Window.ClientBounds.Width == graphics.PreferredBackBufferWidth) { return; } graphics.PreferredBackBufferHeight = Window.ClientBounds.Height; graphics.PreferredBackBufferWidth = Window.ClientBounds.Width; graphics.ApplyChanges(); }; SetKeyBindings(); }