void OnCollisionEnter(Collision otherCollision) { if (otherCollision.gameObject.tag == "Ship") { SpaceShipController SSC = otherCollision.gameObject.GetComponent <SpaceShipController>(); if (!SSC.Immortal) { GameManager.instance.lives--; SSC.StartCoroutine(SSC.ShieldShip(0.2f)); SSC.player.SetActive(true); switch (sizeType) { case asteroidType.Large: GameManager.instance.score += 20; break; case asteroidType.Medium: GameManager.instance.score += 50; break; case asteroidType.Small: GameManager.instance.score += 100; break; } gameObject.SetActive(false); GameManager.instance.GameOver(); if (explosion != null) { Instantiate(explosion, transform.position, transform.rotation); } SoundManager.instance.PlayClip(EAudioClip.DESTROY_SFX, 1); } } }
public GameState() { name = ""; IncreaseBossTimer = false; BossTimer = 0; Bossfight = false; SpecialGun = 0; UpOrDown = 1; LeftOrRight = 1; Shoot = false; Health = 5; Score = 0; Invincible = 0; Ammo = 100; Meteors = 0; alive = true; spaceship = new SpaceShipController(this); boxes = new PowerUpController(this); enemies = new EnemyController(this); meteor = new MeteorController(this); stars = new StarController(this); bullet = new BulletController(this); bossfight = new BossFightController(this); }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("projectile")) { int sourceId = other.GetComponent <ProjectileBehaviour>().SourceId; ScoreManager.Instance.addPoints(sourceId, GameConstants.POINTS_FOR_ASTEROID); GameManager.Instance.DestroyAsteroid(this.gameObject, sourceId); Destroy(other.gameObject); } else { //some refactoring would be in place.. if (other.CompareTag("spaceship")) { SpaceShipController spaceShip = other.GetComponent <SpaceShipController> (); PlayerController playerController = spaceShip.Player; if (playerController.IsEnlargened) { int sourceId = playerController.Id; ScoreManager.Instance.addPoints(sourceId, GameConstants.POINTS_FOR_ASTEROID); GameManager.Instance.DestroyAsteroid(this.gameObject); } else { GetComponent <Rigidbody> ().angularVelocity = Random.insideUnitSphere * _spinMagnitude; } } else { //give it a little spin GetComponent <Rigidbody> ().angularVelocity = Random.insideUnitSphere * _spinMagnitude; } } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("projectile")) { _hp--; int sourceId = other.GetComponent <ProjectileBehaviour>().SourceId; if (_hp <= 0) { ScoreManager.Instance.addPoints(sourceId, GameConstants.POINTS_FOR_CHILICORN); BonusSpawnerBehaviour bonusSpawner = GetComponent <BonusSpawnerBehaviour> (); if (bonusSpawner) { bonusSpawner.spawnBonusOnDestroy(this.gameObject.transform.position); } GameManager.Instance.DestroyWithExplosion(this.gameObject, sourceId); } GameManager.Instance.DestroyWithExplosion(other.gameObject, sourceId); } else if (other.CompareTag("spaceship")) { SpaceShipController spaceShip = other.GetComponent <SpaceShipController> (); PlayerController playerController = spaceShip.Player; GameManager.Instance.DestroyWithExplosion(playerController.gameObject, playerController.Id); } else if (other.CompareTag("asteroid")) { GameManager.Instance.DestroyAsteroid(other.gameObject); } }
void OnTriggerEnter(Collider otherCollider) { if (otherCollider.gameObject.tag == "Bullet" || otherCollider.gameObject.tag == "Ship" || otherCollider.gameObject.tag == "Asteroid") { Destroy(gameObject); GameManager.instance.score += 200; GameManager.instance.EnemyDeath(); SoundManager.instance.PlayClip(EAudioClip.ENEMYDESTROY_SFX, 1); if (otherCollider.gameObject.tag == "Ship") { SpaceShipController SSC = otherCollider.gameObject.GetComponent <SpaceShipController>(); if (!SSC.Immortal) { GameManager.instance.lives--; SSC.StartCoroutine(SSC.ShieldShip(0.2f)); GameManager.instance.GameOver(); SSC.player.SetActive(true); } if (otherCollider.gameObject.tag == "Bullet") { Destroy(otherCollider.gameObject); } } } }
private void OnControllerChange(InputDevice device, InputDeviceChange change) { Debug.Log(Gamepad.current.name); switch (change) { case InputDeviceChange.Added: // New Device. foreach (Ship s in instancePlayers) { SpaceShipController c = s.GetComponent <SpaceShipController>(); if (!c.Controller.Assigned) { c.Controller.AssignController(device); } } break; case InputDeviceChange.Disconnected: // Device got unplugged. break; case InputDeviceChange.Reconnected: // Plugged back in. break; case InputDeviceChange.Removed: // Remove from Input System entirely; by default, Devices stay in the system once discovered. break; default: // See InputDeviceChange reference for other event types. break; } }
private void Start() { spaceShipController = FindObjectOfType <SpaceShipController>(); container = FindObjectOfType <Container>(); rb = GetComponent <Rigidbody>(); moveFoward = spaceShipController.transform.forward; Destroy(gameObject, 6); }
// Update is called once per frame void Update() { SpaceShipController controller = player.GetComponent <SpaceShipController>(); if (controller) { UItext.text = "Ammo :: " + controller.ammo + "\n" + "Special :: " + controller.missile_catridge; } }
private void Awake() { spaceShipController = FindObjectOfType <SpaceShipController>(); particleSystems = spaceShipController.GetComponentsInChildren <ParticleSystem>(); meshRenderers = spaceShipController.GetComponentsInChildren <MeshRenderer>(); asteroids = FindObjectsOfType <Asteroid>(); canvasGroup = GetComponent <CanvasGroup>(); container = FindObjectOfType <Container>(); }
// Use this for initialization void Start() { TimeOfStart = Time.time; scoreKeeper = (ScoreKeeper)GameObject.Find("GameController").GetComponent(typeof(ScoreKeeper)); groundSpawner = (GroundSpawnScript)GameObject.Find("GroundSpawner").GetComponent(typeof(GroundSpawnScript)); enemySpawner = (EnemySpawnerScript)GameObject.Find("EnemySpawner").GetComponent(typeof(EnemySpawnerScript)); enemySpawner.enabled = false; shipController = (SpaceShipController)GameObject.Find("SpaceShip").GetComponent(typeof(SpaceShipController)); maxObstacleSpawnDuration = ObstacleSpawnDuration; }
private void Start() { renderer1 = this.GetComponent <Renderer>(); health = GetComponent <Health>(); SetEularRotation(); SetScale(); CalculateHealth(); spaceShipController = FindObjectOfType <SpaceShipController>(); renderer1.material.color = new Color(1, 1, 1, 0); }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("projectile")) { GameManager.Instance.DestroyWithExplosion(other.gameObject, other.gameObject.GetComponent <ProjectileBehaviour> ().SourceId); } else if (other.CompareTag("spaceship")) { SpaceShipController spaceShip = other.GetComponent <SpaceShipController> (); PlayerController playerController = spaceShip.Player; GameManager.Instance.DestroyWithExplosion(playerController.gameObject, playerController.Id); } }
private void Awake() { if (!MainCharacter) { MainCharacter = this; } Controller = GetComponent <SpaceShipController>(); m_rb = GetComponent <Rigidbody>(); InitializeStatus(); EquipmentObjects.Add(new EquipmentObject(defaultLaser.Hash)); resources = 0; }
public void timeoutElapsed(Timeoutable t) { //TODO refactor tags out, use method accesesor for this feature if (t.CompareTag("spaceship")) { //Invoked by the Controllers after a timeout SpaceShipController spaceShip = t.GetComponent <SpaceShipController> (); DestroyWithExplosion(spaceShip.Player.gameObject, false, false); } else { Destroy(t.gameObject); } }
public void Init(int id, GameConstants.PlayerKeys keys, PlayerInformation playerInformation) { this.Id = id; SetPlayerKeys(keys); this.PlayerInformation = playerInformation; GameObject go = Instantiate(playerInformation.PlayerShipPrefab, _shipContainer, false) as GameObject; _playerShip = go.GetComponent <SpaceShipController> (); _playerShip.Init(this); _playerShip.OnTriggerEnterAsObservable().Subscribe(collider => { OnPlayerShipTriggerEnter(collider); }); }
private void OnPlayerShipTriggerEnter(Collider other) { if (other.CompareTag("projectile")) { ProjectileBehaviour projectile = other.gameObject.GetComponent <ProjectileBehaviour>(); // If the projectile was from another player - destroy our ship if (projectile.SourceId != Id) { int sourceId = projectile.SourceId; ScoreManager.Instance.addPoints(sourceId, GameConstants.POINTS_FOR_KILL); Destroy(other.gameObject); GameManager.Instance.DestroyWithExplosion(this.gameObject, Id); } } else if (other.CompareTag("spaceship")) { SpaceShipController otherSpaceShip = other.gameObject.GetComponent <SpaceShipController> (); PlayerController otherPlayer = otherSpaceShip.Player; bool thisEnlargend = IsEnlargened; bool thatEnlargend = otherPlayer.IsEnlargened; bool both = thisEnlargend && thatEnlargend; bool neither = !thisEnlargend && !thatEnlargend; if (both || neither) { GameManager.Instance.DestroyWithExplosion(this.gameObject); GameManager.Instance.DestroyWithExplosion(otherPlayer.gameObject, true, false); } else if (thisEnlargend) { GameManager.Instance.DestroyWithExplosion(otherPlayer.gameObject, true, true); ScoreManager.Instance.addPoints(Id, GameConstants.POINTS_FOR_KILL); } else if (thatEnlargend) { GameManager.Instance.DestroyWithExplosion(this.gameObject); ScoreManager.Instance.addPoints(otherPlayer.Id, GameConstants.POINTS_FOR_KILL); } else { Debug.LogError("BUG IN PLAYERCONTROLLER"); Debug.Assert(true); } } }
// Update is called once per frame void Update() { SpaceShipController controller = player.GetComponent <SpaceShipController>(); if (controller) { if (!controller.isAlive) { UItext.text = "Wasted"; } } if (!boss) { UItext.text = "GameClear"; } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("spaceship")) { //This code could also be in PlayerController.. refactor if needed SpaceShipController spaceShip = other.GetComponent <SpaceShipController> (); PlayerController playerController = spaceShip.Player; playerController.AddCollectable(_collectable); Destroy(this.gameObject); PlaySoundFX(); } else if (other.CompareTag("planet")) { //destroy just so that it doesn't stay within the planet looking stupid. //spawning these should however check that this doesn't happen, but leave this just in case Destroy(this.gameObject); } }
// Use this for initialization void Awake() { instance = this; speaker = GetComponent <AudioSource>(); smooth = turnSpeed / 3; }
private void Start() { spaceShipController = FindObjectOfType <SpaceShipController>(); container = FindObjectOfType <Container>(); positionTimer = changePositionTimer; }
void Start() { spaceShipController = FindObjectOfType <SpaceShipController>(); container = FindObjectOfType <Container>(); }
static void Main() { var grid = new SpaceGrid(); // Input stars for (int star = 0; star < 3; star++) { string[] starData = Console.ReadLine().Split(' '); grid.Stars.Add(new Star(starData[0], decimal.Parse(starData[1]), decimal.Parse(starData[2]))); } // Input spaceship decimal[] spaceShipData = Console.ReadLine().Split(' ').Select(decimal.Parse).ToArray(); var spaceShip = new SpaceShip(spaceShipData[0], spaceShipData[1]); // Input moves int moves = int.Parse(Console.ReadLine()); var shipController = new SpaceShipController(grid, spaceShip); // Move ship for (int move = 0; move < moves; move++) { shipController.MoveShip(); } }
private void Start() { spaceShipController = FindObjectOfType <SpaceShipController>(); fireCounter = Random.Range(minFireWaitTime, maxFireWaitTime); }
void Start() { spaceShip = GameObject.FindObjectOfType <SpaceShipController>(); camera = GetComponent <Camera>(); UpdateClipPlanes(); }