private void OnGUI() { GUILayout.Label("Balance Manager", EditorStyles.boldLabel); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Hover over the text of any item to get a brief description. Make sure to reset connections after debugging.", MessageType.Info); GUILayout.Label("Engine Scipt edits", EditorStyles.boldLabel); engine.engineCoolingAmount = EditorGUILayout.Slider(new GUIContent("Cooling Speed", "This is the speed at which the engine will cool down."), engine.engineCoolingAmount, 0.1f, 10); engine.florpCoolingPercentage = EditorGUILayout.Slider(new GUIContent("Florp Power", "Percentage of engine that is cooled when florp is inserted."), engine.florpCoolingPercentage, 0.1f, 1); engine.progressionMultiplier = EditorGUILayout.Slider(new GUIContent("Progression Multiplier", "How fast the ship progression bar will move."), engine.progressionMultiplier, 0.1f, 2); engine.enemyProgressionMultiplier = EditorGUILayout.Slider(new GUIContent("Enemy Progression Multiplier", "How fast the enemy ship progression bar will move."), engine.enemyProgressionMultiplier, 0.1f, 2); GUILayout.Label("Ship Health Scipt edits", EditorStyles.boldLabel); shipHealth.timeBetweenNEvents = EditorGUILayout.Slider(new GUIContent("Time Between Events", "Time between the blasts. Or the time between the events that will cause damage to the ship."), shipHealth.timeBetweenNEvents, 0.1f, 15); shipHealth.timeBeforeEventsStart = EditorGUILayout.Slider(new GUIContent("Time Before Event Starts", "Time between the blasts. Or the time between the events that will cause damage to the ship."), shipHealth.timeBeforeEventsStart, 0.1f, 15); GUILayout.Label("Fire Scipt edits", EditorStyles.boldLabel); grid.fireStartPercentage = EditorGUILayout.Slider(new GUIContent("Fire Start Percentage", "Time between the blasts. Or the time between the events that will cause damage to the ship."), grid.fireStartPercentage, 1, 100); grid.fireTimer = EditorGUILayout.Slider(new GUIContent("Fire Spread timer", "Time between the blasts. Or the time between the events that will cause damage to the ship."), grid.fireTimer, 0.1f, 15); GUILayout.Space(25); if (GUILayout.Button("RESET CONNECTIONS")) { engine = FindObjectOfType <Engine>(); shipHealth = FindObjectOfType <ShipHealth>(); grid = FindObjectOfType <Grid>(); } }
public void WinGame() { rfs.StopDamageTimer(); ShipHealth h = GetComponent <ShipHealth>(); //Figure out clout change based on damage taken relative to max health float percentDamage = h.Health / h.MaxHealth; int damageBracket = RandomizerForStorms.GetBracket(damageLevelPercents, percentDamage); int cloutGained = Mathf.CeilToInt((survivalGain.y - survivalGain.x) * percentDamage + survivalGain.x); string cloutText = damageLevelText[damageBracket] + "\n\n" + $"For making your way out of the storm with your ship intact, your clout has risen {Mathf.RoundToInt(cloutGained)}." + $" Combined with the {cloutChange} from the ritual, your clout has changed a total of {Mathf.RoundToInt(cloutGained + cloutChange)}."; Globals.GameVars.AdjustPlayerClout(cloutGained + cloutChange, false); mgInfo.gameObject.SetActive(true); mgInfo.DisplayText( Globals.GameVars.stormTitles[3], Globals.GameVars.stormSubtitles[3], Globals.GameVars.stormSuccessText[0] + "\n\n" + cloutText + "\n\n" + Globals.GameVars.stormSuccessText[Random.Range(1, Globals.GameVars.stormSuccessText.Count)], stormIcon, MiniGameInfoScreen.MiniGame.Finish); finishButton.GetComponentInChildren <TMPro.TextMeshProUGUI>().text = winFinishText; finishButton.onClick.RemoveAllListeners(); finishButton.onClick.AddListener(UnloadMinigame); GetComponent <StormMGmovement>().ToggleMovement(false); }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Player") { if (isBoss) { ShipHealth playerHp = collision.GetComponent <ShipHealth>(); if (!playerHp.getInvincibleStatus()) { collision.GetComponent <PlayerDamageable>().TakeDamage(damage); spawnParticle(); Destroy(gameObject); } } else { collision.GetComponent <PlayerDamageable>().TakeDamage(damage); spawnParticle(); Destroy(gameObject); } } }
void OnCollisionEnter(Collision col) { if (col.gameObject.tag.Equals("Player")) { // Find the ShipHealth script associated with the rigidbody. ShipHealth targetHealth = target.GetComponent <ShipHealth> (); // Calculate the amount of damage the target should take based on it's distance from the shell. // Move the instantiated explosion prefab to the Ship's position and turn it on. m_ExplosionParticles.transform.position = transform.position; m_ExplosionParticles.gameObject.SetActive(true); // Play the particle system of the Ship exploding. m_ExplosionParticles.Play(); // Play the Ship explosion sound effect. m_ExplosionAudio.Play(); // Deal this damage to the Ship. targetHealth.TakeDamage(damage); // Destroy(gameObject); gameObject.SetActive(false); } }
// Start is called before the first frame update void Start() { //shielding = false; hpController = GetComponentInChildren <ShipHealth>(); shieldDelayTimer = setShieldDelay; }
private void Start() { h = GetComponent <ShipHealth>(); damagePerSecond = h.MaxHealth / (timeLimit * 60); sunLight = Globals.GameVars.skybox_sun; }
void Start() { if (player == null) { player = GameObject.Find("Player"); } playerHealth = player.GetComponent <ShipHealth>(); }
void Start() { player = GameObject.Find("Player"); rigid = this.GetComponent <Rigidbody>(); shipHealth = FindObjectOfType <ShipHealth>(); audioSource = GetComponent <AudioSource>(); audioSource.PlayOneShot(flightNoise, flightVolume); thisCollider = gameObject.GetComponent <CapsuleCollider>(); }
public void ShipTakeDamage(int damage, int expected) { // Use the Assert class to test conditions ShipHealth ship = new ShipHealth(10); ship.TakeDamage(damage); Assert.That(ship.GetHealth(), Is.EqualTo(expected)); }
private void Update() { if (m_target != null) { if (m_target.m_isDead || !m_target.gameObject.activeInHierarchy) { m_target = null; } } }
private void Start() { planet = FindObjectOfType <ShipHealth>(); if (planet != null) { planet.gameOver += Explode; } shipMat.DOColor(shipBaseColor, "_EmissionColor", 0); }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
// Use this for initialization void Start() { player = GameObject.Find("Player"); shipHealth = FindObjectOfType <ShipHealth>(); firePoint = GameObject.CreatePrimitive(PrimitiveType.Sphere); myCollider = firePoint.GetComponent <SphereCollider>(); myCollider.isTrigger = true; myMesh = firePoint.GetComponent <MeshRenderer>(); myMesh.enabled = false; firePoint.transform.position = player.transform.position; }
protected new void Start() { base.Start(); shipHealth = GetComponent <ShipHealth>(); shipHealth.ReduceDamage = TakeDamage; if (CompareTag("Player")) { shieldBar = Array.Find(FindObjectsOfType <HealthBar>(), element => "Shield".Equals(element.barName)); } }
void Awake() { if (shipHealth == null) { shipHealth = this; DontDestroyOnLoad(GameObject.FindGameObjectWithTag("Player")); } else if (shipHealth != this) { Destroy(gameObject); } }
// SphereCast to checks every Object within it void Explode() { Collider[] colliders = Physics.OverlapSphere(transform.position, m_explosionRadius); for (int i = 0; i < colliders.Length; i++) { ShipHealth targetInRange = colliders[i].GetComponent <ShipHealth>(); if (targetInRange != null) { targetInRange.TakeDamage(m_damage); } } }
void Hit(RaycastHit hit) { if (hit.transform.tag == "Ship" || hit.transform.tag == "Player") { ShipHealth sh = hit.transform.gameObject.GetComponent <ShipHealth>(); sh.Hit(damage); } Instantiate(hitParticleSystem, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(gameObject); }
private void OnTriggerEnter(Collider other) { // Collect all the colliders in a sphere from the shell's current position to a radius of the explosion radius. Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, m_ShipMask); // Go through all the colliders... for (int i = 0; i < colliders.Length; i++) { // ... and find their rigidbody. Rigidbody targetRigidbody = colliders[i].GetComponent <Rigidbody> (); // If they don't have a rigidbody, go on to the next collider. if (!targetRigidbody) { continue; } // Add an explosion force. targetRigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius); // Find the ShipHealth script associated with the rigidbody. ShipHealth targetHealth = targetRigidbody.GetComponent <ShipHealth> (); // If there is no ShipHealth script attached to the gameobject, go on to the next collider. if (!targetHealth) { continue; } // Calculate the amount of damage the target should take based on it's distance from the shell. float damage = CalculateDamage(targetRigidbody.position); // Deal this damage to the Ship. targetHealth.TakeDamage(damage); } // Unparent the particles from the shell. m_ExplosionParticles.transform.parent = null; // Play the particle system. m_ExplosionParticles.Play(); // Play the explosion sound effect. m_ExplosionAudio.Play(); // Once the particles have finished, destroy the gameobject they are on. Destroy(m_ExplosionParticles.gameObject, m_ExplosionParticles.main.duration); // Destroy (Instantiate(m_ExplosionParticles), m_ExplosionParticles.main.duration); // Destroy the shell. Destroy(gameObject); }
public static ShipController GetShip(Game gameView, ShipModel shipModel) { IView shipView = gameView.CreateView(shipModel.Name); IShipMove shipMove = new ShipMove(shipView.Rigidbody2D, shipModel.MoveForce); IShipRotate shipRotate = new ShipRotate(shipView.Rigidbody2D, shipModel.Torque); IShipHealth shipHealth = new ShipHealth(shipModel.MaxHealth); IShipCollided shipCollided = new ShipCollided(shipView, shipHealth); IShipFire shipFire = new ShipFire(); FireLock fireLock = new FireLock(); IShipFire shipLockableFire = new ShipLockableFire(shipFire, fireLock); return(new ShipController(shipModel, shipView, shipMove, shipRotate, shipCollided, shipHealth, shipLockableFire, fireLock)); }
void AssignLastEnemyComponents() { lastEnemy = GameObject.Find(Names.Enemy); if (lastEnemy == null) { Debug.LogError("GameObject with Tag LastEnemy not found in LevelManager.cs!"); return; } lastEnemyShip = lastEnemy.GetComponentInChildren <ShipHealth>(); lastEnemyFire = lastEnemy.GetComponent <BaseFire>(); }
void Start() { player = GameObject.Find("Player"); shipHealth = FindObjectOfType <ShipHealth>(); //rigid = this.GetComponent<Rigidbody>(); //creating an invisible 'end point' where the player was last standing laserEnd = GameObject.CreatePrimitive(PrimitiveType.Sphere); endCollider = laserEnd.GetComponent <SphereCollider>(); endCollider.isTrigger = true; endMesh = laserEnd.GetComponent <MeshRenderer>(); endMesh.enabled = false; laserEnd.transform.position = player.transform.position; }
void AssignPlayerComponents() { GameObject player = GameObject.Find(Names.Player); if (player == null) { Debug.LogError("GameObject with Tag Player not found in LevelManager.cs!"); return; } playerShip = player.GetComponentInChildren <ShipHealth>(); playerMovement = player.GetComponent <IPlayerMovement>(); playerFire = player.GetComponent <PlayerFire>(); }
private void Start() { cm = CheckpointManager.instance; sc = StatCounter.instance; rb = GetComponent <Rigidbody2D>(); rb.centerOfMass = Vector2.zero; fuel = GetComponent <ShipFuel>(); health = GetComponent <ShipHealth>(); goText.enabled = false; paused = false; pausedText.gameObject.SetActive(paused); StartCoroutine(ShowText()); }
private void OnTriggerEnter2D(Collider2D other) { if (other.ToString().Contains("PlayerShip")) { ShipHealth targetHealth = other.GetComponent <ShipHealth>(); if (!targetHealth.GetShield()) { targetHealth.takeDamage(damage); laserAudio.Play(); } gameObject.transform.position = new Vector2(15, 20); Destroy(gameObject, 0.2f); } else if (other.ToString().Contains("ShieldLaser")) { Destroy(gameObject, 0.0f); } }
void OnCollisionEnter(Collision collision) { // Find ShipHealth component in the object's highest parent Transform obj = collision.gameObject.transform; while (obj.parent != null) { obj = obj.parent; } ShipHealth health = obj.GetComponent <ShipHealth>(); if (health?.gameObject == IgnoreCollisions) { return; } if (health != null) { health.Health--; Destroy(this.gameObject); ContactPoint contact = collision.contacts[0]; Vector3 vfxDirection = contact.normal; vfxDirection.y = Util.Cap(vfxDirection.y, 0.2f); vfxDirection.Normalize(); GameObject vfx = Instantiate(CollisionVFXPrefab, contact.point, Quaternion.identity); vfx.transform.rotation = Quaternion.LookRotation(vfxDirection, Vector3.up); ParticleSystem particles = vfx.GetComponentInChildren <ParticleSystem>(); var particleLifetime = particles.main.startLifetime; float vfxTime = particles.main.duration + particleLifetime.constant; Destroy(vfx, vfxTime); var velocityModule = particles.velocityOverLifetime; velocityModule.x = health.Velocity.x * 10; velocityModule.y = health.Velocity.y * 10; velocityModule.z = health.Velocity.z * 10; } }
// Start is called before the first frame update void Start() { currentState = GameState.Setup; breakTimer = 0; levelPrompt = GameObject.Find("Level Prompt"); levelPromptText = levelPrompt.GetComponent <Text>(); levelPrompt.SetActive(false); damageUpPrompt = GameObject.Find("Damage Up Prompt"); damageUpPrompt.SetActive(false); tripleShotPrompt = GameObject.Find("Triple Shot Prompt"); tripleShotPrompt.SetActive(false); scoreUpPrompt = GameObject.Find("Score Up Prompt"); scoreUpPrompt.SetActive(false); healthUpPrompt = GameObject.Find("Health Up Prompt"); healthUpPrompt.SetActive(false); coroutineStarted = false; scoreMultiplier = 1; scoreMultiplierText.text = scoreMultiplier.ToString() + "x"; baseMultiplier = 1; playerHp = GameObject.Find("Ship").GetComponentInChildren <ShipHealth>(); dropped = false; bossDropSystem = GetComponent <BossDropSystem>(); transitionController = Camera.main.GetComponent <TransitionController>(); blockerSpawnerScripts = blockerSpawners.GetComponentsInChildren <MultiSpawner>(); }
void OnTriggerEnter(Collider other) { // Ignore if other is sibling if (other.tag == tag) { return; } // Enemy bullet if (other.tag.Contains(Tags.Bullet) && !other.tag.Contains(tag)) { TakeDamage(); other.transform.parent.gameObject.SetActive(false); } // Physical collision with ship ShipHealth otherHealth = other.transform.parent.GetComponentInChildren <ShipHealth>(); if (otherHealth != null) { otherHealth.TakeDamage(); } }
private void Start() { h = GetComponent <ShipHealth>(); damagePerSecond = h.MaxHealth / (timeLimit * 60); }
// Use this for initialization public MeterMessager(Power power, ShipHealth shipHealth, EnemyManager enemyManager) { m_Power = power; m_ShipHealth = shipHealth; m_EnemyManager = enemyManager; }
private void OnTriggerEnter(Collider other) { m_target = other.GetComponent <ShipHealth>(); }