Exemplo n.º 1
0
        UniqueCreature getEnemy(RaycastHit hit)
        {
            GameObject     target = hit.collider.gameObject;
            UniqueCreature enem   = target.GetComponent <UniqueCreature>();

            return(enem);
        }
Exemplo n.º 2
0
 void pointAttack(RaycastHit hit)
 {
     if (Vector3.Distance(user.transform.position, hit.point) <= range)
     {
         UniqueCreature enemy = getEnemy(hit);
         if (true)
         {
             // Accuracy Check
             //Run damage equation
             if (AccuracyCheck(enemy))
             {
                 enemy.Damage(DamageEquation(enemy));
             }
             else
             {
                 enemy.GetComponent <UniqueCreature>().Miss();
             }
             //Debug.Log("Hit");
         }
         else
         {
             //Debug.Log("Miss");
         }
     }
 }
Exemplo n.º 3
0
 public override void Initialize(UnitAbilitiesContainer container, GameObject obj, GameObject shape)
 {
     user           = obj.GetComponent <UniqueCreature>();
     this.container = container;
     if (aoe)
     {
         this.shape = shape;
         shapeRend  = this.shape.GetComponent <Renderer>();
     }
 }
Exemplo n.º 4
0
 public void EnemyAttackNonAOE(UniqueCreature unitHit)
 {
     // Accuracy Check
     //Run damage equation
     if (AccuracyCheck(unitHit))
     {
         unitHit.Damage(DamageEquation(unitHit));
     }
     else
     {
         unitHit.GetComponent <UniqueCreature>().Miss();
     }
 }
Exemplo n.º 5
0
        public override void ShowTarget(RaycastHit hit)
        {
            if (!aoe)
            {
                StopShowAoe();
                if (Vector3.Distance(user.transform.position, hit.point) <= range)
                {
                    UniqueCreature enem = getEnemy(hit);
                    if (enem && enem != user)
                    {
                        enem.hightlight();
                    }
                }
            }
            else
            {
                if (range == 0)
                {
                    shapeRend.enabled          = true;
                    shape.transform.localScale = new Vector3(1, 1, length);
                    Vector3 dir = hit.point - user.transform.position;
                    dir = new Vector3(dir.x, 0, dir.z);
                    dir.Normalize();
                    shape.transform.position = user.transform.position + dir * ((float)length / 2f);
                    shape.transform.LookAt(user.transform.position);
                    Collider[] enemies3 = Physics.OverlapBox(shape.transform.position, shape.transform.localScale / 2, shape.transform.rotation);
                    highlightList(enemies3);
                }
                else
                {
                    Collider[] enemies = Physics.OverlapSphere(hit.point, ((float)length) / 2f);
                    highlightList(enemies);

                    if (Vector3.Distance(user.transform.position, hit.point) <= range)
                    {
                        shapeRend.enabled          = true;
                        shape.transform.localScale = new Vector3(length, length, width);
                        shape.transform.position   = hit.point;
                    }
                }
            }
        }
Exemplo n.º 6
0
 private void DamageList(Collider[] enemies)
 {
     foreach (Collider enemy in enemies)
     {
         if (enemy.GetComponent <UniqueCreature>() && enemy.GetComponent <UniqueCreature>() != user)
         {
             UniqueCreature enemyCreature = enemy.GetComponent <UniqueCreature>();
             // Accuracy Check
             //Damage Equation
             if (AccuracyCheck(enemyCreature))
             {
                 enemyCreature.Damage(DamageEquation(enemyCreature));
             }
             else
             {
                 enemyCreature.Miss();
             }
         }
     }
 }
Exemplo n.º 7
0
        public int DamageEquation(UniqueCreature enemy)
        {
            int   levelStaticForNow = 50;
            float levelMult         = (4 * levelStaticForNow / 5f);
            float topPart;

            if (isPhysical)
            {
                topPart = levelMult * damage * (user.stats.physicalAttack * 1.0f / enemy.stats.physicalDefense);
            }
            else
            {
                topPart = levelMult * damage * (user.stats.magicAttack * 1.0f / enemy.stats.magicDefense);
            }
            float preMods = (topPart / 50f) + 2;

            float randomMod   = Random.Range(.85f, 1f);
            int   finalDamage = Mathf.RoundToInt(preMods * randomMod);

            return(finalDamage);
        }
Exemplo n.º 8
0
        void Start()
        {
            audioSource = GetComponent <BrainManager>().manager.AudioSource;
            unit        = GetComponent <UniqueCreature>();
            foreach (Ability ability in abilities)
            {
                if (ability.aoe)
                {
                    switch (ability.aoeShape)
                    {
                    case 1:
                        GameObject sphereFile = Resources.Load <GameObject>("AOE/AoeSphere");
                        GameObject sphere     = Instantiate(sphereFile, Vector3.zero, Quaternion.identity);
                        sphere.GetComponent <Renderer>().enabled = false;
                        ability.Initialize(this, transform.gameObject, sphere);
                        break;

                    case 2:

                        break;

                    case 3:
                        GameObject cubeFile = Resources.Load <GameObject>("AOE/AoeCube");
                        GameObject cube     = Instantiate(cubeFile, Vector3.zero, Quaternion.identity);
                        cube.GetComponent <Renderer>().enabled = false;
                        ability.Initialize(this, transform.gameObject, cube);
                        break;

                    default:
                        Debug.Log("Something broke in unit abilities container");
                        break;
                    }
                }
                else
                {
                    ability.Initialize(this, transform.gameObject);
                }
            }
        }
Exemplo n.º 9
0
 public bool AccuracyCheck(UniqueCreature enemy)
 {
     //int extraMods = (user.stats.accuracy - enemy.stats.evasion) * 3;
     return(accuraccy > Random.Range(0, 100));
 }