public void removeImmunity(Commandments.Element elementValue)
 {
     numImmunities[elementValue.toInt()]--;
     if (numImmunities[elementValue.toInt()] < 0)
     {
         numImmunities[elementValue.toInt()] = 0;
     }
 }
Ejemplo n.º 2
0
        internal static float damageFromTo(Commandments.Element attackElement, Commandments.Element myElement)
        {
            if (attackElement == Commandments.Element.NEUTRAL || myElement == Commandments.Element.NEUTRAL)
            {
                return(1);
            }

            return(Commandments.damageTable[attackElement.toInt(), myElement.toInt()]);
        }
Ejemplo n.º 3
0
    public override float ReceiveDamage(Vector2 direction, float force, float damage, bool critical = false, Commandments.Element attackerElement = Commandments.Element.NEUTRAL, Character source = null)
    {
        if (currentState == "dying")
        {
            return(0);
        }

        float receivedDamage = 0;
        bool  ret            = CoolDownManager.Apply(Identifiers.Invulnerability.ToString(), gameObject, invulnerabilityTime, () =>
        {
            damage *= damageModifier[attackerElement.toInt()];

            receivedDamage = base.ReceiveDamage(direction, force, damage, critical, attackerElement, source);

            if (hp <= 0)
            {
                if (takingDamageParameter != null)
                {
                    animator.ResetTrigger(takingDamageParameter.name);
                }
                if (critical)
                {
                    float criticalValue = 100 * Random.value;



                    if (criticalValue > (100 - scriptDropChance * Commandments.Modifiers.IncreaseScriptDropRate.GetValue()))
                    {
                        GameManager.GetInstance().SpawnYokaiEssence(transform.position, yokaiRank, player);
                    }
                }
                Dying();
            }

            return(true);
        });

        ////print("Received Damage = " + receivedDamage);
        return(receivedDamage);
    }
    protected virtual void Start()
    {
        colliders = new List <Collider2D>();
        Collider2D[] vect = GetComponentsInChildren <Collider2D>();
        if (vect.Length > 0)
        {
            myBounds = vect[0];
        }
        for (int i = 0; i < vect.Length; i++)
        {
            if (vect[i].isTrigger)
            {
                colliders.Add(vect[i]);
            }
        }
        hp = maxHP;


        rigidBody = GetComponent <Rigidbody2D>();
        rigidBody.freezeRotation = true;



        animator = GetComponentInChildren <Animator>();

        //UnityEditor.Animations.AnimatorController controller = animator.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;

        //animatorStates = new List<UnityEditor.Animations.AnimatorState>();
        animatorParameters = new List <AnimatorControllerParameter>();
        animatorStates     = new List <string>();
        currentState       = "";
        foreach (AnimatorControllerParameter parameter in animator.parameters)
        {
            if (parameter.name == "isOnGround")
            {
                groundParameter = parameter;
            }
            else if (parameter.name == "verticalSpeed")
            {
                verticalParameter = parameter;
            }
            else if (parameter.name == "triggerTakingDamage")
            {
                takingDamageParameter = parameter;
            }
            else if (parameter.name == "triggerDying")
            {
                dyingParameter = parameter;
            }
            else if (parameter.name == "attackType")
            {
                attackTypeParameter = parameter;
            }
            else if (parameter.name.Contains("activate"))
            {
                animatorParameters.Add(parameter);
            }
        }

        foreach (AnimationClip a in anims)
        {
            animatorStates.Add(a.name);
        }


        damageModifier = new float[System.Enum.GetValues(typeof(Commandments.Element)).Length];
        for (int cont = 0; cont < System.Enum.GetValues(typeof(Commandments.Element)).Length - 1; cont++)
        {
            if (myElement == Commandments.Element.NEUTRAL)
            {
                damageModifier[cont] = 1.0f;
            }
            else
            {
                damageModifier[cont] = Commandments.damageTable[cont, myElement.toInt()];
            }
        }
        damageModifier[damageModifier.Length - 1] = 1;



        groundVerifier = null;
        ledgeVerifier  = null;
        foreach (Transform t in GetComponentsInChildren <Transform>())
        {
            if (t.tag == "GroundVerifier")
            {
                groundVerifier = t;
            }
            if (t.tag == "LedgeVerifier")
            {
                ledgeVerifier = t;
            }
        }

        drawManager.drawList.Add(displayHP);

        //displayHP.behavior = Drawable.Behavior.PERCENTAGE;
        //displayHP.size.width = 0.04f;
        //displayHP.size.height = 0.0075f;
        //displayHP.percent = 1;
    }
 public float getDamageModifier(Commandments.Element elemento)
 {
     return(damageModifier[elemento.toInt()]);
 }
 public void newImmunity(Commandments.Element newElement)
 {
     numImmunities[newElement.toInt()]++;
 }