Esempio n. 1
0
        /// <summary>
        /// Updates the component with the specified seconds since last update.
        /// </summary>
        /// <param name="seconds">The amount of seconds since last update.</param>
        public void Update(double seconds)
        {
            // Switch state
            if (this.switchData != null && this.stateByString.ContainsKey(this.switchData.NextState))
            {
                if (this.currentState != null)
                {
                    this.currentState.Deactivate(this.switchData);
                    if (this.currentState.IsTemporary)
                    {
                        this.RemoveState(this.currentState.Identifier);
                    }
                }

                this.currentState = this.stateByString[this.switchData.NextState];
                this.currentState.Activate(this.switchData);
                this.switchData = null;
            }

            // Update current state
            if (this.currentState != null)
            {
                this.currentState.Update(seconds);
            }
        }
Esempio n. 2
0
 protected override void Activated(StateSwitchData data)
 {
     Console.WriteLine("State two activated! Message: " + (string)data.Data);
     this.primitive3D = new PrimitiveBatch3D(MBackend.GraphicsManager.GetGraphicsDevice());
 }
Esempio n. 3
0
 /// <summary>
 /// Prepares for a state switch using the provided data.
 /// </summary>
 /// <param name="stateIdentifier">The identifier of the state to switch to.</param>
 /// <param name="data">Data to send with the switch. May be null.</param>
 public void SwitchState(string stateIdentifier, object data)
 {
     this.switchData = new StateSwitchData(stateIdentifier, this.currentState == null ? null : this.currentState.Identifier, data);
 }
Esempio n. 4
0
 protected override void Activated(StateSwitchData data)
 {
     MBackend.MessagePasser.Subscribe("testChannel", Test);
     MBackend.MessagePasser.Subscribe("noChannel", Test);
     MBackend.MessagePasser.Unsubscribe("noChannel", Test);
     MBackend.MessagePasser.Subscribe("CONSOLE", ConsoleMessage);
     MBackend.Console.WriteLine("State one activated! Message: " + (string)data.Data);
     MBackend.Console.WriteLine(MBackend.TextureStorage.LoadFiles("Assets\\Textures", true).Successes + " textures loaded.");
     MBackend.Console.WriteLine(MBackend.FontStorage.LoadFiles("Assets\\Fonts", true).Successes + " fonts loaded.");
     MBackend.Console.WriteLine(MBackend.EffectStorage.LoadFiles("Assets\\Effects", true).Successes + " effects loaded.");
     sb = new SpriteBatch(MBackend.GraphicsManager.GetGraphicsDevice());
     timer.Reset();
     //MonoKleGame.ScriptInterface.AddScriptSources("TestScripts.ms", false);
     //MonoKleGame.ScriptInterface.CompileSources();
     this.primitive2D = new PrimitiveBatch2D(MBackend.GraphicsManager.GetGraphicsDevice());
     //MonoKleGame.EffectStorage.LoadFiles("shader.fx");
 }