public void Damaged(GotHitParams hit) { // TODO include armor values // Debug.Log(hit.damage + " " + properties.Hull.Value + " " + properties.Shield.Value); properties.Shield.Value -= hit.shieldDamage; properties.Shield.Value = Mathf.Max(0, properties.Shield.Value); // Debug.Log("hull -- " + properties.Hull.Value + " " + hit.hullDamage); properties.Hull.Value -= hit.hullDamage; properties.Hull.Value = Mathf.Max(0, properties.Hull.Value); // Debug.Log("hull -- " + properties.Hull.Value); Debug.Log($"Hull: {properties.Hull.Value} Shield: {properties.Shield.Value}"); DamageEvent?.Invoke(); if (properties.Hull.Value == 0) { Death(); } }
public void GetAttacked() // TODO I hate this name { #if _DEBUG if (DebugPanel.Instance.alwaysHit || UnityEngine.Random.Range(0, 1) < cachedAccuracy) #else if (UnityEngine.Random.Range(0, 1) < cachedAccuracy) #endif { var assailant = TurnOrder.Instance.Current.gameObject; GotHitParams hit = new GotHitParams( (int)UnityEngine.Random.Range(cachedDamage.shieldRange.x, cachedDamage.shieldRange.y), (int)UnityEngine.Random.Range(cachedDamage.hullRange.x, cachedDamage.hullRange.y), assailant.transform.position - transform.position, assailant ); Damaged(hit); } else { Debug.Log("Miss"); } }