/*--------------------------------------------------------------------------
        *           Manipulate Health
        *  --------------------------------------------------------------------------*/

        public void TakeDamage(float damage_dealt)
        {
            CurrentHealth -= damage_dealt;

            if (CurrentHealth <= 0)
            {
                DespawnComponent despawn = GetComponent <DespawnComponent>();
                if (despawn != null)
                {
                    despawn.Trigger();
                }
                if (EntityManager.Get().Find <Player>(Entity) != null)
                {
                    //TODO_lukas: Think about what happens when Players are killed
                }
            }
        }
        //---------------------------------------------------------------------------

        //TODO_lukas: Think about what Coins could be good for

        public void OnPickup(IEntity collector)
        {
            if (collector != null && IsCollectable)
            {
                if (collector is Player)
                {
                    PlayerAttributesComponent attributes = collector.GetComponent <PlayerAttributesComponent>();
                    attributes.AddCoins(10);

                    DespawnComponent despawn = GetComponent <DespawnComponent>();
                    if (despawn != null)
                    {
                        despawn.Trigger();
                    }
                }
            }
        }
Exemple #3
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();
                        }
                    }
                }
            }
        }