Beispiel #1
0
    /// <summary>
    ///
    /// direction only concerns with .y's sign
    ///
    /// angle == 0 is UP
    ///
    /// </summary>
    /// <param name="direction"></param>
    /// <param name="angle"></param>
    /// <param name="bulletType"></param>
    /// <param name="infinite"></param>
    public void launchBullet(Vector3 direction, float angle, int bulletType, bool infinite)
    {
        if (!infinite)
        {
            //play the animation regardless of if a bullet is actually shot
            anim.SetTrigger("shoot");
            if (anim.GetBool("Shoot") == true)
            {
                //reset the animation clip if multiple shots are happening
                anim.Play("B_ShootLeft", -1, 0f);
            }
            anim.SetBool("Shoot", true);
        }

        //actual shooting of the pellets
        if (infinite)
        {
            //normal attack
            Vector3 pos = transform.GetComponent <RectTransform>().position;
            pos.x += (direction.y > 0 ? bulletWeaponDist : -bulletWeaponDist) *             //TODO the 32 looks fishy here
                     Mathf.Sin(angle) * (32);
            pos.y += (direction.y > 0 ? bulletWeaponDist : -bulletWeaponDist) *
                     Mathf.Cos(angle) * (32);
            pos.z = 5;
            //from cannon's position plus a little bit of delta x and y to find the firing pos

            GameObject bullet = Instantiate(BulletPrefabs[bulletType], pos,
                                            BulletPrefabs[bulletType].transform.rotation) as GameObject;

            if (!infinite)
            {
                fire[(int)(Random.Range(0, fire.Length - 0.01f))].Play();                      //sound
            }
            MyBullet bulletScript = bullet.GetComponent <MyBullet>();
            bulletScript.passPrefabHolder(prefabHolder);
            bulletScript.setDirection(direction, angle, false);             //no rotation since only going up for now


            //apply additional effects
            if (bulletGaugeSelected != -1)
            {
                //applying special effects to attack; subtracting from the gauge of that pb

                bulletScript.setBulletColor(bulletGauge[bulletGaugeSelected]);

                decrementGaugeCapacity(bulletGaugeSelected, 1);

                if (bulletGaugeContent[bulletGaugeSelected] <= 0)                //exhaust
                {
                    removePaint(bulletGaugeSelected);
                }
            }
            else
            {
                bulletScript.setBulletColor(PaintballBehavior.ColorMode.NON);
            }
        }
        //is interrupted, aiming animation can still transition back to normal
    }
    // Set up new Weapon
    public void SetUpGun(string tag)
    {
        // Guns
        if (tag == "Default Gun")
        {
            equippedWeapon = guns[0];
        }

        if (tag == "Green Gun")
        {
            // Setting up the green gun
            equippedWeapon = guns[1];
        }

        if (tag == "Blue Gun")
        {
            // Setting up the blue gun
            equippedWeapon = guns[2];
        }

        if (tag == "Purple Gun")
        {
            // Setting up the purple gun
            equippedWeapon = guns[3];
        }

        if (tag == "Orange Gun")
        {
            // Setting up the orange gun
            equippedWeapon = guns[4];
        }

        if (tag == "Red Gun")
        {
            // Setting up the red gun
            equippedWeapon = guns[5];
        }

        // Setting up the script to access to the weapon properties
        mw = equippedWeapon.GetComponent <MyWeapon>();

        // Setting up the fireRate and ammo of the new weapon
        fireRate = mw.fireRate;

        // Setting up the bullet of the new weapon
        bullet = mw.bullet;
        mb     = bullet.GetComponent <MyBullet>();

        // Setting up the speed and strength of new the bullet
        speed = mb.speed;
        // strength = mb.strength;

        // Update Interface
        powerSld.maxValue = mw.ammo;
        powerSld.value    = mw.ammo;
        dw.Display(equippedWeapon);
    }
Beispiel #3
0
        /// <summary>
        /// 一動作毎に更新する用
        /// </summary>
        public void Update()
        {
            if (_shotIntervalCount > 0)
            {
                _shotIntervalCount--;
            }

            MyBullet.Update();
        }
    // Set Up Bullet
    public void SetUpBullet()
    {
        Color newColor = Color.grey;

        // Red Bullet
        if (power >= 950)
        {
            bullet   = bullets[0];
            newColor = new Color(1, 0, .1882353f, 1);
        }

        // Orange Bullet
        else if (power >= 800 && power < 950)
        {
            bullet   = bullets[1];
            newColor = new Color(1, 0.509804f, 0, 1);
        }

        // Purple Bullet
        else if (power >= 600 && power < 800)
        {
            bullet   = bullets[2];
            newColor = new Color(0.6352941f, 0, 1, 1);
        }

        // Blue Bullet
        else if (power >= 350 && power < 600)
        {
            bullet   = bullets[3];
            newColor = new Color(0, 0.8666667f, 1, 1);
        }

        // Green Bullet
        else if (power >= 100 && power < 350)
        {
            bullet   = bullets[4];
            newColor = new Color(0.01960784f, 1, 0, 1);
        }

        // Grey Bullet
        else if (power < 100)
        {
            bullet   = bullets[5];
            newColor = Color.grey;
        }

        mb = bullet.GetComponent <MyBullet>();

        speed    = mb.speed;
        fireRate = mb.fireRate;
        // strength = mb.strength;

        fill.color          = newColor;
        powerTxt.color      = newColor;
        powerValueTxt.color = newColor;
    }
Beispiel #5
0
    /*COLLISIONS*/
    private void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject bullet = collision.gameObject;
        MyBullet   mb     = bullet.GetComponent <MyBullet>();

        health -= mb.strength;

        animator.SetTrigger("hit");

        // Debug.Log(health);

        if (health <= 0)
        {
            chosenPosition.setIsFree(true);
            Instantiate(deathParticles, transform.position, Quaternion.identity);
            Destroy(gameObject);
        }
    }
Beispiel #6
0
 private void OnCollisionEnter(Collision collision)
 {
     if (gameManager == null || !gameManager.gameStarted || gameManager.gameEnded || playerStats.IsDead())
     {
         return;
     }
     if (collision.transform.CompareTag("Bullet"))
     {
         Vector3  point       = Vector3.zero;
         float    shootDamage = 0;
         MyBullet bullet      = collision.transform.GetComponent <MyBullet>();
         if (bullet != null && bullet.myPlayerStats != null)
         {
             shootDamage = bullet.myPlayerStats.shootDamage;
             point       = collision.GetContact(0).point;
             photonView.RPC("TakeDamage", RpcTarget.AllBuffered, shootDamage, point);
             PhotonNetwork.Destroy(bullet.photonView);
         }
     }
 }
Beispiel #7
0
    public void Shoot()
    {
        if (bulletPrefab != null && _firePoint != null && shooter != null)
        {
            GameObject myBullet        = Instantiate(bulletPrefab, _firePoint.transform.position, Quaternion.identity) as GameObject;
            MyBullet   bulletComponent = myBullet.GetComponent <MyBullet>();

            if (shooter.transform.localScale.x < 0f)
            {
                //left
                bulletComponent.direction = Vector2.left;
            }
            else
            {
                bulletComponent.direction = Vector2.right;
            }
        }
        else
        {
            //Right
        }
    }