/*================ Health Bar ================*/ public GameObject CreateUnitHealthBar(float health, float maxHealth, Alignment alignment) { _healthBarPanel = GameObject.Find("HealthBarPanel"); GameObject healthBar = Instantiate(_healthBarPrefab, Vector3.zero, Quaternion.identity); healthBar.transform.SetParent(_healthBarPanel.transform); // Change the size of the health bar healthBar.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f); SimpleHealthBar hpBar = healthBar.transform.GetChild(0).GetComponent <SimpleHealthBar>(); if (alignment == Alignment.Friendly) { hpBar.UpdateColor(new Color(0.275f, 0.94f, 0.275f, 1f)); } else { hpBar.UpdateColor(new Color(0.94f, 0.275f, 0.275f, 1f)); } // Change health bar itself hpBar.UpdateBar(health, maxHealth); return(healthBar); }
void StoreReferences() { targ = ( SimpleHealthBar )target; ImageAssigned = new AnimBool(GetImageAssigned()); ImageUnassigned = new AnimBool(GetImageUnassigned()); ImageFilledWarning = new AnimBool(GetBarImageWarning()); barImage = serializedObject.FindProperty("barImage"); barImageBG = serializedObject.FindProperty("barImageBG"); // ----->>> COLOR // ImageColorWarning = new AnimBool(GetColorWarning()); colorMode = serializedObject.FindProperty("colorMode"); barColor = serializedObject.FindProperty("barColor"); barGradient = serializedObject.FindProperty("barGradient"); // ----->>> TEXT // DisplayTextOption = new AnimBool(targ.displayText != SimpleHealthBar.DisplayText.Disabled); textColor = targ.barText != null ? targ.barText.color : Color.white; barText = serializedObject.FindProperty("barText"); displayText = serializedObject.FindProperty("displayText"); additionalText = serializedObject.FindProperty("additionalText"); // ---- < SCRIPT REFERENCE > ---- // ExampleCode = new AnimBool(barName != string.Empty); GenerateExampleCode(); }
void StoreReferences() { // Assign the current target. targ = ( SimpleHealthBar )target; colorMode = serializedObject.FindProperty("colorMode"); statusImage = serializedObject.FindProperty("barImage"); statusColor = serializedObject.FindProperty("barColor"); statusGradient = serializedObject.FindProperty("barGradient"); displayText = serializedObject.FindProperty("displayText"); statusText = serializedObject.FindProperty("barText"); additionalText = serializedObject.FindProperty("additionalText"); fillConstraint = serializedObject.FindProperty("fillConstraint"); fillConstraintMin = serializedObject.FindProperty("fillConstraintMin"); fillConstraintMax = serializedObject.FindProperty("fillConstraintMax"); statusName = serializedObject.FindProperty("barName"); ImageWarning = new AnimBool(GetBarImageWarning()); DisplayTextOptions = new AnimBool(targ.displayText != SimpleHealthBar.DisplayText.Disabled); ImageColorWarning = new AnimBool(GetColorWarning()); DuplicateStatusName = new AnimBool(GetDuplicateBarName()); NameUnassigned = new AnimBool(targ.barName == string.Empty); FillConstraintOptions = new AnimBool(targ.fillConstraint); ExampleCode = new AnimBool(targ.barName != string.Empty && !GetDuplicateBarName()); exampleCode = "SimpleHealthBar.UpdateBar( \"" + targ.barName + "\", currentValue, maxValue );"; StatusImageAssigned = new AnimBool(GetImageAssigned()); StatusImageUnassigned = new AnimBool(GetImageUnassigned()); }
void Start() { ShipRes = GameObject.Find("Ship").GetComponent <ShipRes>(); fuelBar = GameObject.Find("FuelBar").transform.Find("Status Fill 01").GetComponent <SimpleHealthBar>(); foodBar = GameObject.Find("FoodBar").transform.Find("Status Fill 01").GetComponent <SimpleHealthBar>(); DrawLine = GameObject.Find("Grabber").GetComponent <DrawLine>(); }
void RegenShield() { if (shield != maxShield && shield == sameShield && health == sameHealth) { if (currShieldRegenTime <= 0) { shield = maxShield; AsShield.clip = regenShield; AsShield.Play(); currShieldRegenTime = shieldRegenTime; SimpleHealthBar.UpdateBar("PlayerShield", shield, maxShield); } else { currShieldRegenTime -= Time.deltaTime; } } else { currShieldRegenTime = shieldRegenTime; } sameShield = shield; sameHealth = health; }
private void Start() { player1 = GameObject.Find("Main Camera").GetComponent <PlayerLoad>().player1; player2 = GameObject.Find("Main Camera").GetComponent <PlayerLoad>().player2; m_Character = GetComponent <PlatformerCharacter2D>(); startPosition = transform.position; playerHealthBar = gameObject.GetComponent <PlatformerCharacter2D>().healthBarObject.GetComponent <SimpleHealthBar>(); staminaBar = gameObject.GetComponent <PlatformerCharacter2D>().staminaBarObject.GetComponent <SimpleHealthBar>(); stamina = gameObject.GetComponent <Stamina>(); audioArray = gameObject.GetComponents(typeof(AudioSource)); audioData = new AudioSource[audioArray.Length]; for (int i = 0; i < audioArray.Length; i++) { audioData[i] = (AudioSource)audioArray[i]; } heavyCooldown = gameObject.AddComponent <Cooldown>(); mediumCooldown = gameObject.AddComponent <Cooldown>(); lightCooldown = gameObject.AddComponent <Cooldown>(); lariatCooldown = gameObject.AddComponent <Cooldown>(); damageWait = gameObject.AddComponent <Cooldown>(); animEnd = gameObject.AddComponent <Cooldown>(); moveActive = gameObject.AddComponent <Cooldown>(); tripleJab = gameObject.AddComponent <SpamPrevention>(); tripleJab.init(3, 0.5f); wait = gameObject.AddComponent <Cooldown>(); }
bool isSinking; // Whether the enemy has started sinking through the floor. void Awake() { anim = GetComponent <Animator>(); currentHealth = maxHealth; healthBar = GetComponentInChildren <SimpleHealthBar>(); }
public void TakeDamage(float damage) { CameraShaker.Instance.Shake(CameraShakePresets.Flinch); if (shield > 0) { shield -= damage; As.clip = shieldDamageSound; As.Play(); if (shield <= 0) { health += shield; shield = 0; SimpleHealthBar.UpdateBar("PlayerHealth", health, maxHealth); AsShield.clip = shieldBreak; AsShield.Play(); } SimpleHealthBar.UpdateBar("PlayerShield", shield, maxShield); } else { As.clip = playerDamageSound; As.Play(); health -= damage; SimpleHealthBar.UpdateBar("PlayerHealth", health, maxHealth); } //if(health <= 0) //PlayerDies }
void Start() { Transform co2Bar = transform.Find("CO2Bar"); healthBar = co2Bar.Find("Simple Bar").Find("Status Fill 01") .gameObject.GetComponent <SimpleHealthBar>(); backgroundImage = co2Bar.Find("Background").gameObject; scoreText = co2Bar.Find("PPMCounter").gameObject; Transform warningBarT = transform.Find("WarningBar"); warningBar = warningBarT.gameObject; eventImage = warningBarT.Find("EventName").gameObject; Transform livesT = transform.Find("Lives"); livesText = livesT.Find("LivesText").gameObject; canvas = GetComponent <Canvas>(); instance = this; healthBar.UpdateColor(Color.red); healthBar.UpdateBar(ppm, eventPeriod); warningBar.SetActive(false); }
void Awake() { timer = timeBetweenAttacks; if (button == "Fire1") { coolDownBar = GameObject.FindGameObjectWithTag("LMB").GetComponentInChildren <SimpleHealthBar>(); } else if (button == "Fire2") { coolDownBar = GameObject.FindGameObjectWithTag("RMB").GetComponentInChildren <SimpleHealthBar>(); } if (ability) { manaCost = gameObject.GetComponent <AbilityStats>().manaCost; timeBetweenAttacks = gameObject.GetComponent <AbilityStats>().coolDown; } // Set up the references. // gunParticles = GetComponent <ParticleSystem> (); // gunAudio = GetComponent <AudioSource> (); // gunLight = GetComponent <Light> (); }
// Use this for initialization void Start() { gamespeed = 0.1f; //0.1s shieldPeriod = 10; StartCoroutine("PlayTimer"); //start timer for game asteroidShield = GameObject.Find("Circle"); cooldown = GameObject.Find("Cooldown"); inventory = GameObject.Find("Inventory").GetComponent <Inventory>(); craftingPanel = GameObject.Find("CraftingPanel"); craftingGUI = GameObject.Find("CraftingGUIPanel"); craftButton = GameObject.Find("Canvas").transform.Find("btnCraftPanelOn").gameObject; craftButton.SetActive(false); WarningSpaceOpen = GameObject.Find("Warning space open"); mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>(); menuCamera = GameObject.Find("Menu Camera").GetComponent <Camera>(); endCamera = GameObject.Find("End Game Camera").GetComponent <Camera>(); gameButton = GameObject.Find("Game button").GetComponent <Button>(); restartButton = GameObject.Find("Restart button").GetComponent <Button>(); restartButton.gameObject.SetActive(false); backtomenuButton = GameObject.Find("Menu Button").GetComponent <Button>(); quitButton = GameObject.Find("Quit button").GetComponent <Button>(); anim1 = WarningSpaceOpen.GetComponent <Animator>(); gameIsRunning = false; paused = true; comet = GameObject.Find("Comet_prototype"); healthBar = GameObject.Find("HB_Status Fill 00").GetComponent <SimpleHealthBar>(); fuelBar = GameObject.Find("HB_Status Fill 01").GetComponent <SimpleHealthBar>(); foodBar = GameObject.Find("FB_Status Fill 01").GetComponent <SimpleHealthBar>(); }
void Start() { spray.SetActive(false); anim = GetComponent <Animator>(); currentWater = maxWater; SimpleHealthBar.UpdateBar("Water", currentWater, maxWater); }
void Update() { if (Input.GetKey(KeyCode.W) && currentWater > 0) { anim.SetBool("Shooting", true); spray.SetActive(true); currentWater -= sprayRate; } if (Input.GetKeyUp(KeyCode.W) || currentWater <= 0) { anim.SetBool("Shooting", false); spray.SetActive(false); } if (currentWater <= 0) { currentWater = 0; } if (currentWater >= maxWater) { currentWater = maxWater; } SimpleHealthBar.UpdateBar("Water", currentWater, maxWater); // Extinguishing (); }
public void Start() { _truckHealthBar = transform.GetChild(0).GetChild(0).GetComponent <SimpleHealthBar>(); _truckHealthBar.UpdateColor(new Color(0.275f, 0.94f, 0.275f, 1f)); _truck = RTSUnitManager.Instance.truck; }
public void TakeDamage(float damage) { currentHealth -= damage; anim.Play("Hurt"); SimpleHealthBar.UpdateBar("Health", currentHealth, maxHealth); }
void Start() { currentHealth = maxHealth; animator = GetComponent <Animator>(); dashTime = startDashTime; transform.localPosition = new Vector3(transform.localPosition.x, 0.009f, transform.localPosition.z); healthBar = FindObjectOfType <SimpleHealthBar>(); }
public void Start() { wallLife = maxWallLife; cameraShaker = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraShaker>(); ripller = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <RipplePostProcessor>(); update = GameObject.FindGameObjectWithTag("Updater").GetComponent <Updater>(); bar = currentHelth.GetComponent <SimpleHealthBar>(); }
void Start() { sceneController = GameObject.Find("SceneManager").GetComponent <SceneController>(); fuelBar = GameObject.Find("FuelBar").transform.Find("Status Fill 01").GetComponent <SimpleHealthBar>(); movement = true; fuel = initialFuel; food = initialFood; }
// Start is called before the first frame update void Start() { fuelBar = GameObject.Find("FuelBar").transform.Find("Status Fill 01").GetComponent <SimpleHealthBar>(); shipRes = GameObject.Find("Ship").GetComponent <ShipRes>(); transform.Find("TrailRender").GetComponent <TrailRenderer>().enabled = false; Sc = GameObject.Find("SceneManager").GetComponent <SceneController>(); GetComponent <BoxCollider2D>().isTrigger = true; }
void Update() { // Run the CheckExitScreen function to see if the player has left the screen. CheckExitScreen(); // If the user cannot control the player, then return. if (canControl == false) { return; } // Store the input positions rotation = Input.GetAxis("Horizontal"); acceleration = Input.GetAxis("Vertical"); if (canShoot == true) { // If the shooting button is being used... if (Input.GetMouseButton(0)) { // If the gun is not overheated, then increase the timer. if (overheatTimer < overheatTimerMax) { overheatTimer += Time.deltaTime; } // Else the gun has overheated, so start the overheat coroutine. else { canShoot = false; StartCoroutine("DelayOverheat"); } if (shootingTimer <= 0) { // Then reset the timer and shoot a bullet. shootingTimer = shootingCooldown; CreateBullets(); } } else { if (overheatTimer > 0) { overheatTimer -= Time.deltaTime * cooldownSpeed; } } SimpleHealthBar.UpdateBar("Gun", overheatTimer, overheatTimerMax); } // If the shoot timer is above zero, reduce it. if (shootingTimer > 0) { shootingTimer -= Time.deltaTime; } Aiming(); }
void Start() { updater = GameObject.FindGameObjectWithTag("Updater").GetComponent <Updater>(); currentGunShotCount = GunShotsMax; center = GameObject.FindGameObjectWithTag("Center").transform; gunshots.color = gunShotColor.color; bar = gunshots.GetComponent <SimpleHealthBar>(); oldLevel = updater.level; }
void Update() { SimpleHealthBar.UpdateBar("Health", currentHealth, maxHealth); if (currentHealth <= 0) { currentHealth = 0; anim.Play("Death"); } }
//leveling methods public void GainExp(int e) { vCurrExp += e; if (vCurrExp >= vExpLeft) { LvlUp(); } SimpleHealthBar.UpdateBar("PlayerExperience", vCurrExp, vCurrExp + vExpLeft); }
// Use this for initialization void Start() { gamespeed = 0.1f; //0.1s //shieldPeriod = 10; StartCoroutine("PlayTimer"); //start timer for game asteroidShield = GameObject.Find("Circle"); cooldown = GameObject.Find("Cooldown"); inventory = GameObject.Find("Inventory").GetComponent <Inventory>(); craftingPanel = GameObject.Find("CraftingPanel"); craftingGUI = GameObject.Find("CraftingGUIPanel"); craftButton = GameObject.Find("Canvas").transform.Find("btnCraftPanelOn").gameObject; craftButton.SetActive(false); mission = GameObject.Find("Mission"); tutorial = GameObject.Find("Tutorial"); lesson1 = GameObject.Find("Lesson1Panel"); lesson2 = GameObject.Find("Lesson2Panel"); lesson2.SetActive(false); tutorialOn = true; WarningSpaceOpen = GameObject.Find("Warning space open"); mainCamera = GameObject.Find("Main Camera").GetComponent <Camera>(); menuCamera = GameObject.Find("Menu Camera").GetComponent <Camera>(); endCamera = GameObject.Find("End Game Camera").GetComponent <Camera>(); gameButton = GameObject.Find("Game button").GetComponent <Button>(); restartButton = GameObject.Find("Restart button").GetComponent <Button>(); restartButton.gameObject.SetActive(false); backtomenuButton = GameObject.Find("Menu Button").GetComponent <Button>(); quitButton = GameObject.Find("Quit button").GetComponent <Button>(); anim1 = WarningSpaceOpen.GetComponent <Animator>(); gameIsRunning = false; paused = true; engines = GameObject.Find("engines_player"); engines.SetActive(false); comet = GameObject.Find("Comet"); healthBar = GameObject.Find("HB_Status Fill 00").GetComponent <SimpleHealthBar>(); fuelBar = GameObject.Find("HB_Status Fill 01").GetComponent <SimpleHealthBar>(); foodBar = GameObject.Find("FB_Status Fill 01").GetComponent <SimpleHealthBar>(); warningAudioSource = GetComponents <AudioSource>()[1]; hitAudioSource = GetComponents <AudioSource>()[2]; shieldAudioSource = GetComponents <AudioSource>()[3]; warningHealthStart = Resources.Load <AudioClip>("Sounds/warnings/alarm health start"); warningHealthLoop = Resources.Load <AudioClip>("Sounds/warnings/alarm health loop"); warningLowFuel = Resources.Load <AudioClip>("Sounds/warnings/warning low fuel"); warningLowFood = Resources.Load <AudioClip>("Sounds/warnings/warning low food"); shieldLoop = Resources.Load <AudioClip>("Sounds/shield loop"); craftPanelOpen = Resources.Load <AudioClip>("Sounds/craft panel open"); craftPanelClose = Resources.Load <AudioClip>("Sounds/craft panel close"); death = Resources.Load <AudioClip>("Sounds/death"); hitSounds = Resources.LoadAll <AudioClip>("Sounds/hit sounds"); InitGame(true); }
public void TakeDamage(int damage) { // If the player can't take damage, then return. if (canTakeDamage == false) { return; } // If the shield value is greater than 0... if (currentShield > 0) { // Reduce the current shield value. currentShield -= damage; // If the shield is now less than 0... if (currentShield < 0) { // Reduce the health by how much damage went past the shield. currentHealth -= currentShield * -1; // Set the shield to zero. currentShield = 0; } } // Else there was no shield, so reduce health. else { currentHealth -= damage; } // If the health is less than zero... if (currentHealth <= 0) { // Set the current health to zero. currentHealth = 0; // Run the Death function since the player has died. Death(); } // Set canTakeDamage to false to make sure that the player cannot take damage for a brief moment. canTakeDamage = false; // Run the Invulnerablilty coroutine to delay incoming damage. StartCoroutine("Invulnerablilty"); // Shake the camera for a moment to make each hit more dramatic. StartCoroutine("ShakeCamera"); // Update the Health and Shield status bars. SimpleHealthBar.UpdateBar("Health", currentHealth, maxHealth); SimpleHealthBar.UpdateBar("Shield", currentShield, maxShield); // Reset the shield regen timer. regenShieldTimer = regenShieldTimerMax; }
void Awake() { isAlive = true; GameSettings.Buildings.Add(transform); GameController.Instance.UpdateBuildingNumber(); healthBar = transform.Find("Cube_Healthbar").Find("Canvas").Find("Simple Bar soldier").Find("Status Fill 01 soldier").gameObject.GetComponent <SimpleHealthBar>(); stats = GetComponent <CharacterStats>(); audioSource = GetComponent <AudioSource>(); stats.isBuilding = true; }
void Start() { // Set the current health and shield to max values. currentHealth = maxHealth; currentShield = maxShield; // Update the Simple Health Bar with the updated values of Health and Shield. SimpleHealthBar.UpdateBar("Health", currentHealth, maxHealth); SimpleHealthBar.UpdateBar("Shield", currentShield, maxShield); }
// Start is called before the first frame update void Start() { foodBar = GameObject.Find("FoodBar").transform.Find("Status Fill 01").GetComponent <SimpleHealthBar>(); Sc = GameObject.Find("SceneManager").GetComponent <SceneController>(); shipRes = GameObject.Find("Ship").GetComponent <ShipRes>(); isMove = true; incHealthEffect = GetComponent <ParticleSystem>(); Cp = GetComponent <CrewProps>(); WindowTrigger.GetComponent <ActivateBlock>().enableView = false; isAssign = true; }
private void LoadBiomaBars() { if (temperatureBar == null) { temperatureBar = GameObject.Find("TemperatureBar").GetComponent <SimpleHealthBar>(); } if (airHumidityBar == null) { airHumidityBar = GameObject.Find("AirHumidityBar").GetComponent <SimpleHealthBar>(); } }
// Use this for initialization void Start() { Global.PresentTime = 600; TimerOn = false; TimeEffect = GameObject.Find("TimeEffect"); TimeEffect.GetComponent <SpriteRenderer>().enabled = false; GaugeNow = 100; Global.TheWorld = 1; TimeGauge = GameObject.Find("TimeBar").GetComponent <SimpleHealthBar>(); StartCoroutine(Timer()); InvokeRepeating("UpdateGauge", 0, 0.01f); }