void Awake() { // Check if null in prod... engines = GetComponent <Engines>(); playerAvatar = GetComponent <PlayerAvatar>(); bulletGun = GetComponent <BulletGun>(); }
private void Update() { if (this.engines != null) { float horizontalSpeedPercent = Input.GetAxis("Horizontal"); float verticalSpeedPercent = Input.GetAxis("Vertical"); this.engines.SetSpeed(new Vector2(horizontalSpeedPercent, verticalSpeedPercent)); } if (this.bulletGuns != null) { for (int index = 0; index < this.bulletGuns.Length; index++) { BulletGun bulletGun = this.bulletGuns[index]; if (Input.GetAxis("Fire") > 0f) { bulletGun.TryToFire(); } } } if (this.playerAvatar != null) { if (Input.GetAxis("SwitchWeapon") > 0f) { this.playerAvatar.SwitchToNextWeapon(); } } }
void Start() { avatar = GameManager.Instance.GetPlayer().GetComponent <PlayerAvatar>(); maxHealth = avatar.GetMaxHealth(); bulletGun = avatar.GetComponent <BulletGun>(); maxEnergy = bulletGun.GetMaxEnergy(); }
void OnTriggerEnter2D(Collider2D other) { //Au contact du personnage, on applique les effets du collectable PlayerAvatar target = other.GetComponent <PlayerAvatar> (); if (target) { GameManager gameManager = GameObject.FindObjectOfType <GameManager> (); if (gameManager) { if (gameManager.GameModeWithHealth) { target.TakeDamage(-healthRecovery); Destroy(gameObject); } if (!gameManager.GameModeWithHealth) { gameManager.BoostCombo(comboBoost); Destroy(gameObject); } } BulletGun bulletGun = other.GetComponent <BulletGun> (); if (bulletGun && unlockNextShoot) { bulletGun.TryUnlockNextShoot(); } if (bulletGun && energyRecovery) { bulletGun.RefillEnergy(); } } }
// Use this for initialization void Start() { enemyController = GetComponent <AIEnemyBasicEngine>(); enemyController.Position = transform.position; bulletGun = GetComponent <BulletGun>(); bulletGun.Speed = enemyController.Speed * 10; }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { _bulletGun = GetComponent <BulletGun>(); _bulletGun.Fire(); } float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); _engine.Speed = new Vector2(moveHorizontal, moveVertical); }
public void Fire(string type) { BulletGun bulletGun = FindBulletGun(type); if (bulletGun) { if (Time.time - lastFire >= rate) { lastFire = Time.time; bulletGun.Fire(); } } }
private void Update() { if (this.engines != null) { this.engines.SetSpeed(new Vector2(-1f, 0f)); } if (this.bulletGuns != null) { for (int index = 0; index < this.bulletGuns.Length; index++) { BulletGun bulletGun = this.bulletGuns[index]; // Fire all the time ! bulletGun.TryToFire(); } } }
public void SwitchToNextWeapon() { if (Time.time < this.lastWeaponSelectionChangeTime + this.weaponSwitchCooldown) { // Can't change the selected weapon now. It's in cooldown. return; } this.lastWeaponSelectionChangeTime = Time.time; this.selectedWeapon = (this.selectedWeapon + 1) % this.weaponsNames.Length; for (int index = 0; index < this.bulletGuns.Length; index++) { BulletGun bulletGun = this.bulletGuns[index]; if (bulletGun.WeaponName == this.weaponsNames[this.selectedWeapon]) { bulletGun.enabled = true; } else { bulletGun.enabled = false; } } }
private void Start() { _player = GameObject.FindGameObjectWithTag("Player"); _bulletGun = _player.GetComponent <BulletGun>(); _speed = _player.GetComponent <PlayerAvatar>().MaxSpeed; }
// Start is called before the first frame update void Start() { engines = GetComponent <Engines>(); bulletGun = GetComponent <BulletGun>(); }
// Use this for initialization void Start() { this.engine = this.GetComponent <Engines>(); this.gun = this.GetComponent <BulletGun>(); }
// Start is called before the first frame update void Start() { _engine = GetComponent <Engines>(); _bulletGun = GetComponent <BulletGun>(); }
void Awake() { engine = this.GetComponent <Engines>(); bulletGun = this.GetComponent <BulletGun>(); }
public void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerAvatar>(); gun = GameObject.FindGameObjectWithTag("Player").GetComponent <BulletGun>(); }