protected override void Start()
    {
        base.Start();
        HealthBar  = transform.Find("Health_Bar/Background/Slider").GetComponent <Slider>();
        specialBar = transform.Find("Health_Bar/Background/Special").GetComponent <Slider>();
        obeliskController.DancerRootReference   = this;
        leftFireController.DancerRootReference  = this;
        rightFireController.DancerRootReference = this;
        iceController.DancerRootReference       = this;

        obeliskController.ElementalActive   = true;
        iceController.ElementalActive       = false;
        leftFireController.ElementalActive  = false;
        rightFireController.ElementalActive = false;

        List <ElementalResistances> availableElements = new List <ElementalResistances>();

        for (int i = 0; i < System.Enum.GetValues(typeof(ElementalResistances)).Length; i++)
        {
            availableElements.Add((ElementalResistances)i);
        }

        reflectElementA = availableElements[Random.Range(0, availableElements.Count)];
        availableElements.Remove(reflectElementA);

        reflectElementB = availableElements[Random.Range(0, availableElements.Count)];

        Color reflectA = (reflectElementA == ElementalResistances.FIRE ? Color.red : reflectElementA == ElementalResistances.ICE ? Color.cyan : reflectElementA == ElementalResistances.SHOCK ? Color.blue : reflectElementA == ElementalResistances.POISON ? Color.green : reflectElementA == ElementalResistances.PHYSICAL ? Color.yellow : Color.magenta);
        Color reflectB = (reflectElementB == ElementalResistances.FIRE ? Color.red : reflectElementB == ElementalResistances.ICE ? Color.cyan : reflectElementB == ElementalResistances.SHOCK ? Color.blue : reflectElementB == ElementalResistances.POISON ? Color.green : reflectElementB == ElementalResistances.PHYSICAL ? Color.yellow : Color.magenta);

        obeliskController.transform.Find("PrimarySprite/TR_Corner").GetComponent <SpriteRenderer>().color = obeliskController.transform.Find("PrimarySprite/BL_Corner").GetComponent <SpriteRenderer>().color = reflectA;
        obeliskController.transform.Find("PrimarySprite/BR_Corner").GetComponent <SpriteRenderer>().color = obeliskController.transform.Find("PrimarySprite/TL_Corner").GetComponent <SpriteRenderer>().color = reflectB;
    }
 public override void TakeDamage(float damageAmount, ElementalResistances type)
 {
     if (currentState == AttackState.DEFENSE)
     {
         base.TakeDamage(damageAmount * .5f, type);
         if (type == reflectElementA || type == reflectElementB)
         {
             player.GetComponent <Player_Details_Script>().TakeDamage(reflectRatio * damageAmount, ElementalResistances.TRUE);
         }
         TransformProgress += .01f;
     }
     else
     {
         if ((currentState == AttackState.ICE && type == ElementalResistances.FIRE) || (currentState == AttackState.FIRE && type == ElementalResistances.ICE))
         {
             base.TakeDamage(damageAmount * 1.2f, type);
         }
         else
         {
             base.TakeDamage(damageAmount, type);
         }
         if (increaseHitCount < increaseLimit)
         {
             transformProgress += .01f;
             increaseHitCount++;
         }
     }
 }
Exemple #3
0
 public override void TakeDamage(float damageAmount, ElementalResistances type)
 {
     base.TakeDamage(damageAmount, type);
     UpdateHealthBar();
     if (CurrentHealth <= 0)
     {
         Die();
     }
 }
 protected void TakeReplicateDamage(float damageAmount, ElementalResistances type)
 {
     base.TakeDamage(damageAmount * .5f, type);
     UpdateHealthBar();
     if (CurrentHealth <= 0)
     {
         Die();
     }
 }
Exemple #5
0
 public override void TakeDamage(float damageAmount, ElementalResistances type)
 {
     base.TakeDamage(damageAmount, type);
     if (currentHealth <= 0)
     {
         if (Player_Accessor_Script.EquipmentScript.PlayerHasControl)
         {
             Player_Accessor_Script.EquipmentScript.PlayerHasControl = false;
             animController.Play("Dying");
         }
     }
 }
 public override void TakeDamage(float damageAmount, ElementalResistances type)
 {
     base.TakeDamage(damageAmount, type);
     if (HealthBar.transform.parent.GetComponent <Animator>() != null)
     {
         HealthBar.transform.parent.GetComponent <Animator>().Play("DamageFlash");
     }
     UpdateHealthBar();
     foreach (EnemyObject obj in replicatedTargets)
     {
         obj.TakeReplicateDamage(damageAmount, type);
     }
     if (CurrentHealth <= 0)
     {
         Die();
     }
 }
 private void ParseData()
 {
     Id = ReadByte(EnemyOffsets.Id);
     foreach (var s in DataInterpreter.ConvertElements(RawAttackElement))
     {
         AttackElements.Add(s);
     }
     foreach (var s in DataInterpreter.ConvertElements(RawWeakness))
     {
         ElementalWeaknesses.Add(s);
     }
     foreach (var s in DataInterpreter.ConvertElements(RawResistance))
     {
         ElementalResistances.Add(s);
     }
     foreach (var s in DataInterpreter.ConvertElements(RawAbsorb))
     {
         ElementalAbsorbs.Add(s);
     }
     foreach (var s in DataInterpreter.ConvertElements(RawImmunity))
     {
         ElementalImmunities.Add(s);
     }
 }
    public virtual void TakeDamage(float damageAmount, ElementalResistances type)
    {
        float unmitigated = damageAmount;

        //Mitigation Calculations
        float resistValue = 0;

        if (type != ElementalResistances.TRUE)
        {
            resistValue = elementalResists[type];
        }

        if (resistValue == 0)
        {
            resistValue++;
        }
        resistValue *= resistanceMultiplier;

        if (type == ElementalResistances.PHYSICAL)
        {
            int mitigated = Mathf.RoundToInt(damageAmount / (Mathf.Log10(resistValue + 5)) + 1);
            if (mitigated < 0)
            {
                mitigated = 0;
            }

            if (mitigated > shieldAmount)
            {
                mitigated   -= (int)shieldAmount;
                shieldAmount = 0;
            }
            else
            {
                shieldAmount -= mitigated;
                mitigated     = 0;
            }
            CurrentHealth -= mitigated;
            GameObject textRef = Instantiate(damageTextPrefab, transform.position + (Vector3)(Random.insideUnitCircle * Random.Range(0f, 1f)), Quaternion.identity);
            textRef.GetComponentInChildren <Text>().text  = mitigated.ToString();
            textRef.GetComponentInChildren <Text>().color = new Color(.25f, .25f, 0f);
            Destroy(textRef, 1f);

            foreach (SpriteRenderer spr in GetComponentsInChildren <SpriteRenderer>())
            {
                spr.color = Color.red;
            }
            damageColorTimer = .25f;
        }
        else if (type == ElementalResistances.TRUE)
        {
            if (damageAmount > shieldAmount)
            {
                damageAmount -= (int)shieldAmount;
                shieldAmount  = 0;
            }
            else
            {
                shieldAmount -= damageAmount;
                damageAmount  = 0;
            }
            CurrentHealth -= damageAmount;
            GameObject textRef = Instantiate(damageTextPrefab, transform.position + (Vector3)(Random.insideUnitCircle * Random.Range(0f, 3f)), Quaternion.identity);
            textRef.GetComponentInChildren <Text>().text = damageAmount.ToString();
            Destroy(textRef, 1f);
            //foreach (SpriteRenderer spr in GetComponentsInChildren<SpriteRenderer>())
            //{
            //	spr.color = Color.red;
            //}
            //damageColorTimer = .25f;
        }
        else
        {
            int mitigated = Mathf.RoundToInt(damageAmount / (Mathf.Pow(resistValue / 10, 0.5f)));
            if (mitigated < 0)
            {
                mitigated = 0;
            }

            if (mitigated > shieldAmount)
            {
                mitigated   -= (int)shieldAmount;
                shieldAmount = 0;
            }
            else
            {
                shieldAmount -= mitigated;
                mitigated     = 0;
            }
            CurrentHealth -= mitigated;

            GameObject textRef = Instantiate(damageTextPrefab, transform.position + (Vector3)(Random.insideUnitCircle * Random.Range(0f, 3f)), Quaternion.identity);
            textRef.GetComponentInChildren <Text>().text = mitigated.ToString();
            switch (type)
            {
            case (ElementalResistances.FIRE):
                textRef.GetComponentInChildren <Text>().color = Color.red;
                break;

            case (ElementalResistances.ICE):
                textRef.GetComponentInChildren <Text>().color = Color.cyan;
                break;

            case (ElementalResistances.POISON):
                textRef.GetComponentInChildren <Text>().color = new Color(0f, .5f, 0f);
                break;

            case (ElementalResistances.SHOCK):
                textRef.GetComponentInChildren <Text>().color = Color.yellow;
                break;

            case (ElementalResistances.VOID):
                textRef.GetComponentInChildren <Text>().color = new Color(.3f, .2f, .6f);
                break;
            }
            Destroy(textRef, 1f);

            //foreach (SpriteRenderer spr in GetComponentsInChildren<SpriteRenderer>())
            //{
            //	if (!spriteRenderColorReferences.ContainsKey(spr.transform)) {
            //		spriteRenderColorReferences.Add(spr.transform, spr.color);
            //	} else if ((spriteRenderColorReferences.ContainsKey(spr.transform) && spr.color != spriteRenderColorReferences[spr.transform])&& spr.color != Color.red)
            //	{
            //		spriteRenderColorReferences[spr.transform] = spr.color;
            //	}
            //	spr.color = Color.red;
            //}
            //damageColorTimer = .25f;
        }
    }
    public void TransformState()
    {
        //TransformProgress = Mathf.RoundToInt(TransformProgress);
        if (currentState == AttackState.DEFENSE)
        {
            obeliskController.AttackDuration = 0f;
            obeliskController.transform.Find("PrimarySprite/TR_Corner").GetComponent <SpriteRenderer>().color = obeliskController.transform.Find("PrimarySprite/BL_Corner").GetComponent <SpriteRenderer>().color = Color.white;
            obeliskController.transform.Find("PrimarySprite/BR_Corner").GetComponent <SpriteRenderer>().color = obeliskController.transform.Find("PrimarySprite/TL_Corner").GetComponent <SpriteRenderer>().color = Color.white;
            if (previousState == AttackState.FIRE)
            {
                previousState = currentState;
                currentState  = AttackState.ICE;
                iceController.ElementalActive       = true;
                obeliskController.ElementalActive   = false;
                leftFireController.ElementalActive  = false;
                rightFireController.ElementalActive = false;
            }
            else if (previousState == AttackState.ICE)
            {
                previousState = currentState;
                currentState  = AttackState.FIRE;
                iceController.ElementalActive     = false;
                obeliskController.ElementalActive = false;
                if (IsEnraged)
                {
                    leftFireController.ElementalActive  = true;
                    rightFireController.ElementalActive = true;
                }
                else
                {
                    if (Random.Range(0f, 1f) > .5f)
                    {
                        leftFireController.ElementalActive  = true;
                        rightFireController.ElementalActive = false;
                    }
                    else
                    {
                        leftFireController.ElementalActive  = false;
                        rightFireController.ElementalActive = true;
                    }
                }
            }
            else
            {
                previousState = currentState;
                currentState  = Random.Range(0f, 1f) > .5f ? AttackState.ICE : AttackState.FIRE;

                iceController.ElementalActive       = false;
                obeliskController.ElementalActive   = false;
                leftFireController.ElementalActive  = false;
                rightFireController.ElementalActive = false;

                if (currentState == AttackState.FIRE)
                {
                    if (Random.Range(0f, 1f) > .5f)
                    {
                        leftFireController.ElementalActive  = true;
                        rightFireController.ElementalActive = false;
                    }
                    else
                    {
                        leftFireController.ElementalActive  = false;
                        rightFireController.ElementalActive = true;
                    }
                }
                else
                {
                    iceController.ElementalActive = true;
                }
            }
        }
        else
        {
            increaseHitCount = 0;
            previousState    = currentState;
            currentState     = AttackState.DEFENSE;
            iceController.ElementalActive       = false;
            obeliskController.ElementalActive   = true;
            leftFireController.ElementalActive  = false;
            rightFireController.ElementalActive = false;

            List <ElementalResistances> availableElements = new List <ElementalResistances>();
            for (int i = 0; i < System.Enum.GetValues(typeof(ElementalResistances)).Length; i++)
            {
                availableElements.Add((ElementalResistances)i);
            }

            reflectElementA = availableElements[Random.Range(0, availableElements.Count)];
            availableElements.Remove(reflectElementA);

            reflectElementB = availableElements[Random.Range(0, availableElements.Count)];

            Color reflectA = (reflectElementA == ElementalResistances.FIRE ? Color.red : reflectElementA == ElementalResistances.ICE ? Color.cyan : reflectElementA == ElementalResistances.SHOCK ? Color.blue : reflectElementA == ElementalResistances.POISON ? Color.green : reflectElementA == ElementalResistances.PHYSICAL ? Color.yellow : Color.magenta);
            Color reflectB = (reflectElementB == ElementalResistances.FIRE ? Color.red : reflectElementB == ElementalResistances.ICE ? Color.cyan : reflectElementB == ElementalResistances.SHOCK ? Color.blue : reflectElementB == ElementalResistances.POISON ? Color.green : reflectElementB == ElementalResistances.PHYSICAL ? Color.yellow : Color.magenta);
            obeliskController.transform.Find("PrimarySprite/TR_Corner").GetComponent <SpriteRenderer>().color = obeliskController.transform.Find("PrimarySprite/BL_Corner").GetComponent <SpriteRenderer>().color = reflectA;
            obeliskController.transform.Find("PrimarySprite/BR_Corner").GetComponent <SpriteRenderer>().color = obeliskController.transform.Find("PrimarySprite/TL_Corner").GetComponent <SpriteRenderer>().color = reflectB;
        }
    }