Example #1
0
    public void Shoot(Vector3 GunPoint, Quaternion PointerRotation)
    {
        if (CanShoot && AS.CheckCanShootSecondary())
        {
            SPS.playGrenadeToss();
            AS.ConsumeSecondaryAmmo();
            GameObject TmpBullet = OPProjectile.FetchObject();             //= Instantiate (projectile, GunPoint, PointerRotation) as GameObject;
            TmpBullet.transform.rotation = PointerRotation;
            TmpBullet.transform.position = transform.position;
            GameObject TmpTrail = OPTrail.FetchObject();             //Instantiate (Trail, GunPoint, PointerRotation) as GameObject;
            TmpTrail.SetActive(true);
            TmpTrail.GetComponent <TrailFollowScript>().SetThingToFollow(TmpBullet.transform);
            Material TColor = TmpTrail.GetComponent <TrailRenderer>().material;
            TColor.SetColor("_Color", ES.GetColor(PCS.GetPlayerNum()));
            TmpBullet.layer = 17 + PCS.GetPlayerNum();
            Color CtoChange = ES.GetColor(PCS.GetPlayerNum());
            CtoChange.r += .2f;
            CtoChange.g += .2f;
            CtoChange.b += .2f;

            TmpBullet.GetComponent <ProjectileScript>().SetSelfDestruct(CookTime);
            TmpBullet.SetActive(true);

            TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum());
            TmpBullet.GetComponentInChildren <SpriteRenderer>().color = CtoChange;
            TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum());
            TmpBullet.GetComponentInChildren <ExplosionScript>().SetOwner(PCS.GetPlayerNum());


            CanShoot  = false;
            ShotTimer = 0;
            CookTime  = 0;
        }
    }
Example #2
0
    public void Shoot(Vector3 GunPoint, Quaternion PointerRotation)
    {
        if (CanShoot && AS.CheckCanShootSecondary())
        {
            int          Layer = 1 << 9;
            RaycastHit2D hit   = Physics2D.Raycast(transform.position, transform.up, Mathf.Infinity, Layer);
            if (hit.collider != null && (hit.collider.tag == "Wall" || hit.collider.tag == "MovingWall") && hit.distance < .5f)
            {
                SPS.playGrenadeToss();
                AS.ConsumeSecondaryAmmo();
                GameObject TmpBullet = OPProjectile.FetchObject();
                TmpBullet.transform.position = hit.point;
                Debug.Log(hit.normal);
                Debug.Log(Mathf.Atan2(hit.normal.x, hit.normal.y) * Mathf.Rad2Deg);
                TmpBullet.transform.rotation = Quaternion.identity;
                TmpBullet.transform.rotation = Quaternion.FromToRotation(TmpBullet.transform.up, hit.normal);

                TmpBullet.SetActive(true);
                TmpBullet.layer = 17 + PCS.GetPlayerNum();
                TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum());
                Color CtoChange = ES.GetColor(PCS.GetPlayerNum());
                TmpBullet.GetComponentInChildren <SpriteRenderer>().color = CtoChange;
                TmpBullet.GetComponent <TripMineLineScript>().SetColors(CtoChange);
                TmpBullet.GetComponentInChildren <ExplosionScript>().SetOwner(PCS.GetPlayerNum());
                CanShoot  = false;
                ShotTimer = 0;

                TmpBullet.transform.parent = hit.collider.transform;
            }
        }
    }
Example #3
0
 public void Shoot(Vector3 GunPoint, Quaternion PointerRotation)
 {
     if (CanShoot && AS.CheckCanShootSecondary())
     {
         SPS.playInterceptor();
         AS.ConsumeSecondaryAmmo();
         GameObject TMP = OP.FetchObject();
         TMP.transform.position = transform.position;
         TMP.transform.rotation = transform.rotation;
         TMP.SetActive(true);
         CanShoot  = false;
         ShotTimer = 0;
     }
 }
Example #4
0
 public void Shoot(Vector3 GunPoint, Quaternion PointerRotation)
 {
     if (CanShoot && AS.CheckCanShootSecondary())
     {
         SPS.playGrenadeToss();
         AS.ConsumeSecondaryAmmo();
         GameObject TmpBullet = OPProjectile.FetchObject();             //= Instantiate (projectile, GunPoint, PointerRotation) as GameObject;
         TmpBullet.transform.rotation = PointerRotation;
         TmpBullet.transform.position = new Vector3(transform.position.x, transform.position.y, -5);
         TmpBullet.SetActive(true);
         CanShoot  = false;
         ShotTimer = 0;
     }
 }
Example #5
0
 public void Shoot(Vector3 GunPoint, Quaternion PointerRotation)
 {
     if (CanShoot && AS.CheckCanShootSecondary())
     {
         SPS.playGrenadeToss();
         POutline.SetActive(false);
         GameObject TMP = OPWall.FetchObject();
         TMP.transform.position = GunPoint;
         TMP.transform.rotation = PointerRotation;
         TMP.GetComponent <SpriteRenderer>().color = ES.GetColor(PCS.GetPlayerNum());
         TMP.SetActive(true);
         AS.ConsumeSecondaryAmmo();
     }
 }
Example #6
0
    public void Shoot(Vector3 GunPoint, Quaternion PointerRotation)
    {
        if (CanShoot && AS.CheckCanShootSecondary())
        {
            AS.ConsumeSecondaryAmmo();
            CanShoot  = false;
            ShotTimer = 0;

            PointerRotation = PointerRotation * Quaternion.Euler(0, 0, -30);
            for (int i = 0; i < 20; i++)
            {
                Instantiate(projectile, GunPoint, PointerRotation);
                PointerRotation = PointerRotation * Quaternion.Euler(0, 0, 3);
            }
        }
    }
Example #7
0
 public void ShootOutline(Vector3 GunPoint, Quaternion PointerRotation)
 {
     if (!POutline.activeSelf && CanShoot && AS.CheckCanShootSecondary())
     {
         POutline.SetActive(true);
         PCS.SetCanShootPrim(false);
         AS.ConsumeSecondaryAmmo();
         Invoke("turnOff", 2f);
         SPS.PlayShieldUp();
         CanShoot = false;
     }
     if (POutline.activeSelf)
     {
         POutline.transform.position = GunPoint;
         POutline.transform.rotation = PointerRotation;
     }
 }
    public void Shoot(Vector3 GunPoint, Quaternion PointerRotation)
    {
        if (CanShoot && AS.CheckCanShootSecondary())
        {
            SPS.playGrenadeToss();
            AS.ConsumeSecondaryAmmo();
            GameObject tmp = Instantiate(projectile, GunPoint, PointerRotation) as GameObject;

            Material TColor = tmp.GetComponentInChildren <TrailRenderer>().material;
            TColor.SetColor("_Color", ES.GetColor(PCS.GetPlayerNum()));
            tmp.layer = 17 + PCS.GetPlayerNum();
            tmp.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum());
            Color CtoChange = ES.GetColor(PCS.GetPlayerNum());
            CtoChange.r += .2f;
            CtoChange.g += .2f;
            CtoChange.b += .2f;
            tmp.GetComponentInChildren <SpriteRenderer>().color = CtoChange;
            CanShoot  = false;
            ShotTimer = 0;
        }
    }
Example #9
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;
            }
        }
    }