Пример #1
0
 public void ApplyDamage(Damage damage)
 {
     if (shield.applyDamage(ref damage)) {
         if (hull.applyDamage(damage)) {
             //TODO: BOOM sound
             VFXPool.PlayVFX(tForm.position, VFXType.EXPLOSION);
             Destroy(gameObject, 0.25f);
         }
     }
 }
Пример #2
0
 public Weapon(Damage damage, float cooldown, int maxMissiles, float shotDelay)
 {
     this.damage = damage;
     this.cooldown = cooldown;
     this.ccd = 0.0f;
     this.maxMissiles = maxMissiles;
     this.cMissilies = this.maxMissiles;
     this.shotDelay = shotDelay;
     this.csd = 0.0f;
 }
Пример #3
0
 public bool applyDamage(Damage damage)
 {
     damage.value -= armor;
     if (damage.value > 0) {
         HP -= damage.value;
         if (HP <= 0) {
             HP = 0;
             return true;//Ship destroyed
         }
     }
     return false;//Still ok
 }
Пример #4
0
 public void Initialize(Damage damage, Vector3 pos, float speed, Vector2 dir, MissileSource source, MissileType type)
 {
     transform.position = pos;
     this.speed = speed;
     this.direction = dir;
     this.lifetime = 0.0f;
     this.source = source;
     this.type = type;
     this.damage = damage;
     gameObject.SetActive(true);
     spriteRenderer.enabled = true;
     collider.enabled = true;
     audioSource.PlayOneShot(shot_sound);
 }
Пример #5
0
 public bool applyDamage(ref Damage damage)
 {
     if(maxSP == 0)
         return true;//No shields
     if (damage.value > 0) {
         SP -= damage.value;
         if (SP < 0f) {
             damage.value += (int)SP;
             SP = 0f;
             isDestroyed = true;
             return true;//Shield passed through
         }
     }
     return false;//Shield ok
 }
Пример #6
0
 public void fireMissile(Damage damage, Vector3 pos, float speed, Vector2 direction, MissileSource source, MissileType type)
 {
     for (int i = 0; i < missiles.Count; ++i) {
         if (!goList[i].activeSelf) {
             goList[i].SetActive(true);
             missiles[i].Initialize(damage, pos, speed, direction, source, type);
             return;
         }
     }
     if (isExtendAllowed) { //extend the pool
         goList.Add(GameObject.Instantiate(prefabMissile) as GameObject);
         int idx = goList.Count - 1;
         missiles.Add(goList[idx].GetComponent<Missile>());
         goList[idx].transform.parent = goList[0].transform.parent ;
         goList[idx].SetActive(true);
         missiles[idx].Initialize(damage, pos, speed, direction, source, type);
     }
 }
Пример #7
0
 public static void FireMissile(Damage damage, Vector3 pos, float speed, Vector2 direction, MissileSource source, MissileType type)
 {
     int idx = -1;
     instance.poolMap.TryGetValue(type, out idx);
     instance.pools[idx].fireMissile(damage, pos, speed, direction, source, type);
 }