Ejemplo n.º 1
0
        public virtual void FireProyectile(RaycastHit AimRay)
        {
            float percent = Random.Range(0, 1);

            Vector3 AimDirection = (AimRay.point - transform.position).normalized;

            ReduceAmmo(1);

            OnFire.Invoke(AimDirection);

            DamageValues PistolDamage =
                new DamageValues(AimRay.normal, Mathf.Lerp(MinDamage, MaxDamage, percent));                                    //Set the Direction and Damage value

            if (AimRay.transform)                                                                                              //If the AIM Ray hit something
            {
                AimRay.transform.root.SendMessage("getDamaged", PistolDamage, SendMessageOptions.DontRequireReceiver);         //Send to the thing that we hit the Damage Values

                if (AimRay.rigidbody)                                                                                          //If the thing we hit has a rigidbody
                {
                    AimRay.rigidbody.AddForceAtPosition(AimDirection * Mathf.Lerp(MinForce, MaxForce, percent), AimRay.point); //Apply the force to it
                }
                BulletHole(AimRay);

                OnHit.Invoke(AimRay.transform);  //Invoke OnHitSomething Event
            }
        }
Ejemplo n.º 2
0
 public TruckVariables()
 {
     Lights   = new LightValues();
     Warnings = new WarningValues();
     Current  = new CurrentValues();
     Damage   = new DamageValues();
     Constant = new ConstantValues();
 }
Ejemplo n.º 3
0
        public virtual void OnHit(RaycastHit other)
        {
            DamageValues DV = new DamageValues(-transform.forward, damage);

            if (other.transform)
            {
                other.transform.SendMessageUpwards("getDamaged", DV, SendMessageOptions.DontRequireReceiver);

                if (other.rigidbody && AffectRigidBodies)
                {
                    other.rigidbody.AddForceAtPosition(transform.forward * force, other.point);
                }
            }



            //  _Rigidbody.isKinematic = true;
            _Rigidbody.constraints = RigidbodyConstraints.FreezeAll;


            //FIX FOR SCALED OBJECTS
            Vector3 NewScale = other.transform.lossyScale;

            NewScale.x = 1f / Mathf.Max(NewScale.x, 0.0001f);
            NewScale.y = 1f / Mathf.Max(NewScale.y, 0.0001f);
            NewScale.z = 1f / Mathf.Max(NewScale.z, 0.0001f);

            GameObject Hlper = new GameObject();

            Hlper.name = name + "Link";

            Hlper.transform.parent     = other.collider.transform;
            Hlper.transform.localScale = NewScale;
            Hlper.transform.position   = other.point;
            //Hlper.transform.localPosition = other.transform.InverseTransformPoint(other.point);
            Hlper.transform.localRotation = Quaternion.identity;

            transform.parent        = Hlper.transform;
            transform.localScale    = Vector3.one;
            transform.localPosition = Vector3.zero;

            transform.position += transform.forward * Penetration; //Put the arrow a bit deeper in the collider

            Destroy(Hlper, AgeAfterImpact);
            Destroy(gameObject, AgeAfterImpact);

            OnHitTarget.Invoke(other);

            if (timeAfterImpact > 0)
            {
                Invoke("InvokeAfterImpact", timeAfterImpact);
            }
            else
            {
                AfterImpact.Invoke();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Will Send
        /// </summary>
        /// <param name="other"></param>
        public virtual void TestHit(RaycastHit other)
        {
            DamageValues DV = new DamageValues(-transform.forward, damage);

            if (other.transform)
            {
                other.transform.SendMessageUpwards("getDamaged", DV, SendMessageOptions.DontRequireReceiver);

                if (other.rigidbody && AffectRigidBodies)
                {
                    other.rigidbody.AddForceAtPosition(transform.forward * force, other.point);
                }
            }
            OnHitTarget.Invoke(other);
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Selects a group of enemies to hit with the spirit side final attack and returns the
    /// damage numbers for the attack.
    /// </summary>
    /// <param name="hits"></param>
    /// <param name="baseDamage"></param>
    /// <param name="top"></param>
    /// <param name="leftside"></param>
    /// <returns></returns>
    public List <DamageValues> GetRandomEnemies(int hits, int baseDamage, bool top, bool leftside)
    {
        List <DamageValues> values = new List <DamageValues>();

        if (top)
        {
            int i = 0, j = 0, h = 0;
            while (h < hits)
            {
                if (groups[i].alive && groups[i].sStateController.leftSide == leftside)
                {
                    if (j == h)
                    {
                        DamageValues d = new DamageValues(groups[i].sTransform);
                        d.baseDamage = baseDamage;
                        values.Add(d);
                    }
                    else
                    {
                        values[j].baseDamage += baseDamage;
                    }
                    h++;
                    j++;
                }

                i++;

                if (i >= groups.Count)
                {
                    if (h == 0)
                    {
                        Debug.LogWarning("Everyone is dead or not here");
                        return(null);
                    }
                    i = 0;
                    j = 0;
                }
            }
        }
        else
        {
            values.Add(new DamageValues(groups[0].nTransform));
        }

        return(values);
    }
Ejemplo n.º 6
0
        internal void SetDamageStuff(Vector3 OtherHitPoint, Transform other)
        {
            if (other.root == transform.root)
            {
                return;                               //if Im hitting myself
            }
            Mountable montura = other.GetComponentInParent <Mountable>();

            if (montura == Owner.Montura)
            {
                return;                           //if Im hitting my horse **New
            }
            if (!MalbersTools.Layer_in_LayerMask(other.gameObject.layer, HitMask))
            {
                return;                                                                   //Just hit what is on the HitMask Layer
            }
            DV = new DamageValues(meleeCollider.bounds.center - OtherHitPoint, Random.Range(MinDamage, MaxDamage));

            Debug.DrawLine(OtherHitPoint, meleeCollider.bounds.center, Color.red, 3f);


            if (canCauseDamage && !AlreadyHitted.Find(item => item == other.transform.root))                        //If can cause damage and If I didnt hit the same transform twice
            {
                AlreadyHitted.Add(other.transform.root);
                other.transform.root.SendMessage("getDamaged", DV, SendMessageOptions.DontRequireReceiver);         //To everybody who has GetDamaged()


                Rigidbody OtherRB = other.transform.root.GetComponent <Rigidbody>();

                if (OtherRB && other.gameObject.layer != 20)                                                        //Apply Force if the game object has a RigidBody && if is not an Animal
                {
                    OtherRB.AddExplosionForce(MinForce * 50, OtherHitPoint, 20);
                }

                PlaySound(3);                                                                                       //Play Hit Sound when get something

                OnHit.Invoke(other.gameObject);

                if (!meleeCollider.isTrigger)
                {
                    meleeCollider.enabled = false;
                }
            }
        }
    public static void DoesNetrixiAttack(int playerAttack, int attackNumber)
    {
        // Check if Netrixi is still alive
        if (!CombatManagerScript.netrixiAlive)
        {
            // Skip the attack
            if (attackNumber == 1)
            {
                CombatSimulationScript.attack1Delay = DamageValues.standardDelay;
            }
            else
            {
                CombatSimulationScript.attack2Delay = DamageValues.standardDelay;
            }
        }
        else
        {
            float original;
            float burnRate;


            // ATTACK 1
            // Netrixi's Fireball
            if (playerAttack == 1)
            {
                original = DamageValues.fireball * AttackScript.damageModifier;
                burnRate = DamageValues.fireballBurn;
                int damageValue = (int)original;

                if (CombatManagerScript.enemy1Alive)
                {
                    if (CombatManagerScript.enemy2Alive && EnemyManagerScript.enemy2 != "null")
                    {
                        // If Enemies 1 + 2 + 3 are alive
                        if (CombatManagerScript.enemy3Alive && EnemyManagerScript.enemy3 != "null")
                        {
                            DamageValues.ChangeDelay(3);

                            // TODO: Play Netrixi Fireball animation
                            HealthManagerScript.ChangeHealth("Enemy 1", damageValue, burnRate);
                            HealthManagerScript.ChangeHealth("Enemy 2", damageValue, burnRate);
                            HealthManagerScript.ChangeHealth("Enemy 3", damageValue, burnRate);
                        }
                        // If Enemies 1 + 2 are alive
                        else
                        {
                            DamageValues.ChangeDelay(2);

                            int randomValue = UnityEngine.Random.Range(0, 2);

                            if (randomValue <= 1)
                            {
                                // Launch 2 fireballs at Enemy 2
                                // TODO: Play Netrixi Fireball animation
                                HealthManagerScript.ChangeHealth("Enemy 1", damageValue * 1, burnRate);
                                HealthManagerScript.ChangeHealth("Enemy 2", damageValue * 2, burnRate);
                            }
                            else
                            {
                                // Launch 2 fireballs at Enemy 1
                                // TODO: Play Netrixi Fireball animation
                                HealthManagerScript.ChangeHealth("Enemy 1", damageValue * 2, burnRate);
                                HealthManagerScript.ChangeHealth("Enemy 2", damageValue * 1, burnRate);
                            }
                        }
                    }
                    else
                    {
                        // If Enemies 1 + 3 are alive
                        if (CombatManagerScript.enemy3Alive && EnemyManagerScript.enemy3 != "null")
                        {
                            DamageValues.ChangeDelay(2);

                            int randomValue = UnityEngine.Random.Range(0, 2);

                            if (randomValue <= 1)
                            {
                                // Launch 2 fireballs at Enemy 3
                                // TODO: Play Netrixi Fireball animation
                                HealthManagerScript.ChangeHealth("Enemy 1", damageValue * 1, burnRate);
                                HealthManagerScript.ChangeHealth("Enemy 3", damageValue * 2, burnRate);
                            }
                            else
                            {
                                // Launch 2 fireballs at Enemy 1
                                // TODO: Play Netrixi Fireball animation
                                HealthManagerScript.ChangeHealth("Enemy 1", damageValue * 2, burnRate);
                                HealthManagerScript.ChangeHealth("Enemy 3", damageValue * 1, burnRate);
                            }
                        }
                        // If only Enemy 1 is alive
                        else
                        {
                            DamageValues.ChangeDelay(1);

                            // TODO: Play Netrixi Fireball animation
                            HealthManagerScript.ChangeHealth("Enemy 1", damageValue * 3, burnRate);
                        }
                    }
                }
                else
                {
                    if (CombatManagerScript.enemy2Alive && EnemyManagerScript.enemy2 != "null")
                    {
                        // If Enemies 2 + 3 are alive
                        if (CombatManagerScript.enemy3Alive && EnemyManagerScript.enemy3 != "null")
                        {
                            DamageValues.ChangeDelay(2);

                            int randomValue = UnityEngine.Random.Range(0, 2);

                            if (randomValue <= 1)
                            {
                                // Launch 2 fireballs at Enemy 3
                                // TODO: Play Netrixi Fireball animation
                                HealthManagerScript.ChangeHealth("Enemy 2", damageValue * 1, burnRate);
                                HealthManagerScript.ChangeHealth("Enemy 3", damageValue * 2, burnRate);
                            }
                            else
                            {
                                // Launch 2 fireballs at Enemy 2
                                // TODO: Play Netrixi Fireball animation
                                HealthManagerScript.ChangeHealth("Enemy 2", damageValue * 2, burnRate);
                                HealthManagerScript.ChangeHealth("Enemy 3", damageValue * 1, burnRate);
                            }
                        }
                        // If only Enemy 2 is alive
                        else
                        {
                            DamageValues.ChangeDelay(1);

                            // TODO: Play Netrixi Fireball animation
                            HealthManagerScript.ChangeHealth("Enemy 2", damageValue * 3, burnRate);
                        }
                    }
                    else
                    {
                        // If only Enemy 3 is alive
                        if (CombatManagerScript.enemy3Alive && EnemyManagerScript.enemy3 != "null")
                        {
                            DamageValues.ChangeDelay(1);

                            // TODO: Play Netrixi Fireball animation
                            HealthManagerScript.ChangeHealth("Enemy 3", damageValue * 3, burnRate);
                        }
                    }
                }

                AttackScript.delayRate = DamageValues.fireballDelay;
            }


            // ATTACK 2
            // Netrixi's Lightning
            if (playerAttack == 2)
            {
                original = DamageValues.lightning * AttackScript.damageModifier;
                burnRate = DamageValues.lightningBurn;
                AttackScript.delayRate = DamageValues.lightningDelay;
                int damageValue = (int)original;


                if (attackNumber == 1)
                {
                    DetermineEnemyPosition(CombatManagerScript.target1Location);
                }
                else
                {
                    DetermineEnemyPosition(CombatManagerScript.target2Location);
                }


                void DetermineEnemyPosition(int targetLocation)
                {
                    switch (targetLocation)
                    {
                    // If an enemy is on square 6
                    case 1:
                        if (EnemyManagerScript.enemy1Position == 6)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 1", damageValue, burnRate);
                        }

                        if (EnemyManagerScript.enemy2Position == 6)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 2", damageValue, burnRate);
                        }

                        if (EnemyManagerScript.enemy3Position == 6)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 3", damageValue, burnRate);
                        }
                        break;

                    // If an enemy is on square 7
                    case 2:
                        if (EnemyManagerScript.enemy1Position == 7)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 1", damageValue, burnRate);
                        }

                        if (EnemyManagerScript.enemy2Position == 7)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 2", damageValue, burnRate);
                        }

                        if (EnemyManagerScript.enemy3Position == 7)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 3", damageValue, burnRate);
                        }
                        break;

                    // If an enemy is on square 8
                    case 3:
                        if (EnemyManagerScript.enemy1Position == 8)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 1", damageValue, burnRate);
                        }

                        if (EnemyManagerScript.enemy2Position == 8)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 2", damageValue, burnRate);
                        }

                        if (EnemyManagerScript.enemy3Position == 8)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 3", damageValue, burnRate);
                        }
                        break;

                    // If an enemy is on square 9
                    case 4:
                        if (EnemyManagerScript.enemy1Position == 9)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 1", damageValue, burnRate);
                        }

                        if (EnemyManagerScript.enemy2Position == 9)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 2", damageValue, burnRate);
                        }

                        if (EnemyManagerScript.enemy3Position == 0)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 3", damageValue, burnRate);
                        }
                        break;

                    // If an enemy is on square 10
                    case 5:
                        if (EnemyManagerScript.enemy1Position == 10)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 1", damageValue, burnRate);
                        }

                        if (EnemyManagerScript.enemy2Position == 10)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 2", damageValue, burnRate);
                        }

                        if (EnemyManagerScript.enemy3Position == 10)
                        {
                            // TODO: Play Netrixi Lightning animation
                            HealthManagerScript.ChangeHealth("Enemy 3", damageValue, burnRate);
                        }
                        break;
                    }
                }
            }


            // ATTACK 3
            // Netrixi's Transmutate
            if (playerAttack == 3)
            {
                AttackScript.delayRate = DamageValues.transmutateDelay;

                List <String> enemiesToTransform = new List <string>();
                List <String> transformChoices   = new List <string>();

                // Determine which enemies can be transformed
                if (CombatManagerScript.enemy1Alive && CombatManagerScript.canEnemy1Attack)
                {
                    enemiesToTransform.Add("Enemy 1");
                }
                if (CombatManagerScript.enemy2Alive && CombatManagerScript.canEnemy2Attack)
                {
                    enemiesToTransform.Add("Enemy 2");
                }
                if (CombatManagerScript.enemy3Alive && CombatManagerScript.canEnemy3Attack)
                {
                    enemiesToTransform.Add("Enemy 3");
                }

                // Choose a random enemy to transform
                if (enemiesToTransform.Count >= 1)
                {
                    var randomIndex = UnityEngine.Random.Range(0, (enemiesToTransform.Count));

                    // Determine whether the enemy is transformed or not
                    transformChoices.Add("Cat");
                    transformChoices.Add("Dog");
                    transformChoices.Add("Frog");

                    // Creates the option for the transmutation spell to fail
                    for (int i = 0; i < DamageValues.choices - transformChoices.Count; i++)
                    {
                        transformChoices.Add("None");
                    }

                    // Choose a random creature for the enemy to transform into
                    var randomIndex1 = UnityEngine.Random.Range(0, (transformChoices.Count));



                    // If an animal was chosen for the enemy to transform into
                    if (transformChoices[randomIndex1] != "None")
                    {
                        TransformEnemy(enemiesToTransform[randomIndex], CombatManagerScript.roundNumber, transformChoices[randomIndex1]);
                    }
                    else
                    {
                        print("Spell cast failed: " + enemiesToTransform[randomIndex] + " was not transformed");
                    }
                }
                else
                {
                    print("There are no enemies to transform");
                }
            }
        }
    }
    public static void DoesIvAttack(int playerAttack, int attackNumber)
    {
        if (!CombatManagerScript.ivAlive)
        {
            // Skip the attack
            if (attackNumber == 1)
            {
                CombatSimulationScript.attack1Delay = DamageValues.standardDelay;
            }
            else
            {
                CombatSimulationScript.attack2Delay = DamageValues.standardDelay;
            }
            return;
        }
        else
        {
            float original;
            float burnRate;


            // ATTACK 1
            // Iv's Block
            if (playerAttack == 7)
            {
                // TODO: Play Iv Block animation

                AttackScript.delayRate = DamageValues.blockDelay;

                blocking  = true;
                tempBlock = AttackScript.enemyAttack;
            }


            // ATTACK 2
            // Iv's Heal
            if (playerAttack == 8)
            {
                original = DamageValues.heal * AttackScript.damageModifier;
                burnRate = DamageValues.healBurn;
                int damageValue = (int)original;

                int lowestHP        = 500;
                int targetCharacter = 0;

                // Determine which character has the lowest HP;
                if (CombatManagerScript.netrixiAlive)
                {
                    targetCharacter = 1;
                    lowestHP        = CombatManagerScript.netrixiHP;
                }
                if (CombatManagerScript.folkvarAlive)
                {
                    if (CombatManagerScript.folkvarHP < lowestHP)
                    {
                        targetCharacter = 2;
                        lowestHP        = CombatManagerScript.folkvarHP;
                    }
                }
                if (CombatManagerScript.ivAlive)
                {
                    if (CombatManagerScript.ivHP < lowestHP)
                    {
                        targetCharacter = 3;
                        lowestHP        = CombatManagerScript.ivHP;
                    }
                }


                switch (targetCharacter)
                {
                // Netrixi
                case 1:
                    // If Netrixi is below her starting HP
                    if (CombatManagerScript.netrixiHP < HealthValues.netrixiHP)
                    {
                        // TODO: Play Iv Heal animation
                        int temp = CalculateMissingHealth(CombatManagerScript.netrixiHP, HealthValues.netrixiHP, damageValue);
                        DamageValues.ChangeHealDelay(temp, 0);

                        HealthManagerScript.ChangeHealth("Netrixi", -temp, burnRate);
                        print("Heal Netrixi");
                    }
                    else
                    {
                        print("Netrixi is already at full health!");
                        DamageValues.healDelay = DamageValues.standardDelay;
                    }
                    break;

                // Folkvar
                case 2:
                    // If Folkvar is below his starting HP
                    if (CombatManagerScript.folkvarHP < HealthValues.folkvarHP)
                    {
                        // TODO: Play Iv Heal animation
                        int temp = CalculateMissingHealth(CombatManagerScript.folkvarHP, HealthValues.folkvarHP, damageValue);
                        DamageValues.ChangeHealDelay(temp, 0);

                        HealthManagerScript.ChangeHealth("Folkvar", -temp, burnRate);
                        print("Heal Folkvar");
                    }
                    else
                    {
                        print("Folkvar is already at full health!");
                        DamageValues.healDelay = DamageValues.standardDelay;
                    }
                    break;

                // Iv
                case 3:
                    // If Iv is below her starting HP
                    if (CombatManagerScript.ivHP < HealthValues.ivHP)
                    {
                        // TODO: Play Iv Heal animation
                        int temp = CalculateMissingHealth(CombatManagerScript.ivHP, HealthValues.ivHP, damageValue);
                        DamageValues.ChangeHealDelay(temp, 0);

                        HealthManagerScript.ChangeHealth("Iv", -temp, burnRate);
                        print("Heal Iv");
                    }
                    else
                    {
                        print("Iv is already at full health!");
                        DamageValues.healDelay = DamageValues.standardDelay;
                    }
                    break;
                }

                AttackScript.delayRate = DamageValues.healDelay;
            }


            // ATTACK 3
            // Iv's Empower
            if (playerAttack == 9)
            {
                // TODO: Play Iv Empower animation

                AttackScript.delayRate = DamageValues.empowerDelay;

                empowered   = true;
                tempEmpower = AttackScript.playerAttack;

                // Determine how much to increase the damage of the next attack by
                if (attackNumber == 1)
                {
                    DetermineDamageBoost(CombatManagerScript.target1Location);
                }
                else
                {
                    DetermineDamageBoost(CombatManagerScript.target2Location);
                }


                // TODO: Finish Empower-Counter interaction
            }
        }
    }