void OnDestroy() { if (this == m_Instance) { m_Instance = null; } }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); /* spriteBatch.Begin(SpriteSortMode.Immediate, * BlendState.NonPremultiplied, * SamplerState.LinearClamp, * DepthStencilState.Default, * RasterizerState.CullCounterClockwise, * null, Matrix.Identity);*/ //NOTE: Should create and loop through tempScreenList here in case a screen is added or removed while drawing foreach (AbstractScreen screen in screens) { if (screen.IsVisible) { screen.Draw(spriteBatch); } } if (DebugScreen.GetInstance().IsVisible) { DebugScreen.GetInstance().Draw(spriteBatch); } spriteBatch.End(); base.Draw(gameTime); }
protected override void Initialize() { SetWindowOnSurface(); ScreenManager screenManager = new ScreenManager(this); this.Components.Add(screenManager); var backgroundscreen = new BackgroundScreen(); screenManager.AddScreen(backgroundscreen); var debugScreen = new DebugScreen(screenManager, false); screenManager.Game.Components.Add(debugScreen); this.Services.AddService(typeof(IDebugScreen), debugScreen); PopulationSimulator populationSimulator = new PopulationSimulator(0, 0); var swarmEmitterComponent = new SwarmEmitterComponent(populationSimulator); var swarmAnalysisComponent = new SwarmAnalysisComponent(this.Services.GetService(typeof(IDebugScreen)) as IDebugScreen); SwarmScreen1 swarmScreen = new SwarmScreen1(swarmEmitterComponent, swarmAnalysisComponent, populationSimulator); screenManager.AddScreen(swarmScreen); ControlClient controlClient = new ControlClient(swarmScreen, swarmAnalysisComponent); this.Services.AddService(typeof(IControlClient), controlClient); base.Initialize(); SoundEngine.Init(); }
public static void OnInject() { DebugScreen.Instantiate(); DebugScreen.Log("Tridev Loader started!"); LoadMods(); }
public void Update(Vector3 target) { if (!isCameraControllable || isSoftLocked) { if (targetObject == null) { cameraTarget = target; } else { cameraTarget = targetObject.Position; } } //Camera update for top-down view //cameraPosition = new Vector3((cameraTarget.X ), (cameraTarget.Y + (5 + (5 * currentZoom))), (cameraTarget.Z)); //cameraViewMatrix = Matrix.CreateLookAt(cameraPosition, cameraTarget, new Vector3(1, 0, 0)); // cameraPosition =cameraRotation+ new Vector3((cameraTarget.X - (5 * currentZoom)), (cameraTarget.Y + (5 + (5 * currentZoom))), (cameraTarget.Z - (5 * currentZoom))); // cameraPosition = cameraRotation + cameraPosition; DebugScreen.GetInstance().SetDebugListing("Camera Rotation:", "" + rotationRadians); Matrix rotationMatrix = Matrix.CreateRotationY(-rotationRadians); cameraOffset = new Vector3(5 * currentZoom, 5 * currentZoom, 0); Vector3 transformedReference = Vector3.Transform(cameraOffset, rotationMatrix); cameraPosition = transformedReference + cameraTarget; cameraViewMatrix = Matrix.CreateLookAt(cameraPosition, cameraTarget, Vector3.Up); // cameraPosition = new Vector3((cameraTarget.X - (5 * currentZoom)), (cameraTarget.Y + (5 + (5 * currentZoom))), (cameraTarget.Z - (5 * currentZoom))); //cameraProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), graphics.Viewport.AspectRatio, 1.0f, 10000.0f); }
private void Start() { animatorControl = GetComponent <PlayerAnimator>(); verticalSpeed = minFall; character = GetComponent <CharacterController>(); screen = DebugScreen.GetInstance(); }
public void NotifyPlayerStopReady() { --m_NbPlayersReady; DebugScreen.PrintVar <int>("ready", m_NbPlayersReady); UIManager.Instance.HideSelectableMessage(sessionStartMsg); }
void Start() { if (instance != null) { Destroy(this); } else { instance = this; debugScreen = GameObject.Find("Debug Screen"); world = GameObject.Find("World").GetComponent <World>(); screen = DebugScreen.GetInstance(); player = GameObject.Find("Player"); settingMenu = GetComponent <SettingMenu>(); if (MainScene == SceneManager.GetActiveScene().buildIndex) { inputController = PlayerInputController.GetInstance(); } else { inputController = EditInputController.GetInstance(); } WorldInit(); } }
private void FixedUpdate() { if (this.sceneLoadTimer == 0) { var allObjects = FindObjectsOfType <GameObject>(); bool foundManager = false; foreach (var obj in allObjects) { var gameNetworkManager = obj.GetComponent <GameNetworkManager>(); if (gameNetworkManager) { foundManager = true; DebugScreen.Log("Found game network manager, dumping channel data."); foreach (var channel in gameNetworkManager.channels) { DebugScreen.Log(channel.ToString()); } } } if (!foundManager) { DebugScreen.Log("No network manager was found."); } this.sceneLoadTimer = -1; } this.sceneLoadTimer = this.sceneLoadTimer > 0 ? this.sceneLoadTimer - 1 : this.sceneLoadTimer; }
protected override void Initialize() { StaticClassSerializer.Load(typeof(PlayerData), "data.bin"); // Manage inputs like keyboard or gamepad Components.Add(new InputHandler(this)); // Display FPS at the top left screen's corner Components.Add(new FrameRateCounter(this)); _stateManager = new GameStateManager(this); Components.Add(_stateManager); // Screens TitleScreen = new TitleScreen(this, _stateManager); DebugScreen = new DebugScreen(this, _stateManager); PatternTestScreen = new PatternTestScreen(this, _stateManager); GameConfigurationScreen = new GameConfigurationScreen(this, _stateManager); GameplayScreen = new GameplayScreen(this, _stateManager); LeaderboardScreen = new LeaderboardScreen(this, _stateManager); ImprovementScreen = new ImprovementScreen(this, _stateManager); GameOverScreen = new GameOverScreen(this, _stateManager); OptionsScreen = new OptionsScreen(this, _stateManager); KeyboardInputsScreen = new KeyboardInputsScreen(this, _stateManager); GamepadInputsScreen = new GamepadInputsScreen(this, _stateManager); _stateManager.ChangeState(TitleScreen); ParticleManager = new ParticleManager <ParticleState>(1024 * 20, ParticleState.UpdateParticle); base.Initialize(); }
protected override void Initialize() { ScreenManager screenManager = new ScreenManager(this); this.Components.Add(screenManager); var backgroundscreen = new BackgroundScreen(); screenManager.AddScreen(backgroundscreen); var debugScreen = new DebugScreen(screenManager, false); screenManager.Game.Components.Add(debugScreen); this.Services.AddService(typeof(IDebugScreen), debugScreen); //Recipe[] recipes = new Recipe[1]; //recipes[0] = new Recipe(StockRecipies.Stable_A); PopulationSimulator populationSimulator = new PopulationSimulator(0, 0); var swarmEmitterComponent = new SwarmEmitterComponent(populationSimulator); var swarmAnalysisComponent = new SwarmAnalysisComponent(this.Services.GetService(typeof(IDebugScreen)) as IDebugScreen); SwarmScreen1 swarmScreen = new SwarmScreen1(swarmEmitterComponent, swarmAnalysisComponent, populationSimulator); screenManager.AddScreen(swarmScreen); #if NETFX_CORE ControlClient controlClient = new ControlClient(swarmScreen, this.Services.GetService(typeof(IAudio)) as IAudio); #else ControlClient controlClient = new ControlClient(swarmScreen)); #endif this.Services.AddService(typeof(IControlClient), controlClient); base.Initialize(); //SoundEngine.Init(); }
public void LoadAssemblies() { // Get the directory assemblies are stored in, then gather all the files with a .DLL extension. var librariesFolder = Path.Combine(AppContext.BaseDirectory, "mods", "libraries"); // Create the libraries folder if it doesn't exist. if (!Directory.Exists(librariesFolder)) { Directory.CreateDirectory(librariesFolder); } var libraryFiles = Directory.GetFiles(librariesFolder).Where(x => x.ToUpper().EndsWith(".DLL")).ToList(); var libraryAssemblies = libraryFiles.Select(x => Assembly.LoadFrom(x)).ToList(); // Store assemblies based on their name, used to remove duplicate assemblies by looking at their version. var duplicateAssemblies = new Dictionary <string, List <Assembly> >(); foreach (var assembly in libraryAssemblies) { var name = assembly.GetName().Name; if (!duplicateAssemblies.ContainsKey(name)) { duplicateAssemblies.Add(name, new List <Assembly>()); } duplicateAssemblies[name].Add(assembly); } // Unloads any duplicate assemblies. foreach (var keyValuePair in duplicateAssemblies) { Assembly selectedAssembly = null; foreach (var assembly in keyValuePair.Value) { if (selectedAssembly == null) { selectedAssembly = assembly; } else { var selectedVersion = selectedAssembly.GetName().Version; var duplicateVersion = assembly.GetName().Version; if (selectedVersion < duplicateVersion) { selectedAssembly = assembly; } else { DebugScreen.Log($"Rejected duplicate library with version {duplicateVersion}," + $" using {selectedVersion}"); } } } if (selectedAssembly != null) { DebugScreen.Log($"Loaded external library {selectedAssembly.GetName().Name}"); } } }
/// Let player join public void NotifyPlayerJoin() { ++m_NbPlayersJoin; DebugScreen.PrintVar <int>("join", m_NbPlayersJoin); // if needed, hide Start Party message UIManager.Instance.HideSelectableMessage(sessionStartMsg); }
public static void Terminate() { DebugScreen tDebug = ( DebugScreen )GameObject.FindObjectOfType(typeof(DebugScreen)); if (tDebug != null) { Destroy(tDebug.gameObject); } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Update(GameTime gameTime) { // Allows the game to exit /* if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) * this.Exit();*/ if (DebugScreen.GetInstance().IsActive) { DebugScreen.GetInstance().HandleInput(gameTime, input); DebugScreen.GetInstance().Update(gameTime); } input.Update(this.Game.IsMouseVisible); tempScreensList.Clear(); foreach (AbstractScreen screen in screens) { tempScreensList.Add(screen); } foreach (AbstractScreen screen in tempScreensList) { if (screen.HasFocus) { screen.HandleInput(gameTime, input); } if (screen.IsActive) { screen.Update(gameTime); } } //Any controls that are accessible to all screens will go here (i.e. toggle fullscreen) if (input.CurrentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F3) && !input.PreviousKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F3)) { DebugScreen.GetInstance().IsVisible = !DebugScreen.GetInstance().IsVisible; } /* if (input.CurrentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Back)) * { * ToggleFullscreen(); * //graphics.ToggleFullScreen(); * }*/ base.Update(gameTime); }
public void NotifyPlayerReady() { ++m_NbPlayersReady; DebugScreen.PrintVar <int>("ready", m_NbPlayersReady); if (AreAllJoiningPlayersReady()) { UIManager.Instance.ShowAndSelectMessage(sessionStartMsg); } }
void Start() { camTrans = transform.Find("Main Camera"); screen = DebugScreen.GetInstance(); world = GameObject.Find("World").GetComponent <World>(); promptText = GameObject.Find("Selection prompt").GetComponent <Text>(); //设置Enermy默认模型 enermyModelPrefab = PrefabManager.GetInstance().GetPrefab(PrefabType.Breaker); InitMonsterModel(); }
private void Awake() { if (!instance) { instance = this; } else { Destroy(this.gameObject); } }
public PlayerInputMessageHandler( MessageProcessor messageProcessor, PlayerRegistry playerRegistry, BallKick ballKick, DebugScreen debugScreen ) : base(messageProcessor) { _playerRegistry = playerRegistry; _ballKick = ballKick; _debugScreen = debugScreen; }
public void Render(GraphicsDevice graphicsDevice) { graphicsDevice.SetVertexBuffer(VertexBuffer); graphicsDevice.Indices = IndexBuffer; DebugScreen.GetInstance().PolysDrawn += Indices.Length / 3; DebugScreen.GetInstance().VertsDrawn += Vertices.Length; if (Vertices.Length > 0) { graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, Vertices.Length, 0, Indices.Length / 3); } }
public ScreenManager(Game game, bool isDebuging = false) : base(game) { _isDebugging = isDebuging; _screens = new List <Screen>(); ServicesHelper.AddService <ScreenManager>(this); if (_isDebugging) { _debugScreen = new DebugScreen(Game); _debugScreen.LoadContent(); } }
private void OnEnterPartyPhase() { DebugScreen.Print(1, "Party starting"); // VISUAL: display the START message on GUI layer (prefab also on GUI layer just in case) UIManager.Instance.ShowMessage("START"); // AUDIO: play the in-game BGM MusicManager.Instance.Play(); // After some time, enable the avatars to move CharacterManager.Instance.StartControlAllCharacters(); }
private void Update() { if (debugScreenOptions.Count > 0) { UITreeView.Item parent = DebugScreen.AddContentItem(null, "bugreport", "Bug report", null, null); DebugScreen.AddContentItem(parent, "createreport", "Create report", null, CreateReportFromDebugScreen); DebugScreen.AddContentItem(parent, "addscreenshot", "Add screenshot to last report", null, AddScreenshotToLastReport); DebugScreen.AddContentItem(parent, "uploadreport", "Upload last report", null, UploadLastReport); DebugScreen.AddContentItem(parent, "copylinktoclipoard", "Copy last upload link to clipboard", null, CopyLastLinkToClipboard); DebugScreen.AddContentItem(parent, "openreport", "Open last report", null, OpenReportFromDebugScreen); DebugScreen.AddContentItem(parent, "openfolder", "Open report folder", null, OpenFolderFromDebugScreen); Destroy(this); } }
public void Load(ContentManager content) { _debugScreen = new DebugScreen(); _debugScreen.LoadContent(content); _transitionManager = new TransitionManager(); _transitionManager.Load(content); _guiRenderer = new GUIRenderer(); _guiRenderer.Load(content); _mainMenuLogic = new MainMenuLogic(); _mainMenuLogic.Load(content); _radialBlurLogic = new RadialBlurLogic(); _radialBlurLogic.Load(content); _radialBlurRenderer = new RadialBlurRenderer(); _radialBlurRenderer.Load(content); _pixelizerLogic = new PixelizerLogic(); _pixelizerLogic.Load(content); _pixelizerRenderer = new PixelizerRenderer(); _pixelizerRenderer.Load(content); _bokehLogic = new BokehLogic(); _bokehLogic.Load(content); _bokehRenderer = new BokehRenderer(); _bokehRenderer.Load(content); _particlePhysicsLogic = new ParticlePhysicsLogic(); _particlePhysicsLogic.Load(content); _particlePhysicsRenderer = new ParticlePhysicsRenderer(); _particlePhysicsRenderer.Load(content); _ssLogic = new SubsurfaceLogic(); _ssLogic.Load(content); _ssRenderer = new SubsurfaceRenderer(); _ssRenderer.Load(content); _ftLogic = new FTLogic(); _ftLogic.Load(content); _ftRenderer = new FTRenderer(); _ftRenderer.Load(content); _meshLoader = new MeshLoader(); _meshLoader.Load(content); }
/* Warp the avatar out of the scene */ /* alternatives: * a) Warp() is public, the warper calls Warp(), Warp() calls the Character Manager * b) Warp() is private, the warper sets the avatar's intention to warp, FixedUpdate() converts * intention to action Warp(), Warp() calls the Character Manager * c) there is no Warp() here and the warper directly calls the Character Manager * chosen: a) (allows to add some extra such as StopMotion or some animation) */ public void Warp() { DebugScreen.Print(0, "{0} warps.", this); control.StopControl(); // motor.StopMotion(); /* add some warping view here, should last around 1 second */ // yield return new WaitForSeconds(1.0f); CharacterManager.Instance.DespawnCharacter(master.PlayerId); // if the last avatar has been removed, end the session if (CharacterManager.Instance.RemainingCharacterNb == 0) { SceneManager.LoadScene(Scenes.ScoreScreen); // SessionManager.Instance.Reset(); } }
// Use this for initialization void Start() { enemiesParent = GameObject.Find("Enemies"); enemyTypeList = new List <int>(); hordeWave = new List <int>(); enemyList = new List <GameObject>(); Enemy.Death += EnemyKilled; if (DebugScreen.GetInstance()) { DebugScreen.GetInstance().AddButton("Kill All Enemies", KillAllEnemies); DebugScreen.GetInstance().AddButton("NextWave", NextWave); } chanceOfHardRound = initialChanceOfHardRound; timerWaves = timeBetweenWaves; aSource = GetComponent <AudioSource>(); AudioManager.Get().AddSound(aSource); }
private void Initialize() { loader = LoaderManager.Get(); Tower.TowerDestroyed += GameOver; LightStand.LightFinished += GameWon; if (DebugScreen.GetInstance()) { DebugScreen.GetInstance().AddButton("ResetGameScene", ResetGame); DebugScreen.GetInstance().AddButton("Add Players Level", LevelUpPlayers); } aSource = GetComponent <AudioSource>(); AudioManager.Get().AddMusic(aSource); mage = GameObject.Find("Mage"); archer = GameObject.Find("Archer"); GiveOrbsToPlayers(); isInitialized = true; }
/// <summary> /// Adds the given item to the item registry. /// </summary> /// <param name="owner">The mod associated with the registered item.</param> /// <param name="item">The item to register.</param> /// <returns>The item that was registered, or null if registration failed.</returns> public T RegisterItem <T>(Mod owner, T item) where T : ModItem { var itemDef = new ModItemDefinition(owner, item.id, item); if (IsItemPresent(itemDef.Id)) { throw new Exception($"Attempted to register an item with the id '${itemDef.Id}' but it was already registered."); } this.itemIds.Add(itemDef.Id, this.itemIds.Count); this.itemIdList.Insert(this.itemIds.Count - 1, itemDef.Id); this.registeredItems.Insert(this.itemIds.Count - 1, itemDef); DebugScreen.Log($"Registered new item with id {itemDef.Id}"); return(item); }
/// <summary> /// Tells all subscriptions managed by this list that an event has been fired. /// </summary> /// <param name="eventFired">The event that was fired.</param> public void HandleFiredEvent <T>(T eventFired) where T : EventBase { if (typeof(T) != this.type) { throw new ArgumentException("Attempted to handle a fired event on an event list with the incorrect event type."); } foreach (var sortedSubscription in GetSortedSubscriptions <T>()) { try { sortedSubscription.HandleFiredEvent(eventFired); } catch (Exception e) { DebugScreen.Log($"Failed to handle event {this.type}, caused by subscription by {sortedSubscription.Subscriber.Id}"); DebugScreen.Log(e.ToString()); } } }
private void StandardInitialization(ContentManager content) { //Load stuff var platformConeTexture = content.Load <Texture2D>("Cones"); var platformCylTexture = content.Load <Texture2D>("Cylinders"); var platformBlankTexture = content.Load <Texture2D>("PlatformBasic"); var platformDomeTexture = content.Load <Texture2D>("Dome"); var mapBackground = content.Load <Texture2D>("backgroundGrid"); var libSans12 = content.Load <SpriteFont>("LibSans12"); PlatformFactory.Init(platformConeTexture, platformCylTexture, platformDomeTexture, platformBlankTexture, libSans12); StructureLayoutHolder.Initialize(ref mDirector); //Map related stuff Camera = new Camera(mGraphics.GraphicsDevice, ref mDirector); mFow = new FogOfWar(Camera, mGraphics.GraphicsDevice); var map = new Map.Map(mapBackground, 60, 60, mFow, Camera, ref mDirector); Map = map; var milUnitSheet = content.Load <Texture2D>("UnitSpriteSheet"); var milGlowSheet = content.Load <Texture2D>("UnitGlowSprite"); var genUnitSprite = content.Load <Texture2D>("GenUnit"); MilitaryUnit.mMilSheet = milUnitSheet; MilitaryUnit.mGlowTexture = milGlowSheet; GeneralUnit.mGenUnitTexture = genUnitSprite; mDirector.GetMilitaryManager.SetMap(ref map); //INITIALIZE SCREENS GameScreen = new GameScreen(mGraphics.GraphicsDevice, ref mDirector, Map, Camera, mFow); Ui = new UserInterfaceScreen(ref mDirector, Map, Camera, mScreenManager); mDirector.GetUserInterfaceController.ControlledUserInterface = Ui; // the UI needs to be added to the controller // the input manager keeps this from not getting collected by the GC mDebugscreen = new DebugScreen((StackScreenManager)mScreenManager, Camera, Map, ref mDirector); mDirector.GetInputManager.FlagForAddition(this); if (Ai != null) { GameScreen.AddObject(Ai); } }
public static DebugScreen Get() { if (m_Instance == null) m_Instance = (DebugScreen)FindObjectOfType(typeof(DebugScreen)); return m_Instance; }