Exemplo n.º 1
0
 public void SendSpellCast()
 {
     //if (!BlobArmorAttackOnceBool)
     //{
     if (InternalSpellCastCD_ < 0)
     {
         CS.CastCurrentSpell();
         InternalSpellCastCD_ = 0.2f;
     }
     //   if (BlobArmorBool)
     //    {
     //        BlobArmorAttackOnceBool = true;
     //    }
     //}
 }
Exemplo n.º 2
0
    public void WeaponAttack()
    {
        if (spellSlot1rdy == true && player_.DieOnce == false)
        {
            switch (CurrentWeapon)
            {
            case 0:
                spellSlotCD = 0.5f;
                break;


            case 1:
                WeaponSpider spell = Weapons[CurrentWeapon].GetComponent <WeaponSpider>();
                spellSlotCD = spell.cooldown;
                GameObject spider1 = Instantiate(spell.ItemObject, transform.position, transform.rotation, transform);
                GameObject spider2 = Instantiate(spell.ItemObject, transform.position, transform.rotation, transform);

                spider1.transform.position += spider1.transform.right * 2;
                spider2.transform.position += spider2.transform.right * -2;

                spider1.transform.parent = null;
                spider2.transform.parent = null;

                break;

            case 2:
                Blink      spell2 = Weapons[CurrentWeapon].GetComponent <Blink>();
                Ray        ray    = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit) && hit.collider.gameObject.tag == "Floor" || hit.collider.gameObject.tag == "Monster" || hit.collider.gameObject.tag == "Token" || hit.collider.gameObject.tag == "Door")
                {
                    TelePortDoor = false;
                    Tele1Effect  = Instantiate(TelePortEffect, Player1.transform.position, Player1.transform.rotation);
                    Tele1Effect.transform.parent = Player1.transform;

                    ParticleSystem Tele1Effect2 = Instantiate(TelePortEffect, hit.point, Player1.transform.rotation);
                    TeleLoc = hit.point;
                    Destroy(Tele1Effect.transform.gameObject, 3.1f);
                    Destroy(Tele1Effect2.transform.gameObject, 3.1f);

                    Invoke("TelePortPlayer", 1f);
                    spellSlotCD = spell2.cooldown;
                }
                else
                {
                    spellSlotCD = 0.5f;
                }
                break;

            case 3:
                Blink      spell3 = Weapons[CurrentWeapon].GetComponent <Blink>();
                Ray        ray2   = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit2;
                if (Physics.Raycast(ray2, out hit2))
                {
                    // Code Here.
                    Vector3 Pos = new Vector3(Player1.transform.position.x, 1.5f, Player1.transform.position.z);
                    Player1.transform.LookAt(hit2.point);
                    GameObject PoolObj = Instantiate(spell3.ItemObject, Pos + Player1.transform.forward * 4, transform.rotation, transform);
                    PoolObj.transform.parent     = null;
                    PoolObj.transform.localScale = new Vector3(1, 1, 1);
                    PoolObj.GetComponent <BigBoyFire>().PoolNumb      = 10;
                    PoolObj.GetComponent <BigBoyFire>().PlayerCasting = true;
                    PoolObj.GetComponent <BigBoyFire>().duration      = 3f;
                    PoolObj.GetComponent <BigBoyFire>().damage        = 1f;

                    spellSlotCD = spell3.cooldown;
                }
                else
                {
                    spellSlotCD = 0.5f;
                }
                break;

            case 4:
                Blink spell4 = Weapons[CurrentWeapon].GetComponent <Blink>();
                // Code Here.
                float OrbFacing   = transform.rotation.eulerAngles.x;
                float attackTimer = 0;
                for (int i = 0; i < 5; i++)
                {
                    GameObject P1 = Instantiate(spell4.ItemObject, transform);
                    player_.SpellsCastInThisRoom.Add(P1);
                    P1.transform.Rotate(0, OrbFacing, 0);
                    P1.transform.position = new Vector3(transform.position.x, 3, transform.position.z) + P1.transform.forward * 1.5f;
                    P1.GetComponent <OldKingAttack3>().FloatUpTimer += attackTimer;
                    P1.GetComponent <OldKingAttack3>().damage        = 1;
                    P1.GetComponent <OldKingAttack3>().PlayerCast    = true;
                    OrbFacing   += 72;   //360/5
                    attackTimer += 0.2f;
                }
                spellSlotCD = spell4.cooldown;
                break;

            case 5:
                Blink spell5 = Weapons[CurrentWeapon].GetComponent <Blink>();
                player_.BlobWeaponEquppied = true;
                player_.W5.SetActive(true);
                player_.BlobWeaponObject = spell5.ItemObject;
                spellSlotCD = spell5.cooldown;
                break;

            case 6:
                Blink spell6 = Weapons[CurrentWeapon].GetComponent <Blink>();
                player_.TimeStaffCDS();
                player_.ResetCDVis(spell6.ItemObject);
                spellSlotCD = spell6.cooldown;
                break;

            case 7:
                Blink      spell7    = Weapons[CurrentWeapon].GetComponent <Blink>();
                Collider[] cols      = Physics.OverlapSphere(transform.position, 35);
                bool       AnySpells = false;
                foreach (Collider c in cols)
                {
                    Monster e = c.GetComponent <Monster>();
                    if (e != null && e.tag == "Monster")
                    {
                        AnySpells = true;
                        //Monster enemy = e.GetComponent<Monster>();
                        GameObject      test123     = Instantiate(spell7.ItemObject, transform.position, transform.rotation, transform);
                        SpellProjectile Frostmeteor = test123.GetComponent <SpellProjectile>();
                        Frostmeteor.projectilespeed    = 30;
                        Frostmeteor.damage             = 1;
                        Frostmeteor.FrostBoltSlow      = true;
                        Frostmeteor.SlowDuration       = 3f;
                        Frostmeteor.SlowPercent        = 1.4f;
                        Frostmeteor.aoeSizeMeteor      = 3f;
                        Frostmeteor.FrostStaff         = true;
                        Frostmeteor.spellCastLocation  = e.transform.position;
                        Frostmeteor.transform.position = new Vector3(transform.position.x, 20, transform.position.z);
                        player_.SpellsCastInThisRoom.Add(test123);
                    }
                }

                if (!AnySpells)
                {
                    GameObject      test12345   = Instantiate(spell7.ItemObject, transform.position, transform.rotation, transform);
                    SpellProjectile Frostmeteor = test12345.GetComponent <SpellProjectile>();
                    Frostmeteor.projectilespeed    = 15;
                    Frostmeteor.damage             = 1;
                    Frostmeteor.FrostBoltSlow      = true;
                    Frostmeteor.SlowDuration       = 3f;
                    Frostmeteor.SlowPercent        = 1.4f;
                    Frostmeteor.aoeSizeMeteor      = 3f;
                    Frostmeteor.FrostStaff         = true;
                    Frostmeteor.spellCastLocation  = transform.position;
                    Frostmeteor.transform.position = new Vector3(transform.position.x, 20, transform.position.z);
                    player_.SpellsCastInThisRoom.Add(test12345);
                }

                spellSlotCD = spell7.cooldown;
                break;

            case 8:
                Blink spell8 = Weapons[CurrentWeapon].GetComponent <Blink>();

                GameObject test1234 = Instantiate(spell8.ItemObject, transform.position, transform.rotation, transform);

                test1234.transform.parent = null;
                Destroy(test1234, 1f);

                Collider[] cols2 = Physics.OverlapSphere(transform.position, 10);
                foreach (Collider c in cols2)
                {
                    Monster e = c.GetComponent <Monster>();
                    if (e != null && e.tag == "Monster")
                    {
                        Monster enemy = e.GetComponent <Monster>();
                        enemy.Slow(true, 2, 1.25f);
                        Vector3 directionF = (enemy.transform.position - transform.position).normalized;
                        enemy.CancelInvoke("StopPush");
                        enemy.TakeDamage(1);
                        enemy.pushDir = directionF;
                        enemy.pushed  = true;
                    }
                }
                spellSlotCD = spell8.cooldown;
                break;

            case 9:
                // Blink spell9 = Weapons[CurrentWeapon].GetComponent<Blink>();

                Spellbook SB_ = FindObjectOfType <Spellbook>();
                CastSpell CS_ = FindObjectOfType <CastSpell>();

                int curS = CastSpell.FindObjectOfType <CastSpell>().currentSlot;
                CS_.MadWeapon = true;
                SB_.LeveloneSpell(Random.Range(1, 4));
                SB_.LeveltwoSpell(Random.Range(0, 4));
                SB_.LevelthreeSpell(Random.Range(0, 5));
                SB_.LevelfourSpell(Random.Range(0, 4));
                SB_.LevelfiveSpell(Random.Range(0, 4));
                SB_.LevelsixSpell(Random.Range(0, 6));



                Ray        ray3 = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit3;
                if (Physics.Raycast(ray3, out hit3))
                {
                    CS_.spellCastLocation = hit3.point;
                    Vector3    targetPosition = hit3.point;
                    Vector3    direction      = (targetPosition - Player1.transform.position).normalized;
                    Quaternion lookRotation   = Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z));      // flattens the vector3
                    Player1.transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * 999f);
                }
                CS_.CastCurrentSpell();
                CS_.MadWeapon = false;

                switch (curS)
                {
                case 1:
                    SB_.SlotOne();
                    break;

                case 2:
                    SB_.SlotTwo();
                    break;

                case 3:
                    SB_.SlotThree();
                    break;
                }

                // spellSlotCD = spell9.cooldown;
                break;
            }
            CD1  = spellSlotCD;
            CD1_ = spellSlotCD;
        }
    }