public void Shoot(Vector3 GunPoint, Quaternion PointerRotation) { if (CanShoot && AS.CheckCanShootPrimary()) { SPS.playShoot(); AS.ConsumePrimaryAmmo(); GameObject TmpBullet = OPProjectile.FetchObject(); //= Instantiate (projectile, GunPoint, PointerRotation) as GameObject; TmpBullet.transform.position = GunPoint; TmpBullet.transform.rotation = PointerRotation; TmpBullet.transform.Rotate(new Vector3(0, 0, Random.Range(-5, 6))); TmpBullet.SetActive(true); 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(); TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum()); TmpBullet.GetComponentInChildren <HitScript>().SetBulletNumber(BulletNumber); BulletNumber++; Color CtoChange = ES.GetColor(PCS.GetPlayerNum()); CtoChange.r += .2f; CtoChange.g += .2f; CtoChange.b += .2f; TmpBullet.GetComponentInChildren <SpriteRenderer>().color = CtoChange; CanShoot = false; ShotTimer = 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; } } }
public void Shoot(Vector3 GunPoint, Quaternion PointerRotation) { if (CanShoot && AS.CheckCanShootPrimary()) { SPS.PlayBoomerang(); AS.ConsumePrimaryAmmoNoReload(); GameObject TmpBullet = OPProjectile.FetchObject(); //= Instantiate (projectile, GunPoint, PointerRotation) as GameObject; TmpBullet.transform.rotation = PointerRotation; TmpBullet.transform.position = GunPoint; TmpBullet.SetActive(true); TmpBullet.GetComponent <ProjectileScript>().setPlayerReturn(transform); Component[] TrailArray; TrailArray = TmpBullet.GetComponentsInChildren <TrailRenderer> (); foreach (TrailRenderer Current in TrailArray) { Material TColor = Current.material; TColor.SetColor("_Color", ES.GetColor(PCS.GetPlayerNum())); } TmpBullet.layer = 17 + PCS.GetPlayerNum(); TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum()); TmpBullet.GetComponentInChildren <HitScript>().SetBulletNumber(BulletNumber); BulletNumber++; Color CtoChange = ES.GetColor(PCS.GetPlayerNum()); CtoChange.r += .2f; CtoChange.g += .2f; CtoChange.b += .2f; TmpBullet.GetComponentInChildren <SpriteRenderer>().color = CtoChange; CanShoot = false; ShotTimer = 0; } }
public void Shoot(Vector3 GunPoint, Quaternion PointerRotation) { if (CanShoot && AS.CheckCanShootPrimary()) { SPS.PlayBoomerang(); AS.ConsumePrimaryAmmo(false); GameObject TmpBullet = OPProjectile.FetchObject(); TmpBullet.transform.position = GunPoint; TmpBullet.transform.rotation = PointerRotation; TmpBullet.SetActive(true); Material TColor = TmpBullet.GetComponentInChildren <TrailRenderer>().material; TmpBullet.layer = 17 + PCS.GetPlayerNum(); TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum()); TmpBullet.GetComponentInChildren <HitScript>().SetBulletNumber(BulletNumber); BulletNumber++; Color CtoChange = ES.GetColor(PCS.GetPlayerNum()); Component[] sprites = TmpBullet.GetComponentsInChildren <SpriteRenderer>(); foreach (SpriteRenderer s in sprites) { s.color = CtoChange; CtoChange.r += .2f; CtoChange.g += .2f; CtoChange.b += .2f; } TColor.SetColor("_Color", CtoChange); CanShoot = false; ShotTimer = 0; } }
void FireBullet(Vector3 GunPoint, Quaternion PointerRotation) { GameObject TmpBullet = OPProjectile.FetchObject(); //= Instantiate (projectile, GunPoint, PointerRotation) as GameObject; TmpBullet.transform.rotation = PointerRotation; TmpBullet.transform.position = GunPoint; TmpBullet.SetActive(true); 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(); TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum()); TmpBullet.GetComponentInChildren <HitScript>().SetBulletNumber(BulletNumber); Color CtoChange = ES.GetColor(PCS.GetPlayerNum()); CtoChange.r += .2f; CtoChange.g += .2f; CtoChange.b += .2f; TmpBullet.GetComponentInChildren <SpriteRenderer>().color = CtoChange; }
public void Shoot(Vector3 GunPoint, Quaternion PointerRotation) { if (CanShoot && AS.CheckCanShootPrimary()) { Color CtoChange = ES.GetColor(PCS.GetPlayerNum()); CtoChange.r += .025f; CtoChange.g += .025f; CtoChange.b += .025f; AS.ConsumePrimaryAmmo(); GameObject TmpBullet = OPProjectile.FetchObject(); TmpBullet.GetComponent <LazerProjectileScript>().ShootLine(chargeLevel, CtoChange, transform.position, transform.up, PCS.GetPlayerNum(), BulletNumber); //if (chargeLevel > 2){ // diff = new Vector2( hit2.point.x - hit.point.x, hit2.point.y - hit.point.y); // hit3 = Physics2D.Raycast (hit2.point, Vector3.Reflect(diff.normalized, hit2.normal), Mathf.Infinity, Layer); // TmpBullet.GetComponent<LazerProjectileScript>().ShootLine(chargeLevel, CtoChange, transform.position, hit.point, hit2.point, hit3.point); // }else{ // TmpBullet.GetComponent<LazerProjectileScript>().ShootLine(chargeLevel, CtoChange, transform.position, hit.point, hit2.point); // } //TmpBullet.SetActive(true); //TmpBullet.layer = 17 + PCS.GetPlayerNum(); //TmpBullet.GetComponent<HitScript>().BulletDamage = chargeLevel; //TmpBullet.GetComponent<HitScript>().SetBulletNumber(BulletNumber); BulletNumber++; //TmpBullet.GetComponent<HitScript>().SetOwner(PCS.GetPlayerNum()); TmpBullet.GetComponentInChildren <LineRenderer>().SetColors(CtoChange, CtoChange); SPS.PlayLazerShoot(); CanShoot = false; ShotTimer = 0; chargeLevel = 1; chargeAmount = 0; particlesSystem.startColor = ES.GetColor(PCS.GetPlayerNum()); particlesOBJ.transform.localScale = new Vector2(1f, 1f); particlesSystem.emissionRate = 25f; particlesOBJ.SetActive(false); firstPress = true; } }
public void ConsumePrimaryAmmo(bool flash = true) { PrimaryCurrentAmmo--; ShellTrans.position = transform.position; ShellTrans.rotation = transform.rotation; if (flash) { PSShell.Emit(1); PSFlash.Emit(15); } Stats.IncrementShots(PCS.GetPlayerNum()); if (PrimaryCurrentAmmo <= 0) { SpriteColor.color = Color.gray; SPS.playReload(); Invoke("Reload", Delay); } }
// checks health numbers for death void HealthCheck(int PlayerNum) { if (health <= 0) { DeathTrans.position = transform.position; DeathPaticles.Emit(25); SPS.playDeath(); Stats.IncrementDeaths(PCS.GetPlayerNum()); CCS.CancelDeathAnimations(); if (PlayerNum != PCS.GetPlayerNum()) { if (RHS.UpdateScore(PlayerNum)) { CCS.PlayDeathAnimations(transform.position, ES.GetColor(PlayerNum), true); } else { CCS.PlayDeathAnimations(transform.position, ES.GetColor(PlayerNum)); } } else { RHS.UpdateScore(PlayerNum, true); Stats.IncrementSuicides(PlayerNum); CCS.PlayDeathAnimations(transform.position, ES.GetColor(PlayerNum)); } Component[] DeathParticlesArray; CorpseObject.transform.position = transform.position; DeathParticlesArray = CorpseObject.GetComponentsInChildren <DeathAnimationScript> (); foreach (DeathAnimationScript Current in DeathParticlesArray) { Current.PlayDeathAnim(PlayerColor); } Component[] arrows = GetComponentsInChildren <WallStickScript>(); foreach (WallStickScript ws in arrows) { ws.transform.parent = null; } Destroy(gameObject); } }
// Use this for initialization void Start() { SPS = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> (); PCS = GetComponent <PlayerControlScript> (); ES = GameObject.Find("EternalHolder").GetComponent <EternalScript> (); SpriteColor = GetComponent <SpriteRenderer> (); CurrentColor = ES.GetColor(PCS.GetPlayerNum()); SpriteColor.color = CurrentColor; Stats = GameObject.Find("TotalStatsHolder").GetComponent <EndGameStatsScript>(); }
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; } }
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; } }
public void Shoot(Vector3 GunPoint, Quaternion PointerRotation) { if (CanShoot && AS.CheckCanShootPrimary()) { SPS.playShoot(); AS.ConsumePrimaryAmmo(); GameObject TmpBullet = Instantiate(projectile, GunPoint, PointerRotation) as GameObject; GameObject TmpTrail = Instantiate(Trail, GunPoint, PointerRotation) as GameObject; TmpTrail.GetComponent <TrailFollowScript>().SetThingToFollow(TmpBullet.transform); Material TColor = TmpTrail.GetComponent <TrailRenderer>().material; TColor.SetColor("_Color", ES.GetColor(PCS.GetPlayerNum())); TmpBullet.layer = 17 + PCS.GetPlayerNum(); TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum()); Color CtoChange = ES.GetColor(PCS.GetPlayerNum()); CtoChange.r += .2f; CtoChange.g += .2f; CtoChange.b += .2f; TmpBullet.GetComponentInChildren <SpriteRenderer>().color = CtoChange; CanShoot = false; ShotTimer = 0; } }
void releaseCharge() { if (CanShoot && AS.CheckCanShootPrimary()) { // change to sword sound SPS.playShoot(); AS.ConsumePrimaryAmmo(); GameObject TmpBullet = Instantiate(projectile, GunPointPerm, RotationPerm) as GameObject; TmpBullet.transform.parent = transform; Material TColor = TmpBullet.GetComponentInChildren <TrailRenderer>().material; TColor.SetColor("_Color", ES.GetColor(PCS.GetPlayerNum())); TmpBullet.layer = 17 + PCS.GetPlayerNum(); TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum()); Color CtoChange = ES.GetColor(PCS.GetPlayerNum()); CtoChange.r += .2f; CtoChange.g += .2f; CtoChange.b += .2f; TmpBullet.GetComponentInChildren <SpriteRenderer>().color = CtoChange; CanShoot = false; ShotTimer = 0; ChargeAmount = 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(); } }
public void Shoot(Vector3 GunPoint, Quaternion PointerRotation) { if (CanShoot && numOfMines > 2) { for (int x = 0; x < numOfMines; x++) { mines[x].GetComponent <SachelExplosionScript>().Detonate(); } numOfMines = 0; } else if (CanShoot && AS.CheckCanShootPrimary()) { SPS.playGrenadeToss(); AS.ConsumePrimaryAmmo(); GameObject TmpBullet = OPProjectile.FetchObject(); //= Instantiate (projectile, GunPoint, PointerRotation) as GameObject; TmpBullet.transform.rotation = PointerRotation; TmpBullet.transform.position = GunPoint; TmpBullet.SetActive(true); TmpBullet.layer = 17 + PCS.GetPlayerNum(); TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum()); Color CtoChange = ES.GetColor(PCS.GetPlayerNum()); CtoChange.r += .2f; CtoChange.g += .2f; CtoChange.b += .2f; TmpBullet.GetComponentInChildren <SpriteRenderer>().color = CtoChange; TmpBullet.GetComponentInChildren <HitScript>().SetOwner(PCS.GetPlayerNum()); TmpBullet.GetComponentInChildren <SachelExplosionScript>().SetOwner(PCS.GetPlayerNum()); TmpBullet.GetComponentInChildren <SachelExplosionScript>().SetBulletNumber(BulletNumber); BulletNumber++; CanShoot = false; mines[numOfMines] = TmpBullet; numOfMines++; ShotTimer = 0; } }
// Use this for initialization void Start() { ES = GameObject.Find("EternalHolder").GetComponent <EternalScript> (); SPS = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> (); PCS = GetComponent <PlayerControlScript> (); AS = GetComponent <AmmoScript>(); AS.SetSecondaryMagazineSize(2); PCS.SetSecondaryWeapon(ShootOutline); PCS.SetSecondaryWeaponRelease(Shoot); CanShoot = true; projectile = Resources.Load("ShieldPrefab") as GameObject; POutline = Instantiate(projectile, Vector3.zero, Quaternion.identity) as GameObject; Color CtoChange = ES.GetColor(PCS.GetPlayerNum()); CtoChange.a = .75f; POutline.GetComponent <SpriteRenderer> ().color = CtoChange; POutline.SetActive(false); }
// Use this for initialization void Start() { ES = GameObject.Find("EternalHolder").GetComponent <EternalScript> (); PCS = GetComponent <PlayerControlScript> (); SPS = GameObject.Find("SoundObject").GetComponent <SoundPlayerScript> (); OPProjectile = GameObject.Find("ObjectPoolerLazer").GetComponent <ObjectPoolScript> (); particlesOBJ = Resources.Load("ChargeParticleHolder") as GameObject; AS = GetComponent <AmmoScript>(); AS.SetPrimaryMagazineSize(6); AS.SetReloadTime(3f); PCS.SetPrimaryWeapon(Charge); PCS.SetPrimaryWeaponRelease(Shoot); ShotTimer = 0; chargeLevel = 1; ShootFireCooldown = 7; CanShoot = true; particlesOBJ = Instantiate(particlesOBJ, transform.position, transform.rotation) as GameObject; particlesSystem = particlesOBJ.GetComponentInChildren <ParticleSystem> (); particlesSystem.startColor = ES.GetColor(PCS.GetPlayerNum()); particlesOBJ.SetActive(false); }
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; } } }