Beispiel #1
0
    protected virtual void Die(DamageEmitter killer)
    {
        if (killer.owner == Player.Self.CurrentPossession)
        {
            //The player killed this creature. The player now becomes this creature.
            Player.Self.SetPossessionAs(gameObject);
            currentHealth = maxHealth;
        }
        else
        {
            if (gameObject == Player.Self.CurrentPossession)
            {
                if (Player.Self.CrownPrefab)
                {
                    GameObject crown = Instantiate(Player.Self.CrownPrefab, transform.position, transform.rotation);
                    crown.AddComponent <Rigidbody>();
                    MeshCollider mc = crown.AddComponent <MeshCollider>();
                    mc.convex = true;

                    Player.Self.GameOver();
                }
            }
            gameObject.SetActive(false);
            ignoreDamage = true;
        }
    }
Beispiel #2
0
 public virtual void TakeDamageFrom(DamageEmitter attacker)
 {
     if (ignoreDamage)
     {
         return;
     }
     currentHealth -= attacker.damage;
     if (currentHealth <= 0 && maxHealth > 0)
     {
         Die(attacker);
     }
 }
        // Apply damage and return true if death.
        public virtual bool ApplyDamage(nfloat damage)
        {
            Health -= damage;

            if (Health <= 0)
            {
                PerformDeath();
                return(true);
            }

            var emitter = (SKEmitterNode)DamageEmitter.Copy();

            CharacterScene.AddNode(emitter, WorldLayer.AboveCharacter);
            emitter.Position = Position;
            GraphicsUtilities.RunOneShotEmitter(emitter, 0.15f);

            // Show the damage.
            RunAction(DamageAction);

            return(false);
        }