// Use this for initialization void Start() { if (identity == null) { identity = GetComponent <UnitIdentity>(); } if (engine == null) { engine = GetComponent <ShipEngine>(); } if (weaponHolder == null) { weaponHolder = GetComponent <ShipboardWeaponHolder>(); } if (health == null) { health = GetComponent <Health>(); } if (sheild == null) { sheild = GetComponent <Sheild>(); } if (master != null) { master.Register(this); } }
// Inizializzo le armi public void Init(EnginesSysyemData data) { // Inizializzo la lista _engines = new List <ShipEngine> (); // Cicla sulle armi recuperate dallo scriptable object // e successivamente recupera gli effetti particellari tramite i tag assegnati foreach (EngineData ed in data.engines) { ShipEngine se = new ShipEngine(); se.data = ed; Transform[] allChildren = gameObject.GetComponentsInChildren <Transform>(); foreach (Transform t in allChildren) { if (t.gameObject.tag == se.data.tag) { ParticleSystem ps = t.GetComponentInChildren <ParticleSystem> (); if (ps != null) { se.particleSystems.Add(ps); } } } _engines.Add(se); } }
public void AssignNewTarget(EncounterAgent target) { this.target = target; targetPilot = target.GetComponent <ShipPiloting>(); targetEngines = target.GetComponent <ShipEngine>(); Start(); }
void Start() { // Get the components for the Motor and Data data = GetComponent<ShipData>(); engine = GetComponent<ShipEngine>(); shooter = GetComponent<ShipShooter>(); }
// Use this for initialization void Start() { if (shipEngine == null) { shipEngine = GetComponent <ShipEngine>(); } }
public void AddEngine(Vector2 hardPoint, ShipAddOnData addOnData) { ShipEngine engine = new ShipEngine(hardPoint, AssetManager.GetKeyFromData(addOnData), this, true); ShipAddOns.AddObject(engine); DealWithHardPoint(hardPoint, true); }
protected void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { ShipEngine engine = collision.gameObject.GetComponent <ShipEngine>(); refillRoutine = StartCoroutine(ReloadFuel(engine)); reloadingParticles.Play(); } }
private void OnCollisionEnter2D(Collision2D other) { ShipEngine engine = other.gameObject.GetComponent <ShipEngine>(); if (engine) { engine.Kill(); } OriginFactory.Reclaim(this); }
private void OnCollisionEnter2D(Collision2D other) { ShipEngine engine = other.gameObject.GetComponent <ShipEngine>(); if (engine) { engine.Kill(); } Instantiate(smallExplosion, transform.position, Quaternion.identity); OriginFactory.Reclaim(this); }
private void OnCollisionEnter2D(Collision2D collision) { ShipEngine engine = collision.gameObject.GetComponent <ShipEngine>(); if (engine) { engine.Kill(); DoExplosion(collision); } OriginFactory.Reclaim(this); }
public void SetTarget(Unit target) { if (target == null) { Clear(); return; } this.target = target.engine; this.weaponHolder = target.weaponHolder; this.visualizeWeaponIndex = 0; }
private void UpdateSpeed(ShipEngine engine) { var dt = Time.fixedDeltaTime; var dv = dt * engine.Acceleration; var dvAuH = UnitHelper.KmsToAuh(dv); engine.CurrentSpeed += dvAuH; if (engine.CurrentSpeed > engine.MaxSpeed) { engine.CurrentSpeed = engine.MaxSpeed; } }
private IEnumerator ReloadFuel(ShipEngine _engine) { if (_engine.CurrentFuel < _engine.GetMaxFuel) { _engine.RechargeFuel(rechargeValue); Debug.Log("Reloading " + rechargeValue); yield return(new WaitForSeconds(rechargeCooldown)); refillRoutine = StartCoroutine(ReloadFuel(_engine)); } }
void OnTriggerEnter2D(Collider2D _collider) { if (!_collider.CompareTag("Player")) { ShipEngine engine = _collider.GetComponent <ShipEngine>(); if (engine != null) { engine.TakeDamage(damage); } } Release(); }
// Use this for initialization void Start() { engine = ship.GetComponent <ShipEngine> (); health = ship.GetComponent <HealthManager> (); //if the boss is added to the script make sure to update related parts of the script bossFight = (boss != null); if (bossFight) { sBoss = boss.GetComponent <BossScript> (); bossHealth = boss.GetComponent <HealthManager> (); } //if the asteroid is added to the script make sure to update related parts of the script asteroidFight = (asteroidManager != null); }
private void Awake() { components = GetComponents <ShipComponent>(); if (hitBoxComponent == null) { hitBoxComponent = GetComponent <BoxCollider2D>(); } if (spriteComponent == null) { spriteComponent = GetComponent <SpriteRenderer>(); if (spriteComponent == null) { spriteComponent = GetComponentInChildren <SpriteRenderer>(); } } if (bodyComponent == null) { bodyComponent = GetComponent <Rigidbody2D>(); } if (engineComponent == null) { engineComponent = GetComponent <ShipEngine>(); } if (radarComponent == null) { radarComponent = GetComponent <Radar>(); } if (oscilatorComponent == null) { oscilatorComponent = GetComponent <SignalOscilator>(); } if (atractorRayComponent == null) { atractorRayComponent = GetComponent <AtractorRay>(); } if (shieldComponent == null) { shieldComponent = GetComponent <Shield>(); } }
// Aggiorna tutti i sistemi particellari di un determinato gruppo private void UpdateParticleSystems(ShipEngine shipEngine, float move) { // Per ogni effetto particellare nel sistema di motori... foreach (ParticleSystem ps in shipEngine.particleSystems) { // ...recupero il modulo principale delle particelle... ParticleSystem.MainModule mainModule = ps.main; // ...calcolo il numero di particelle prodotte... float lifetime = shipEngine.data.maxLifetime * move; // ... applicando il valore minimo, se necessario lifetime = lifetime > shipEngine.data.minLifetime ? lifetime : shipEngine.data.minLifetime; // Infine, impongo la nuova lifetime alle particelle mainModule.startLifetime = lifetime; } }
public void Clear() { target = null; weaponHolder = null; for (int i = 0; i < movementBeaconParent.childCount; i++) { movementBeaconParent.GetChild(i).gameObject.SetActive(false); } if (fireBeacon != null) { fireBeacon.SetActive(false); } if (ceaseBeacon != null) { ceaseBeacon.SetActive(false); } }
private void DoExplosion(Collision2D firstHit) { SoundManager.Instance.PlayExplosion(); var hits = Physics2D.OverlapCircleAll(transform.position, explosionRadius); Instantiate(bombExplosion, transform.position, Quaternion.identity); foreach (var hit in hits) { if (hit == firstHit.collider) { continue; } ShipEngine engine = hit.gameObject.GetComponent <ShipEngine>(); if (engine) { engine.Kill(); } } }
void Update() { if (!target || !target.gameObject.activeInHierarchy) { var hit = Physics2D.OverlapCircle(transform.position, 2.0f, enemyMask); if (hit) { target = hit.gameObject.GetComponent <ShipEngine>(); } } else { Vector3 vectorToTarget = target.transform.position - transform.position; float angle = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg - 90.0f; Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward); transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * rotationSpeed); ResetVelocity(); } }
public void Initialize(ShipEngine target) { this.target = target; Initialize(); }
public void RechargeFuel() { ShipEngine engine = FindObjectOfType <ShipEngine>(); engine.RechargeFuel(999f); }
void CreatePlayer() { player = enemyFactory.Get(ShipType.Player); player.transform.position = new Vector3(0, -4, 0); }
void InitiateBossStage() { boss = Instantiate(bossPrefab, new Vector3(bossPrefab.transform.position.x, bossPrefab.transform.position.y + shipSpawnOffset, 0.0f), bossPrefab.transform.rotation); currentStage++; }
// Use this for initialization void Start() { min = Camera.main.ScreenToWorldPoint(Vector3.zero); max = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0)); engine = this.GetComponent <ShipEngine> (); }
private void Awake() { shipEngine = GetComponent <ShipEngine>(); shipRotation = GetComponent <ShipRotation>(); }
public AfterburnAbility(string dataAsset, ShipEngine shipEngine) : base(dataAsset, shipEngine) { ShipEngine = shipEngine; }
private void Start() { engine = GetComponent <ShipEngine>(); maxHealth = engine.GetHealth(); }
private void Awake() { playerInput = GetComponent <ShipInput>(); shotSequence = GetComponent <ShotSequence>(); engine = GetComponent <ShipEngine>(); }