/// <summary> /// Öffnet den Screen mit einer Animation /// </summary> /// <param name="prevScreen"></param> /// <returns></returns> public virtual GuiScreen Open(GuiScreen prevScreen) { this.prevScreen = prevScreen; Animation = new CustomAnimation <float>(-Game.HEIGHT, 0.0f, (float delta, float current) => current + delta) { Toleranz = 1E-3f }; Animation.Fire(); return(this); }
/// <summary> /// Initialisiert die Form und die dafür notwendingen Komponenten für unser Framework /// </summary> private void Init() { Text = NAME; Width = (int)WIDTH; Height = (int)HEIGHT; DoubleBuffered = true; //Verhindert Flackern //Erstellen der Timer für aktualisierung der Form renderTimer = new Timer() { Interval = (int)(1000.0f / FPS) }; renderTimer.Tick += RenderTimer_Tick; tickTimer = new Timer() { Interval = (int)TPT, }; tickTimer.Tick += TickTimer_Tick; watch = new Stopwatch(); watch.Start(); //Hinzufügen der Events für interaktionen MouseClick += Game_MouseClick; MouseMove += Game_MouseEvent; KeyDown += Game_KeyDown; KeyUp += Game_KeyUp; MouseWheel += Game_MouseEvent; Resize += (object sender, EventArgs e) => { A_WIDTH = Width; A_HEIGHT = Height; currentScreen?.Resize(); }; animationHandler = new AnimationHandler(); zoom = new CustomAnimation <float>(5, 5, (float current, float delta) => { return(current + delta); }); zoom.Fire(); inputManager = new InputManager(); AddKeybinds(); renderTimer.Start(); tickTimer.Start(); isIngame = false; SetScreen(new GuiStartScreen());//StartScreen setzen entities = new List <Entity>(); enemyTypes = new Type[] { typeof(EnemyJens) }; }
private void CreateNewAnimation() { check = new CustomAnimation <float>(0.0f, 1.0f, (float current, float delta) => current + delta) { Toleranz = 1E-3f }; //Animation für den Haken check.OnFinish += (object o, EventArgs args) => { if (!check.Increments) //Soll wieder groß werden wenn es klein geworden ist { state = !state; token = state ? ((char)10003).ToString() : ((char)10007).ToString(); check.Reverse(); } }; check.Fire(); }
/// <summary> /// Methoden für die Events /// </summary> /// <param name="sender"></param> /// <param name="e"></param> #region events private void Game_MouseEvent(object sender, MouseEventArgs e) { //Anpassung auf die Skalierung InputManager.mouseX = (int)(e.X / StateManager.ScaleX); InputManager.mouseY = (int)(e.Y / StateManager.ScaleY); InputManager.mousePosition = new Vector(InputManager.mouseX, InputManager.mouseY); if (currentScreen != null) { currentScreen.Move(new MouseEventArgs(e.Button, e.Clicks, InputManager.mouseX, InputManager.mouseY, 0)); return; } //Zoom zoom.End += e.Delta / 120 / 2f; if (zoom.End < 0.5f) { zoom.End = 0.5f; } if (zoom.Finished) { zoom.Fire(); } }
private CustomAnimation <float> health = CustomAnimation <float> .CreateDefaultAnimation(20.0f);//Animation für das Leben public GuiIngame(Game game) { this.game = game; health.Fire(); }