示例#1
0
 public void DamageByExplosion(TankEntity tank)
 {
     CurrentHP -= tank.ExplosionDamage;
     CurrentMatchReference.Value.TeamStats[Team].DamageSuffered += tank.ExplosionDamage;
     if (tank.Team == Team)
     {
         CurrentMatchReference.Value.TeamStats[Team].TeamDamage += tank.ExplosionDamage;
     }
     else
     {
         CurrentMatchReference.Value.TeamStats[tank.Team].DamageDone += tank.ExplosionDamage;
     }
     if (CurrentHP > 0)
     {
         return;
     }
     Die(tank);
 }
示例#2
0
        private void OnTriggerEnter(Collider other)
        {
            if (other.GetComponent <ShellEntity>())
            {
                return;
            }
            TankEntity tankEntity = other.GetComponent <TankEntity>();

            if (tankEntity == TankEntityOwner)
            {
                return;
            }
            if (tankEntity)
            {
                tankEntity.DamageByShot(this);
            }
            Instantiate(ExplosionPrefab, transform.position, Quaternion.Inverse(ExplosionPrefab.transform.rotation));
            Destroy(gameObject);
        }
示例#3
0
        private void Die(TankEntity killer)
        {
            if (killer.Team == Team)
            {
                CurrentMatchReference.Value.TeamStats[Team].TeamKill++;
            }
            else
            {
                CurrentMatchReference.Value.TeamStats[killer.Team].KillCount++;
            }
            CurrentMatchReference.Value.TeamStats[Team].LossCount++;
            CurrentMatchReference.Value.TeamStats[Team].TankLeft--;
            if (CurrentMatchReference.Value.TeamStats[Team].TankLeft == 0)
            {
                CurrentMatchReference.Value.TeamStats[Team].IsDefeated = true;
            }
            if (CurrentMatchReference.Value.TeamInMatch.Count() == 1)
            {
                OnMatchFinished.Raise();
            }
            // Explosion
            Instantiate(TankExplosionPrefab, transform.position, TankExplosionPrefab.transform.rotation);
            int size = Physics.OverlapSphereNonAlloc(transform.position, ExplosionRadius, _hitColliders);

            for (int i = 0; i < size; i++)
            {
                TankEntity tankEntity = _hitColliders[i].GetComponent <TankEntity>();
                if (tankEntity && tankEntity != this)
                {
                    tankEntity.DamageByExplosion(this);
                }
            }
            // Wreck
            if (PlayerPrefsUtils.GetBool(Properties.PlayerPrefs.ExplosionCreateBustedTank,
                                         Properties.PlayerPrefsDefault.ExplosionCreateBustedTank))
            {
                Instantiate(BustedTankPrefab, transform.position, transform.rotation);
            }
            // Remove from list
            TanksReference.Value.Remove(gameObject);
            // Destroy
            Destroy(gameObject);
        }
示例#4
0
 public FactionType GetFaction(TankEntity otherTank)
 {
     return(Team == otherTank.Team ? FactionType.Ally : FactionType.Enemy);
 }