Exemple #1
0
        public virtual void Update(float dt)
        {
            tweenManager.Update(dt);
            transitionTimer.Update(dt);

            switch (state)
            {
            case ScreenState.TransitioningIn:
                if (transitionTimer.IsTrigged())
                {
                    State = ScreenState.Running;
                }
                break;

            case ScreenState.Running:
                break;

            case ScreenState.TransitioningOut:
                if (transitionTimer.IsTrigged())
                {
                    State = ScreenState.Done;
                }
                break;

            case ScreenState.Done:
                break;
            }

            cam.Update(dt);
        }
Exemple #2
0
        public void Update(float dt)
        {
            if (running && spawnTimer.IsTrigged(dt))
            {
                if (settings.loop)
                {
                    Spawn();
                }
                else
                {
                    if (spawned >= settings.capacity)
                    {
                        if (particles.Count == 0)
                        {
                            Done = true;
                        }
                    }
                    else
                    {
                        Spawn();
                    }
                }
            }

            for (int i = 0; i < particles.Count; i++)
            {
                Particle p = particles[i];
                p.current += dt;
                if (p.current > p.duration)
                {
                    particles.Push(i--);
                }
                else
                {
                    float progress = p.current / p.duration;

                    p.velocity.X += settings.gravity.force.X * dt;
                    p.velocity.Y += settings.gravity.force.Y * dt;

                    p.position.X += p.velocity.X * dt;
                    p.position.Y += p.velocity.Y * dt;

                    p.scale.X = MathHelper.Lerp(p.startScale.X, p.endScale.X, progress);
                    p.scale.Y = MathHelper.Lerp(p.startScale.Y, p.endScale.Y, progress);

                    // TODO: start and end of all properties
                    p.color.R = (byte)MathHelper.Lerp(p.startColor.R, p.endColor.R, progress);
                    p.color.G = (byte)MathHelper.Lerp(p.startColor.G, p.endColor.G, progress);
                    p.color.B = (byte)MathHelper.Lerp(p.startColor.B, p.endColor.B, progress);
                    p.color.A = (byte)MathHelper.Lerp(p.startColor.A, p.endColor.A, progress);
                }
            }
        }
Exemple #3
0
        void Update()
        {
            _input.Clear();


            // TODO: stupid ai
            if (_timer.IsTrigged(Time.deltaTime * 1000f))
            {
                SetState(GetRandomState(), Random.Range(500f, 5000f));
            }

            UpdateState();
        }
        public virtual void Update(float dt)
        {
            if (!trig.IsTrigged(dt))
            {
                return;
            }

            currentFrame++;
            if (currentFrame >= frames.Length)
            {
                currentFrame = 0;
                if (OnAnimationEnd != null)
                {
                    OnAnimationEnd();
                }
            }
        }