void Explode() { Collider[] floaters = Physics.OverlapSphere(transform.position, explosionRange, 1 << 9, QueryTriggerInteraction.Collide); foreach (Collider c in floaters) { float dist = (c.transform.position - transform.position).magnitude; float dmg = Mathf.Clamp(dist / explosionRange, 0.0f, 1.0f); Ballast bal = c.GetComponent <Ballast>(); if (bal != null) { bal.CurrentHp -= damage * dmg; Debug.Log("Ballast: " + (damage * dmg)); } ShipBallaster shipBal = c.GetComponent <ShipBallaster>(); if (shipBal != null) { shipBal.CurrentHp -= damage * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp) * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp); Debug.Log("ShipBal damage: " + (damage * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp) * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp))); } } Explosives.SetActive(true); StartCoroutine(Destruction()); }
private void Blow() { if (typ) { model.SetActive(false); } Destroy(rigid); bHasCollided = true; Destroy(GetComponent <FollowShip>()); explosion.SetActive(true); Collider[] floaters = Physics.OverlapSphere(transform.position, explosionRange, 1 << 9, QueryTriggerInteraction.Collide); foreach (Collider c in floaters) { dg = true; float dist = (c.transform.position - transform.position).magnitude; float dmg = Mathf.Clamp(dist / explosionRange, 0.0f, 1.0f); Ballast bal = c.GetComponent <Ballast>(); if (bal != null) { bal.CurrentHp -= damage * dmg * dmg; Debug.Log("Ballast: " + (damage * dmg * dmg)); } ShipBallaster shipBal = c.GetComponent <ShipBallaster>(); if (shipBal != null) { shipBal.CurrentHp -= damage * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp) * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp); Debug.Log("ShipBal damage: " + (damage * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp) * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp))); } } StartCoroutine(Destruction()); }
public void OnTrigger(Swimming Swi, ShipBallaster Bal) { foreach (ChainShoot c in HookManager.Instance.chains) { if (c.bPicked) { Points += PointsPerTreasure; c.bPicked = false; c.DestroyChain(); HookManager.Instance.readiness[HookManager.Instance.chains.IndexOf(c)] = false; } } Points = Bal.Repair(Points / PointsPerHp) * PointsPerHp; if (Points < (Swi.maxPetrol - Swi.CurrentPetrol) * PointsPerFuel) { Swi.CurrentPetrol += Points / PointsPerFuel; Points = 0.0f; } else { Points -= (Swi.maxPetrol - Swi.CurrentPetrol) * PointsPerFuel; Swi.CurrentPetrol = Swi.maxPetrol; } }
// Use this for initialization void Start() { GameObject ship = GameObject.FindGameObjectWithTag("Ship"); playerCollider = ship.GetComponent <BoxCollider>(); ballaster = ship.GetComponent <ShipBallaster>(); }
void Awake() { rigid = GetComponent <Rigidbody>(); bal = GetComponent <ShipBallaster>(); currentPetrol = maxPetrol; }