void Awake()
 {
     frogMovement = GetComponent<Imovement>() as Imovement ;
     shotgun = GetComponentInChildren<ShotgunController>(true);
     swipeToJumpConversionRatio = maxJumpLength / maxJumpSwipe;
     minimalDragScreenDistance = (Camera.main.WorldToScreenPoint(new Vector3(minimalDragDistance, 0f, 0f)) - Camera.main.WorldToScreenPoint(Vector3.zero)).sqrMagnitude;
 }
Example #2
0
    public void Fire()
    {
        if (!stop)
        {
            if (Bazooka == true)
            {
                bulletSpawnTransform = GameObject.Find("PLSpawn").transform;
                if (!fire && !timedFire && !onLadder && !stuckToWall)
                {
                    if (pickup.bazookaAmmo > 0f)
                    {
                        Vib100();
                        isAttacking = true;
                        fire        = true;
                        animator.SetBool("BazookaFire", true);
                        GetComponent <AudioSource>().PlayOneShot(Launch, 1.0f);
                        GameObject             newBullet = (GameObject)Instantiate(bulletPrefab);
                        GameObject             newKick   = (GameObject)Instantiate(rocketKick);
                        PlayerBulletController bullCon   = newBullet.GetComponent <PlayerBulletController>();
                        ParticleFlip           kickCon   = newKick.GetComponent <ParticleFlip>();
                        bullCon.playerObject = gameObject;
                        kickCon.playerObject = gameObject;
                        bullCon.launchBullet();
                        kickCon.launchBullet();
                        newBullet.transform.position = bulletSpawnTransform.position;
                        newKick.transform.position   = bulletSpawnTransform.position;
                        pickup.bazookaAmmo--;
                    }

                    else if (pickup.bazookaAmmo == 0f)
                    {
                        GetComponent <AudioSource>().PlayOneShot(outOfAmmo);
                    }
                }
            }

            if (Shotgun == true)
            {
                shotgunBulletSpawn = GameObject.Find("ShotGunSpawnPoint").transform;
                if (!fire && !onLadder && !stuckToWall)
                {
                    if (pickup.shotgunAmmo > 0f)
                    {
                        Vib100();
                        isAttacking = true;
                        fire        = true;
                        animator.SetBool("ShotgunFire", true);
                        GetComponent <AudioSource>().PlayOneShot(shotgunShot, 1.0f);
                        GameObject        newBullet = (GameObject)Instantiate(shotgunBullet);
                        GameObject        newKick   = (GameObject)Instantiate(shotgunKick);
                        ShotgunController bullCon   = newBullet.GetComponent <ShotgunController>();
                        ParticleFlip      kickCon   = newKick.GetComponent <ParticleFlip>();
                        bullCon.playerObject = gameObject;
                        kickCon.playerObject = gameObject;
                        bullCon.ShotgunShoot();
                        kickCon.ShotgunShoot();
                        newBullet.transform.position = shotgunBulletSpawn.position;
                        newKick.transform.position   = shotgunBulletSpawn.position;
                        pickup.shotgunAmmo--;
                    }

                    else if (pickup.shotgunAmmo == 0f)
                    {
                        GetComponent <AudioSource>().PlayOneShot(outOfAmmo);
                    }
                }
            }

            if (Watergun == true)
            {
                watergunBulletSpawn = GameObject.Find("WaterGunSpawnPoint").transform;
                if (!fire && !onLadder && !stuckToWall)
                {
                    Vib100();
                    isAttacking = true;
                    fire        = true;
                    animator.SetBool("WaterGunFire", true);
                    GetComponent <AudioSource>().PlayOneShot(watergunShot, 1.0f);
                    GameObject         newBullet = (GameObject)Instantiate(watergunBullet);
                    GameObject         newKick   = (GameObject)Instantiate(watergunKick);
                    WaterGunController bullCon   = newBullet.GetComponent <WaterGunController>();
                    ParticleFlip       kickCon   = newKick.GetComponent <ParticleFlip>();
                    bullCon.playerObject = gameObject;
                    kickCon.playerObject = gameObject;
                    bullCon.WaterGunShoot();
                    kickCon.WaterGunShoot();
                    newBullet.transform.position = watergunBulletSpawn.position;
                    newKick.transform.position   = watergunBulletSpawn.position;
                }
            }

            if (Staff)
            {
                staffBulletSpawn = GameObject.Find("StaffSpawnPoint").transform;
                if (!fire && !onLadder && !stuckToWall)
                {
                    staffClicks++;
                    if (staffClicks == 1)
                    {
                        staffTimer = 0.5f;
                    }

                    else if (pickup.staffAmmo > 5f && staffClicks == 2 && !staffFired)
                    {
                        if (staffTimer > 0.3f)
                        {
                            Vib500();
                            isAttacking = true;
                            fire        = true;
                            stop        = true;
                            Stop();
                            animator.SetBool("StaffBoom", true);
                            GameObject newPower = Instantiate(power);
                            newPower.transform.position = staffBulletSpawn.position;
                            pickup.staffAmmo           -= 5;
                        }
                    }

                    else if (pickup.staffAmmo == 0f)
                    {
                        GetComponent <AudioSource>().PlayOneShot(outOfAmmo);
                    }
                }
            }

            if (Granade == true)
            {
                granadeBulletSpawn = GameObject.Find("GranadeSpawnPoint").transform;
                if (!fire && !timedFire && !onLadder && !stuckToWall)
                {
                    if (pickup.granadeAmmo > 0f)
                    {
                        isAttacking = true;
                        fire        = true;
                        animator.SetBool("GranadeFire", true);
                    }

                    else if (pickup.granadeAmmo == 0f)
                    {
                        GetComponent <AudioSource>().PlayOneShot(outOfAmmo);
                    }
                }
            }

            if (Boomerang == true)
            {
                boomerangBulletSpawn = GameObject.Find("BoomerangSpawnPoint").transform;
                if (!fire && !timedFire && !onLadder && !stuckToWall)
                {
                    isAttacking = true;
                    fire        = true;
                    animator.SetBool("BoomerangFire", true);
                }
            }
        }
    }
 void Awake()
 {
     lineRenderer = GetComponent<LineRenderer>();
     lineRenderer.sortingLayerName = "Frog";
     lineRenderer.sortingOrder = 50;
     jumpMarkerSensor = GetComponentInChildren<JumpMarkerSensor>();
     jumpPathSensor = GetComponentInChildren<JumpPathSensor>();
     powerup = ServiceLocator.getService<IPowerup>();
     shotgun = GetComponentInChildren<ShotgunController>(true);
 }