/// <summary> /// onSceneCreated this function is called whenever the current gamestate is changed. This function should contain logic that /// needs to be processed before the state is shown for the player. This could be enteties that's not able to be created pre-runtime. /// </summary> public void onSceneCreated() { DrawableTextComponent text1 = new DrawableTextComponent("Map:", Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/Menufont")); PositionComponent pos1 = new PositionComponent(new Vector2(0, Game.Instance.GraphicsDevice.Viewport.Height - 80)); int id1 = ComponentManager.Instance.CreateID(); FadeComponent fc2 = new FadeComponent(1, 3); ComponentManager.Instance.AddComponentToEntity(id1, text1); ComponentManager.Instance.AddComponentToEntity(id1, pos1); ComponentManager.Instance.AddComponentToEntity(id1, fc2); entitiesInState.Add(id1); draw = new DrawableTextComponent("Whiteboard", Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/Menufont")); PositionComponent pos2 = new PositionComponent(new Vector2(105, Game.Instance.GraphicsDevice.Viewport.Height - 80)); kbc1 = new KeyBoardComponent(); FadeComponent fc = new FadeComponent(1, 3); kbc1.keyBoardActions.Add(ActionsEnum.Left, Keys.Right); newId = ComponentManager.Instance.CreateID(); ComponentManager.Instance.AddComponentToEntity(newId, fc); ComponentManager.Instance.AddComponentToEntity(newId, draw); ComponentManager.Instance.AddComponentToEntity(newId, pos2); ComponentManager.Instance.AddComponentToEntity(newId, kbc1); DrawableTextComponent text = new DrawableTextComponent("Press Enter To Start", Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/Menufont")); PositionComponent pos = new PositionComponent(new Vector2(300, 0)); KeyBoardComponent kbc = new KeyBoardComponent(); FadeComponent fc3 = new FadeComponent(1, 3); kbc.keyBoardActions.Add(ActionsEnum.Enter, Keys.Enter); textId = ComponentManager.Instance.CreateID(); ComponentManager.Instance.AddComponentToEntity(textId, kbc); ComponentManager.Instance.AddComponentToEntity(textId, text); ComponentManager.Instance.AddComponentToEntity(textId, pos); ComponentManager.Instance.AddComponentToEntity(textId, fc3); entitiesInState.Add(textId); DrawableTextComponent text2 = new DrawableTextComponent("Press Right-Arrow key To Change Map", Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/Menufont")); PositionComponent pos3 = new PositionComponent(new Vector2(180, 50)); int textId2 = ComponentManager.Instance.CreateID(); FadeComponent fc4 = new FadeComponent(1, 3); ComponentManager.Instance.AddComponentToEntity(textId2, text2); ComponentManager.Instance.AddComponentToEntity(textId2, pos3); ComponentManager.Instance.AddComponentToEntity(textId2, fc4); entitiesInState.Add(textId2); DrawableTextComponent text3 = new DrawableTextComponent("Register Character By pressing a Key", Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/Menufont")); PositionComponent pos4 = new PositionComponent(new Vector2(150, 100)); FadeComponent fc5 = new FadeComponent(1, 3); int textId3 = ComponentManager.Instance.CreateID(); ComponentManager.Instance.AddComponentToEntity(textId3, text3); ComponentManager.Instance.AddComponentToEntity(textId3, pos4); ComponentManager.Instance.AddComponentToEntity(textId3, fc5); entitiesInState.Add(textId3); }
private System.Collections.IEnumerator Start() { Log("Bootstrap.Start()"); _fadeComponent = gameObject.AddComponent <FadeComponent>(); _fadeComponent.SetDepth((int)UIRenderDepth.BootstrapFade); _fadeComponent.SetFade(1.0f); //start off black _dataStore = new DataStore(); yield return(_dataStore.Init()); yield return(SetStateInternal("mainmenu")); }
/// <summary> /// onSceneCreated this function is called whenever the current gamestate is changed. This function should contain logic that /// needs to be processed before the state is shown for the player. This could be enteties that's not able to be created pre-runtime. /// </summary> public void onSceneCreated() { //add the enteties which should be displayed on the screen when the players choose their caracters. Player enteties is to be created after leaving this state therefore the //add entetiestolist - function needs to be called before entering the playing-state DrawableTextComponent dtx = new DrawableTextComponent("Flappy Ass, version 1.0 By: PT2", Color.Tomato, Game.Instance.GetContent <SpriteFont>("Fonts/MenuFont")); PositionComponent pc = new PositionComponent(new Vector2(20, 100)); fc = new FadeComponent(254, -3); int id = ComponentManager.Instance.CreateID(); ComponentManager.Instance.AddComponentToEntity(id, fc); ComponentManager.Instance.AddComponentToEntity(id, dtx); ComponentManager.Instance.AddComponentToEntity(id, pc); entitiesInState.Add(id); }
private void Awake() { _player = PlayerControls.Get(); _bomb = Bomb.Get(); _fade = FadeComponent.Get(); if (_player == null) { Debug.LogError($"Unable to find a {typeof(PlayerControls)} inside this scene."); } if (_bomb == null) { Debug.LogError($"Unable to find a {typeof(Bomb)} inside this scene."); } if (_fade == null) { Debug.LogError($"Unable to find a {typeof(FadeComponent)} inside this scene."); } }
protected override void Awake() { base.Awake(); Lights = transform.parent.GetComponentInChildren <FadeComponent>(); }
/// <summary> /// draw is the function which handles the actuall drawing of the text in each loop in the game. /// </summary> /// <param name="gameTime">Takes a GameTime object which should represent the time since the last time this function was called</param> /// <param name="spriteBatch">Takes a SpriteBatch object which is used to draw the textures directly to the screen</param> public void draw(GameTime gameTime, SpriteBatch spriteBatch) { List <int> dra = ComponentManager.Instance.GetAllEntitiesWithComponentType <DrawableTextComponent>(); if (dra != null) { foreach (var a in dra) { DrawableTextComponent d = ComponentManager.Instance.GetEntityComponent <DrawableTextComponent>(a); FadeComponent f = ComponentManager.Instance.GetEntityComponent <FadeComponent>(a); if (f != null) { f.fadeDelay -= gameTime.ElapsedGameTime.TotalSeconds; } Dictionary <Vector2, string> list = d.GetStringDictiornary(); //If there is a StringList then there's multiple lines of text that should be written to the screen. if (list != null) { //For each of the strings in the list write them to the screen, the value key in the dictionary is the //position where the line should be written. foreach (var item in list) { if (f != null) { if (f.fadeDelay <= 0) { f.fadeDelay = .035; f.alphaValue += f.fadeIncrement; if (f.fadeIncrement >= 255 || f.alphaValue <= 0) { f.fadeIncrement *= -1; } } d.textColor = new Color(255, 255, 255, (byte)MathHelper.Clamp(f.alphaValue, 0, 255)); } spriteBatch.DrawString(d.font, item.Value, item.Key, d.textColor); } } //There is just one line of text, then just draw it to the screen. else { FadeComponent fc = ComponentManager.Instance.GetEntityComponent <FadeComponent>(a); if (f != null) { f.fadeDelay -= gameTime.ElapsedGameTime.TotalSeconds; } if (fc != null) { if (fc.fadeDelay <= 0) { fc.fadeDelay = .035; fc.alphaValue += f.fadeIncrement; if (fc.fadeIncrement >= 255 || fc.alphaValue <= 0) { fc.fadeIncrement *= 0; } } d.textColor = new Color(255, 0, 255, (byte)MathHelper.Clamp(fc.alphaValue, 0, 255)); } PositionComponent p = ComponentManager.Instance.GetEntityComponent <PositionComponent>(a); if (p != null && d != null && d.visible == true) { spriteBatch.DrawString(d.font, d.text, p.position, d.textColor); } } } } }
public void OnEnable() { MenuAync(); fade = FindObjectOfType <FadeComponent>(); }