예제 #1
0
        //---------------------------------------------------------------------------

        public void Tick(float deltaTime)
        {
            if (!IsCollectable)
            {
                PhysicsComponent physics = GetComponent <PhysicsComponent>();
                if (physics != null)
                {
                    if (physics.HasTouchedFloor)
                    {
                        IsCollectable = true;

                        CircleColliderComponent collider = GetComponent <CircleColliderComponent>();
                        if (collider != null)
                        {
                            collider.SetCollidesWith(ECollisionCategory.Stage | ECollisionCategory.Player);
                        }
                    }
                }
            }
            if (m_IsCollected)
            {
                LightingComponent light = GetComponent <LightingComponent>();
                if (light != null)
                {
                    light.Scale      *= 1.2f;
                    light.Brightness -= 0.05f;
                }
                SpriteComponent sprite = GetComponent <SpriteComponent>();
                if (sprite != null)
                {
                    sprite.Opacity -= 0.05f;
                    if (sprite.Opacity <= 0.0f)
                    {
                        DespawnComponent despawn = GetComponent <DespawnComponent>();
                        if (despawn != null)
                        {
                            despawn.Trigger();
                        }
                    }
                }
            }
        }
예제 #2
0
        //---------------------------------------------------------------------------

        public void Tick(float deltaTime)
        {
            switch (State)
            {
            case EAnimationState.Playing:
                TransformComponent transform = GetComponent <TransformComponent>();
                PhysicsComponent   physics   = GetComponentInAncestor <PhysicsComponent>();

                if (transform != null)
                {
                    if (physics != null)
                    {
                        Keyframe frame;
                        if (m_Paths[Index].GetNextKeyFrame(deltaTime, out frame))
                        {
                            physics.ApplyAbsoluteForce(frame.Location - transform.Location);
                            //physics.RotateTo(frame.Rotation);
                        }
                        else
                        {
                            Stop();
                        }
                    }
                    else
                    {
                        Keyframe frame;
                        if (m_Paths[Index].GetNextKeyFrame(deltaTime, out frame))
                        {
                            transform.MoveTo(frame.Location);
                            transform.RotateTo(frame.Rotation);
                        }
                        else
                        {
                            Stop();
                        }
                    }
                }
                break;
            }
        }