private void Start()
 {
     anim              = GetComponent <Animator>();
     spriteRenderer    = GetComponent <SpriteRenderer>();
     meleeAttackScript = GetComponent <MeleeAttackScript>();
     bossScript        = GetComponent <BossScript>();
 }
    void HandleShooting()
    {
        if (canShoot[currentWep])
        {
            if (shootInput)
            {
                GameObject attack;
                //Debug.Log(aim);
                PoolerScript pS       = PoolerScript.instance;
                Vector3      rotation = Vector3.zero;
                string       tag      = attackPrefabs[currentWep].tag;
                Vector3      position;
                switch (aim)
                {
                case "right":
                    rotation.z = 0;
                    position   = attackSpawns[0].position;
                    pS.SpawnFromPool(tag, position, rotation);
                    attack = pS.objectToSpawn;
                    if (attack.name.Contains("Ranged"))
                    {
                        BasicParticleScript script = attack.GetComponent <BasicParticleScript>();
                        script.horiVel = script.velocity;
                        script.vertVel = 0;
                    }
                    if (attack.name.Contains("Melee"))
                    {
                        MeleeAttackScript script = attack.GetComponent <MeleeAttackScript>();
                        script.HideMe();
                    }
                    break;

                case "rightDown":
                    rotation.z = -45;
                    position   = attackSpawns[1].position;
                    pS.SpawnFromPool(tag, position, rotation);
                    attack = pS.objectToSpawn;
                    if (attack.name.Contains("Ranged"))
                    {
                        BasicParticleScript script = attack.GetComponent <BasicParticleScript>();
                        script.horiVel = script.velocity * Mathf.Cos(45);
                        script.vertVel = -script.velocity * Mathf.Cos(45);
                    }
                    if (attack.name.Contains("Melee"))
                    {
                        MeleeAttackScript script = attack.GetComponent <MeleeAttackScript>();
                        script.HideMe();
                    }
                    break;

                case "Down":
                    rotation.z = -90;
                    position   = attackSpawns[2].position;
                    pS.SpawnFromPool(tag, position, rotation);
                    attack = pS.objectToSpawn;
                    if (attack.name.Contains("Ranged"))
                    {
                        BasicParticleScript script = attack.GetComponent <BasicParticleScript>();
                        script.horiVel = 0;
                        script.vertVel = -script.velocity;
                    }
                    if (attack.name.Contains("Melee"))
                    {
                        MeleeAttackScript script = attack.GetComponent <MeleeAttackScript>();
                        script.HideMe();
                    }
                    break;

                case "leftDown":
                    rotation.z = -135;
                    position   = attackSpawns[3].position;
                    pS.SpawnFromPool(tag, position, rotation);
                    attack = pS.objectToSpawn;
                    if (attack.name.Contains("Ranged"))
                    {
                        BasicParticleScript script = attack.GetComponent <BasicParticleScript>();
                        script.horiVel = -script.velocity * Mathf.Cos(45);
                        script.vertVel = -script.velocity * Mathf.Cos(45);
                    }
                    if (attack.name.Contains("Melee"))
                    {
                        MeleeAttackScript script = attack.GetComponent <MeleeAttackScript>();
                        script.HideMe();
                    }
                    break;

                case "left":
                    rotation.z = -180;
                    position   = attackSpawns[4].position;
                    pS.SpawnFromPool(tag, position, rotation);
                    attack = pS.objectToSpawn;
                    if (attack.name.Contains("Ranged"))
                    {
                        BasicParticleScript script = attack.GetComponent <BasicParticleScript>();
                        script.horiVel = -script.velocity;
                        script.vertVel = 0;
                    }
                    if (attack.name.Contains("Melee"))
                    {
                        MeleeAttackScript script = attack.GetComponent <MeleeAttackScript>();
                        script.CancelInvoke("HideMe");
                        script.HideMe();
                    }
                    break;

                case "leftUp":
                    rotation.z = -225;
                    position   = attackSpawns[5].position;
                    pS.SpawnFromPool(tag, position, rotation);
                    attack = pS.objectToSpawn;
                    if (attack.name.Contains("Ranged"))
                    {
                        BasicParticleScript script = attack.GetComponent <BasicParticleScript>();
                        script.horiVel = -script.velocity * Mathf.Cos(45);
                        script.vertVel = script.velocity * Mathf.Cos(45);
                    }
                    if (attack.name.Contains("Melee"))
                    {
                        MeleeAttackScript script = attack.GetComponent <MeleeAttackScript>();
                        script.HideMe();
                    }
                    break;

                case "Up":
                    rotation.z = -270;
                    position   = attackSpawns[6].position;
                    pS.SpawnFromPool(tag, position, rotation);
                    attack = pS.objectToSpawn;
                    if (attack.name.Contains("Ranged"))
                    {
                        BasicParticleScript script = attack.GetComponent <BasicParticleScript>();
                        script.horiVel = 0;
                        script.vertVel = script.velocity;
                    }
                    if (attack.name.Contains("Melee"))
                    {
                        MeleeAttackScript script = attack.GetComponent <MeleeAttackScript>();
                        script.HideMe();
                    }
                    break;

                case "rightUp":
                    rotation.z = -315;
                    position   = attackSpawns[7].position;
                    pS.SpawnFromPool(tag, position, rotation);
                    attack = pS.objectToSpawn;
                    if (attack.name.Contains("Ranged"))
                    {
                        BasicParticleScript script = attack.GetComponent <BasicParticleScript>();
                        script.horiVel = script.velocity * Mathf.Cos(45);
                        script.vertVel = script.velocity * Mathf.Cos(45);
                    }
                    if (attack.name.Contains("Melee"))
                    {
                        MeleeAttackScript script = attack.GetComponent <MeleeAttackScript>();
                        script.HideMe();
                    }
                    break;

                default:
                    rotation.z = 0;
                    position   = attackSpawns[0].position;
                    pS.SpawnFromPool(tag, position, rotation);
                    attack = pS.objectToSpawn;
                    if (attack.name.Contains("Ranged"))
                    {
                        BasicParticleScript script = attack.GetComponent <BasicParticleScript>();
                        script.horiVel = script.velocity;
                        script.vertVel = 0;
                    }
                    if (attack.name.Contains("Melee"))
                    {
                        MeleeAttackScript script = attack.GetComponent <MeleeAttackScript>();
                        script.HideMe();
                    }
                    break;
                }
                //Debug.Log(rotation.z);
                canShoot[currentWep] = false;
                StartCoroutine(ReadyToShoot(currentWep));
            }
        }
    }
Esempio n. 3
0
 void Start()
 {
     meleeScript = GetComponent <MeleeAttackScript>();
 }
Esempio n. 4
0
 public override void Initialize(GameObject abilityHolder)
 {
     meleeAttackScript = abilityHolder.GetComponent <MeleeAttackScript>();
 }