Exemple #1
0
 void OnCollisionEnter2D(Collision2D col)     //objects with rigidbody and box2d ontrigger false
 {
     if (_MyObject.gameObject != col.gameObject)
     {
         targets = col.gameObject.GetComponent <CreatureRoot> ();
         if (targets != null)
         {
             if (targets.Stats.HealthImmunity == false && targets.Stats.TotalImmunity == false)
             {
                 if (savedDmg * (1 - targets.Stats.PhysicalResistence) > 0)                      //If The Creature Have Resist > 1 Then The Attack Will Heal The Creature. Fire On Fire Might Heal?
                 {
                     targets.TookDmg(Mathf.CeilToInt(savedDmg * (1 - targets.Stats.PhysicalResistence)));
                 }
             }
         }
     }
 }
Exemple #2
0
    void FixedUpdate()                                                                                                                                         //Only Here For One Update, If Nothing Is Hit, The 'Spell' Is Destroyed
    {
        foreach (RaycastHit2D s in Physics2D.CapsuleCastAll(transform.position, TheCapsuleSize, CapsuleDirection2D.Vertical, 0, Vector2.zero, 0, WhatCanIHit)) //Capsule size is acting weird. the y value is the radius of the height, but the x value is the diameter of the width?????? WHAT why......

        {
            targets = s.transform.GetComponent <CreatureRoot> ();
            if (targets != null)
            {
                if (targets.Stats.HealthImmunity == false && targets.Stats.TotalImmunity == false)
                {
                    if (dmg * (1 - targets.Stats.PhysicalResistence) > 0)                      //If The Creature Have Resist > 1 Then The Attack Will Heal The Creature. Fire On Fire Might Heal?
                    {
                        targets.TookDmg(Mathf.CeilToInt(dmg * (1 - targets.Stats.PhysicalResistence)));
                    }
                }
            }
        }

        Destroy(gameObject);
    }
    // Update is called once per frame
    void Update()
    {
        if (_Target != null)
        {
            _travelPoint = _Target.transform.position;
        }


        if ((_travelPoint - transform.position).y < 0)
        {
            _Directions.z = 180 + Vector3.Angle(Vector3.left, (_travelPoint - transform.position)) - 90;
        }
        else
        {
            _Directions.z = Vector3.Angle(Vector3.right, (_travelPoint - transform.position)) - 90;
        }

        transform.eulerAngles = _Directions;
        if (Vector3.Distance(transform.position, _travelPoint) > Vector3.Distance(transform.position, transform.position + (_travelPoint - transform.position).normalized * Time.deltaTime * Speed))          //Checking If New Position Is Closer Then My Current, If False Then The Object Teleports Through To The Other Side
        {
            transform.position += (_travelPoint - transform.position).normalized * Time.deltaTime * Speed;
        }
        else
        {
            transform.position += _travelPoint - transform.position;
        }



        if (Vector3.Distance(transform.position, _travelPoint) < 0.1f)
        {
            if (_Target != null)
            {
                if (_Target.gameObject.tag == "Enemy")
                {
                    if (_TargetStats.Stats.Shield > 0)                      //Shield Is There
                    {
                        float DmgToShields = 1.5f * _TargetStats.Stats.PhysicalResistence * 2;

                        if (DmgToShields > _TargetStats.Stats.Shield)
                        {
                            _TargetStats.TookDmg(Mathf.FloorToInt(((DmgToShields - _TargetStats.Stats.Shield) / 2) + _TargetStats.Stats.Shield));                            //Calculating Dmg + Sending Dmg
                        }
                        else
                        {
                            _TargetStats.TookDmg(Mathf.FloorToInt(DmgToShields));                            //Sending Dmg
                        }
                    }
                    else
                    {
                        float DmgToHealth = 1.5f * _TargetStats.Stats.PhysicalResistence;

                        if (DmgToHealth > _TargetStats.Stats.Shield)
                        {
                            _TargetStats.TookDmg(Mathf.FloorToInt(1.5f * _TargetStats.Stats.PhysicalResistence));                            //Calculating Dmg + Sending
                        }
                    }
                }
            }

            Destroy(this.gameObject);             //Destoying On Contact With Target
        }
    }
    void FixedUpdate()
    {
        if (_StartMoving == true)
        {
            if (Dieing == false)
            {
                if (RemoveParent == false)
                {
                    RemoveParent        = true;
                    transform.parent    = null;
                    MyShootingDirection = MyShootingDirection.normalized;
                }

                transform.position += MyShootingDirection * test [0].SpellVariables [1] * Time.deltaTime;

                _ObjectHit = Physics2D.CircleCastAll(transform.position + (Vector3.right * 0.02f), test [0].SpellVariables [2], Vector2.zero, 1, WhatCanIHit);

                if (_ObjectHit.Length > 0)
                {
                    foreach (RaycastHit2D s in _ObjectHit)
                    {
                        if (s.transform.gameObject.layer == 8 || s.transform.gameObject.layer == 15)
                        {
                            targets = s.transform.GetComponent <CreatureRoot> ();
                            if (targets != null)
                            {
                                if (targets.Stats.HealthImmunity == false && targets.Stats.TotalImmunity == false)
                                {
                                    if (test [0].SpellVariables [0] * (1 - targets.Stats.PhysicalResistence) > 0)                                      //If The Creature Have Resist > 1 Then The Attack Will Heal The Creature. Fire On Fire Might Heal?
                                    {
                                        targets.TookDmg(Mathf.CeilToInt(test [0].SpellVariables [0] * (1 - targets.Stats.PhysicalResistence)));
                                    }
                                }
                            }
                        }
                    }

                    Dieing = true;
                    MyAnimator.SetInteger("SpellState", 1);
                }
            }
            else
            {
                transform.position += (MyShootingDirection * Time.deltaTime) / 2;
            }
        }
        else
        {
            MyShootingDirection = _MyObject.GetWhatToTarget().MyMovementTarget.transform.position - transform.position;

            if (MyShootingDirection.y < 0)
            {
                transform.rotation = Quaternion.Euler(0, 0, Vector3.Angle(Vector3.right, MyShootingDirection) * -1);
            }
            else
            {
                transform.rotation = Quaternion.Euler(0, 0, Vector3.Angle(Vector3.right, MyShootingDirection));
            }
            transform.localPosition = Quaternion.Euler(0, transform.parent.rotation.y, transform.parent.rotation.z) * test [0].SpawnPosition;
        }
    }
    void FixedUpdate()     //If I Hit Something I Do A Pushback On Everything Within (CircleRadius * 2.5f)
    {
        if (_MyObject == null)
        {
            Destroy(this.gameObject);
        }

        if (Collided == false)
        {
            if (_TimeToComplete > ClockTest.TheTimes)
            {
                _ObjectHit = Physics2D.CircleCastAll(transform.position, test [0].SpellVariables [1], Vector2.zero, 1, WhatCanIHit);                 //If Collided
                if (_ObjectHit.Length > 0)
                {
                    _ObjectHit = Physics2D.CircleCastAll(transform.position, test [0].SpellVariables [2], Vector2.zero, 1, WhatCanIHit);                     //If Collided Do A Expanded Pushback
                    foreach (RaycastHit2D s in _ObjectHit)
                    {
                        if (s.transform.gameObject.layer == 8 || s.transform.gameObject.layer == 15)
                        {
                            theObject = s.transform.GetComponent <CreatureRoot> ();
                            if (theObject != null)
                            {
                                if (theObject.Stats.TotalImmunity == false)
                                {
                                    if (theObject.Stats.HealthImmunity == false)
                                    {
                                        if (test [0].SpellVariables [0] * (1 - theObject.Stats.PhysicalResistence) > 0)                                          //If The Creature Have Resist > 1 Then The Attack Will Heal The Creature. Fire On Fire Might Heal?
                                        {
                                            theObject.TookDmg(Mathf.CeilToInt(test [0].SpellVariables [0] * (1 - theObject.Stats.PhysicalResistence)));
                                        }
                                    }

                                    if (theObject.Stats.VelocityImmunity == false)
                                    {
                                        vectorPower = (test [0].SpellVariables [5] * (1 - theObject.Stats.VelocityResist) - theObject.Stats.VelocityAbsorb); //Not Sertain About

                                        if (vectorPower > 0)                                                                                                 //If There Are More Resistance Then The Effect Does, Do Nothing
                                        {
                                            theObject.MyRigidBody.velocity = ((s.transform.position - transform.position).normalized * 1) * vectorPower;
                                            theObject.VelocityChange(vectorPower);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    _MyObject.GetAnimatorVariables().SetAnimatorStage(1000);                     //1000 - 1010 Is Values Used For The Purpose Of Animator State Changes Which Isnt Similar To Any Spell 'ID'
                    _MyObject.Stats.Speed -= test [0].SpellVariables [5];
                    _TimeToComplete        = ClockTest.TheTimes + test [0].SpellVariables [6];
                    Collided = true;
                }
            }
            else
            {
                _MyObject.GetAnimatorVariables().SetAnimatorStage(0);
                _MyObject.Stats.Speed -= test [0].SpellVariables [5];
                Destroy(this.gameObject);
            }
        }
        else
        {
            if (_TimeToComplete <= ClockTest.TheTimes)
            {
                _MyObject.GetAnimatorVariables().SetAnimatorStage(0);                 //1000 - 1010 Is Values Used For The Purpose Of Animator State Changes Which Isnt Similar To Any Spell 'ID'
                Destroy(this.gameObject);
            }
        }
    }