void Start() { //print(SceneManager.GetActiveScene().buildIndex + 1); score = 0; AlienBullet.SetActive(true); healthBar = GameObject.FindObjectOfType <HealthBar>(); }
public void OnHit(GameObject source, Vector3 point) { if (source.tag == "shield") { if (grid.isAnimatingUp && source.transform.root != transform.root) { grid.Return(this); } return; } AlienBullet projectile = source.GetComponent <AlienBullet>(); if (projectile) { if (caughtObject.Contains(source)) { return; } projectile.attachedShield = this; caughtObject.Add(source); projectile.Stop(point); if (caughtObject.Count > capacity) { DestroyShield(); grid.RemoveShield(this); } return; } }
void OnTriggerEnter(Collider other) { AlienBullet bullet = other.gameObject.GetComponent <AlienBullet>(); if (bullet && bullet.GetOriginGo() != this.gameObject && bullet.GetSource() != this.gameObject) { Debug.Log("Bullet incoming from other alien"); //Add check to see if connection already exists. SceneUtils.FindObject <AlienTargetManager>().OnAlienTargetHit(this); RopeContainer ropeContainer = GameObject.Instantiate(ropeContainerPrefab, GetCenterTransform().position, Quaternion.identity); ropeContainer.transform.parent = this.transform; ropeContainer.AddEventListener(this.gameObject); Transform originTransform = bullet.GetOriginGo().transform; if (bullet.GetOriginGo().GetComponent <AlienTarget>()) { originTransform = bullet.GetOriginGo().GetComponent <AlienTarget>() .GetCenterTransform(); } ropeContainer.PrepareRope(originTransform, GetCenterTransform()); bullet.BeforeDestroy(); Destroy(bullet.gameObject); PlayInfectionSound(); OnControlled(); } }
public void publicDeactivates() { rocket.SetActive(false); UI.SetActive(false); Bounder.SetActive(false); AlienCar.SetActive(false); AlienBullet.SetActive(false); AlienCar2.SetActive(false); }
void ShootAtPlayer() { Vector2 direction = (player.transform.position - transform.position).normalized; GameObject alienBullet = Instantiate(bullet, transform.position, transform.rotation); AlienBullet tempBullet = alienBullet.GetComponent <AlienBullet>(); tempBullet.speed *= 1.5f; tempBullet.direction = direction; }
void OnTriggerEnter(Collider other) { AlienBullet alienBullet = other.gameObject.GetComponent <AlienBullet>(); if (alienBullet) { alienBullet.gameObject.SetActive(false); Invoke("LoadNextLevelDelayed", 1f); } }
private void OnTriggerEnter(Collider other) { AlienBullet alienBullet = other.gameObject.GetComponent <AlienBullet>(); if (alienBullet) { Destroy(alienBullet.gameObject); SceneUtils.FindObject <AlienGameManager>().ResetGame(); } }
IEnumerator AlienShooting(Transform playerTransform) { while (true && (alien.curState == Alien.State.PATROLLING) && playerTransform != null) { Vector2 direction = (playerTransform.position - transform.position).normalized; GameObject alienBullet = Instantiate(bullet, transform.position, transform.rotation); AlienBullet tempBullet = alienBullet.GetComponent <AlienBullet>(); tempBullet.direction = direction; float waitSeconds = 1.5f; yield return(new WaitForSeconds(waitSeconds)); } }
public override void Fire(float rotation) { Globals.audioManager.PlayGameSound("alien_range"); float r = (float)Globals.random.NextDouble() * accuracy; AlienBullet b = Globals.gameInstance.alienProjectileManager.alienProjectilePool.Provide(); b.Construct(emmitterPosition, rotation /*+ r - halfAccuracy*/); base.Fire(rotation); }
void WinGame() { if (score > 1) { PlayerPrefs.SetInt("levelReached", SceneManager.GetActiveScene().buildIndex); GameWin.SetActive(true); publicDeactivates(); gameWin = true; AlienCar.SetActive(false); AlienBullet.SetActive(false); AlienCar2.SetActive(false); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "bullet") { TakeDamage(); } AlienBullet b = other.transform.GetComponent <AlienBullet>(); if (b != null) { b.Death(); } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "bullet") { TakeDamage(); } AlienBullet b = collision.transform.GetComponent <AlienBullet>(); if (b != null) { b.Death(); } }
// Update is called once per frame void Update() { if (isControlled && alienTargetManager.CanDoInputs()) { var normalizedPosition = leftStickControl.GetNormalizedPosition(); var animationName = DecideAnimationName(normalizedPosition.x * -1f, normalizedPosition.y * -1f); var aimDirection = leftStickControl.GetAimDirection(false); var currentPosition = leftStickControl.GetCurrentPosition(); var shootAnimationName = DecideAnimationName(aimDirection.x, aimDirection.z); Debug.Log("anim " + shootAnimationName); if (animationName.Length > 1 && animationManager != null) { animationManager.PlayAnimationByName(animationName); } directinIndicator.ChangeDirection(currentPosition, shootPosition.position, aimDirection); if (canDoAction) { if (alienInputActions.shoot.IsPressed && aimDirection.magnitude > .3f) { leftStickControl.ResetPositions(); canDoAction = false; Debug.Log("aim direction " + aimDirection); Debug.Log("Aimed in direction " + aimDirection); Debug.Log("Will use animation " + shootAnimationName); if (flingSound != null) { flingSound.Play(true); } if (shootAnimationName != null && animationManager) { animationManager.PlayAnimationByName(shootAnimationName); animationManager.DisableSwitchAnimations(); } AlienBullet bullet = GameObject.Instantiate(bulletPrefab, shootPosition.position, Quaternion.identity); bullet.SetSource(this.gameObject); bullet.SetOriginGo(shootPosition.gameObject); bullet.Shoot(aimDirection); OnLostControl(); Invoke("ResetShooting", .3f); } } } }
AlienBullet fire() { Vector3 spawnPos = gameObject.transform.position; spawnPos.y += 1.5f; // * Mathf.Sin(rotation * Mathf.PI/180); GameObject newBullet = Instantiate(Resources.Load("Prefabs/AlienBulletPrefab"), spawnPos, Quaternion.identity) as GameObject; AlienBullet bulletComponent = newBullet.GetComponent <AlienBullet>(); bulletComponent.ship = gameObject.GetComponent <Alien>(); AudioClip fireSound = (AudioClip)Resources.Load("Audio/shoot"); AudioSource.PlayClipAtPoint(fireSound, gameObject.transform.position); return(bulletComponent); }
public void DestroyShield() { foreach (GameObject obj in caughtObject) { AlienBullet a = obj.GetComponent <AlienBullet>(); if (a != null) { a.Death(); } else { Destroy(obj); } } Destroy(this.gameObject); }
public bool CollidedWith(AlienBullet abullet) { return(PlayerBitmap.RectangleCollision(X, Y, abullet.CollisionRec)); // Circle circle1= SplashKit.CircleAt(X-20, Y-20, 50); // return SplashKit.CirclesIntersect(circle1, abullet.CollisionCircle); }
public bool CollidedWith(AlienBullet target) { return(SplashKit.RectanglesIntersect(CollisionRec, target.CollisionRec)); }