public IEnumerator SelenePrimary(Vector2 startShot)
    {
        int   tempProjectiles = primaryProjectiles;
        float baseAngle       = Mathf.Atan2(tarDir.y, tarDir.x) * Mathf.Rad2Deg;

        for (int i = primaryWaves; i > 0; i--)
        {
            float angle = baseAngle - (60f / 2);
            for (int k = 0; k < tempProjectiles; k++)
            {
                float shotDirXPos = Mathf.Cos(angle * Mathf.Deg2Rad);
                float shotDirYPos = Mathf.Sin(angle * Mathf.Deg2Rad);

                Vector2 shotDirection = new Vector2(shotDirXPos, shotDirYPos) * primarySpeed;

                GameObject    tempObj       = Instantiate(primaryPrefab, startShot, Quaternion.identity);
                PrimaryBullet primaryBullet = tempObj.GetComponent <PrimaryBullet>();
                tempObj.GetComponent <SharedBullet>().playerNumber = charCon.playerNumber;
                bulletList.Add(primaryBullet);
                primaryBullet.player     = this;
                primaryBullet.shotOrigin = startShot;
                tempObj.GetComponent <Rigidbody2D>().velocity = shotDirection;
                angle += 60f / (tempProjectiles - 1);
            }
            yield return(new WaitForSeconds(.4f));

            tempProjectiles = tempProjectiles - 1;
        }
    }
Example #2
0
 // Use this for initialization
 void Start()
 {
     ES  = GameObject.Find("EternalHolder").GetComponent <EternalScript> ();
     PCS = GetComponent <PlayerControlScript> ();
     SPS = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> ();
     AS  = GetComponent <AmmoScript>();
     AS.SetSecondaryMagazineSize(2);
     PCS.SetSecondaryWeapon(Shoot);
     ShotTimer         = 0;
     ShootFireCooldown = 10;
     CanShoot          = true;
     ProjectileWrapper = Resources.Load("WallProjectileWrapper") as GameObject;
     ProjectileWrapper = Instantiate(ProjectileWrapper, Vector3.zero, Quaternion.identity) as GameObject;
     PrimaryBullet     = ProjectileWrapper.transform.GetChild(0).gameObject;
     SecondaryBullet   = ProjectileWrapper.transform.GetChild(1).gameObject;
     WPS = PrimaryBullet.GetComponent <WallProjectileScript> ();
     PrimaryBullet.SetActive(false);
     SecondaryBullet.SetActive(false);
 }
Example #3
0
    public void Shoot(Vector3 GunPoint, Quaternion PointerRotation)
    {
        if (CanShoot && AS.CheckCanShootSecondary() && FirstShot)
        {
            RaycastHit2D hit        = Physics2D.Raycast(GunPoint, transform.up);
            Vector3      FinalPoint = hit.point;
            if (hit.point.x < transform.position.x)
            {
                FinalPoint.x += .1f;
            }
            else
            {
                FinalPoint.x -= .1f;
            }
            if (hit.point.y < transform.position.y)
            {
                FinalPoint.y += .1f;
            }
            else
            {
                FinalPoint.y -= .1f;
            }

            if (hit.collider != null)
            {
                SPS.playShoot();
                AS.ConsumeSecondaryAmmo();
                PrimaryBullet.SetActive(true);
                PrimaryBullet.transform.position = FinalPoint;
                PrimaryBullet.GetComponent <Rigidbody2D>().isKinematic = true;
                Color CtoChange = ES.GetColor(PCS.GetPlayerNum());
                CtoChange.r -= .1f;
                CtoChange.g -= .1f;
                CtoChange.b -= .1f;
                PrimaryBullet.GetComponentInChildren <SpriteRenderer>().color = CtoChange;
                CanShoot  = false;
                FirstShot = false;
                ShotTimer = 0;
            }
        }
        else if (CanShoot && AS.CheckCanShootSecondary())
        {
            RaycastHit2D hit        = Physics2D.Raycast(GunPoint, transform.up);
            Vector3      FinalPoint = hit.point;
            if (hit.point.x < transform.position.x)
            {
                FinalPoint.x += .1f;
            }
            else
            {
                FinalPoint.x -= .1f;
            }
            if (hit.point.y < transform.position.y)
            {
                FinalPoint.y += .1f;
            }
            else
            {
                FinalPoint.y -= .1f;
            }
            if (hit.collider != null)
            {
                SPS.playShoot();
                AS.ConsumeSecondaryAmmo();
                SecondaryBullet.SetActive(true);
                SecondaryBullet.transform.position = FinalPoint;
                SecondaryBullet.GetComponent <Rigidbody2D>().isKinematic = true;
                Color CtoChange = ES.GetColor(PCS.GetPlayerNum());
                WPS.ActivateWall(CtoChange);
                CtoChange.r -= .1f;
                CtoChange.g -= .1f;
                CtoChange.b -= .1f;
                SecondaryBullet.GetComponentInChildren <SpriteRenderer>().color = CtoChange;
            }
        }
    }