// Update is called once per frame void Update() { pHealthScript = FindObjectOfType <PlayerHealthScript>(); if (!pHealthScript.playerIsActive) { amSpeed = 0; } amTimer -= Time.deltaTime * amSpeed; int minutes; float seconds; minutes = Mathf.FloorToInt(amTimer / 60); seconds = amTimer % 60; if (amTimer <= 0) { amTimerText.text = "NEW ANTIMICROBIAL: AVAILABLE!"; } else { amTimerText.text = "NEW ANTIMICROBIAL: " + string.Format("{00}:{1:00.00}", minutes, seconds); useAntimicrobial = false; } if (Input.GetMouseButtonDown(1) && amTimer <= 0) { useAntimicrobial = true; Debug.Log("Use Antimicrobial"); amTimer = 10f * amTimerIncrement; amTimerIncrement = amTimerIncrement + 1; } }
void Awake() { VariableResourcesScript vrs = GetComponent<VariableResourcesScript>(); players = GameObject.FindGameObjectsWithTag("Player"); objPlayer1 = vrs.objPlayer1; scrPlayerScript1 = objPlayer1.GetComponent<PlayerScript>(); scrPlayerExperience1 = objPlayer1.GetComponent<PlayerStats>(); scrPlayerHealthScript1 = objPlayer1.GetComponent<PlayerHealthScript>(); scrPlayerShoot1 = objPlayer1.GetComponent<PlayerShoot>(); //objPlayer2 = vrs.objPlayer2; playersTag = objPlayer1.tag; // 8: Enemy, 15: Spawn Point, 20: Flying, 24: Neutral, 25: Immune intEnemyLayerMask = 1 << LayerMask.NameToLayer("Enemy") | 1 << LayerMask.NameToLayer("Flying") | 1 << LayerMask.NameToLayer("Neutral") | 1 << LayerMask.NameToLayer("Immune") | 1 << LayerMask.NameToLayer("Spawn Point"); intHostileLayerMask = 1 << LayerMask.NameToLayer("Enemy") | 1 << LayerMask.NameToLayer("Spawn Point") | 1 << LayerMask.NameToLayer("Immune"); intPlayerUnitsLayerMask = 1 << LayerMask.NameToLayer("Player"); objBullet = vrs.objBullet; objExplodingShot = vrs.objExplodingShot; objArrow = vrs.objArrow; objFire = vrs.objFire; objExplosion = vrs.objExplosion; objTemp = vrs.objTemp; objText = vrs.objText; texAttribute = vrs.texAttribute; matLineOfSightSolid = vrs.matLineOfSight; matLineOfSightTransparent = vrs.matLineOfSightTransparent; matSkull = vrs.matSkull; }
/** * Awake- Used by Unity for initialization * Finds all component children that this player has and caches them */ void Awake() { movementScript = transform.FindChild("MovementController").GetComponent <PlayerMovementScript> (); if (movementScript == null) { Debug.LogError("Could not load Player Movement Script"); } inputScript = transform.FindChild("InputController").GetComponent <PlayerInputScript> (); if (inputScript == null) { Debug.LogError("Could not load Player Input Script"); } networkScript = transform.FindChild("NetworkController").GetComponent <NetworkControllerScript> (); if (inputScript == null) { Debug.LogError("Could not load Network Controller Script"); } visionScript = transform.FindChild("VisionController").GetComponent <VisionControllerScript> (); if (visionScript == null) { Debug.LogError("Could not load Vision Controller Script"); } environmentScript = transform.FindChild("EnvironmentController").GetComponent <PlayerEnvironmentController> (); if (environmentScript == null) { Debug.LogError("Could not load Player Environment Controller Script"); } healthScript = transform.FindChild("HealthController").GetComponent <PlayerHealthScript> (); if (healthScript == null) { Debug.LogError("Could not load Player Health Script"); } }
void Start() { DontDestroyOnLoad(GameObject.Find("EmptyObject")); GameObject go = GameObject.Find("HealthSlider"); mapSlider = go.GetComponent <Slider> (); playerHealth = GetComponent <PlayerHealthScript> (); defeatCanvas = GameObject.FindGameObjectWithTag("DefeatCanvas").GetComponent <Canvas> (); defeatCanvas.gameObject.SetActive(false); winningCanvas = GameObject.FindGameObjectWithTag("WinningCanvas").GetComponent <Canvas> (); winningCanvas.gameObject.SetActive(false); restartLevel = restartLevel.GetComponent <Button> (); goToUpgradeStore = goToUpgradeStore.GetComponent <Button> (); goToMap = goToMap.GetComponent <Button> (); GameObject cannon2 = GameObject.Find("Cannon2"); cannon2.SetActive(GameObject.Find("EmptyObject(Clone)").GetComponent <StoringVarScript>().secondCannon); GameObject cannon = GameObject.Find("Cannon"); cannon.SetActive(true); layer = gameObject.layer; material = GetComponent <SpriteRenderer> ().material; color = material.color; attackDamage = GameObject.Find("EmptyObject(Clone)").GetComponent <StoringVarScript>().attackDamage; }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { startAttackTime = Time.time; HitTime = Time.time + (stateInfo.length / 3f); SplashDamage = GameObject.Find("SplashDamage").GetComponent <SplashDamageScript>(); _nav = animator.gameObject.GetComponent <AlienNavMeshInterface>(); playerHealth = GameObject.Find("PlayerSpawnLocation").GetComponent <PlayerHealthScript>(); }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Player") { TakingDamage = true; targetHealth = other.GetComponent <PlayerHealthScript>(); } }
// Use this for initialization void Start() { anim = GetComponent <Animator>(); timer = 0; currentHealth = startingHealth; player = GameObject.FindGameObjectWithTag("Player").transform; playerHealth = player.GetComponent <PlayerHealthScript>(); }
void OnTriggerExit2D(Collider2D hit) { PlayerHealthScript target = hit.gameObject.GetComponent <PlayerHealthScript>(); if (target) { playerHere = false; } }
public void OnTriggerStay2D(Collider2D hit) { PlayerHealthScript target = hit.gameObject.GetComponent <PlayerHealthScript>(); if (target) { target.InflictDamage(gameObject, damageValue); } }
public void OnTriggerEnter2D(Collider2D hit) { PlayerHealthScript player = hit.gameObject.GetComponent <PlayerHealthScript>(); if (player != null) { player.InflictDamage(gameObject, damage); } }
// Use this for initialization void Start() { amTimer = 30f; amSpeed = 1; useAntimicrobial = false; amTimerIncrement = 2; amDamage = 2; pHealthScript = FindObjectOfType <PlayerHealthScript>(); }
void Awake() { currentHealth = startingHealth; player = GameObject.FindGameObjectWithTag("Player").transform; ribo = GetComponent <Rigidbody2D>(); playerHealth = player.GetComponent <PlayerHealthScript>(); anim = GetComponent <Animator>(); colliderOne = GetComponent <BoxCollider2D>(); sprite = GetComponent <SpriteRenderer>(); enemyAudio = GetComponent <AudioSource>(); }
// Update is called once per frame void Update() { pHealthScript = FindObjectOfType <PlayerHealthScript>(); spawnWait = Random.Range(spawnMinWait, spawnMaxWait); if (pHealthScript.currentHealth <= 0) { stopSpawn = true; StopCoroutine(SpawnEnemy()); } }
public void OnTriggerExit2D(Collider2D hit) { PlayerHealthScript target = hit.gameObject.GetComponent <PlayerHealthScript>(); if (target && !target.HasMaxHealth) { target.Heal(healthValue); Destroy(gameObject); } }
void OnTriggerEnter2D(Collider2D other) { //Debug.Log("Collided"); if (other.tag == "Player") { targetHealth = other.GetComponent <PlayerHealthScript>(); targetHealth.TakeDamage(10); //Debug.Log("Damage Done"); Destroy(gameObject); } }
// Use this for initialization void Start() { gamePaused = false; resistVar = 1.0f; gameOver = false; gameOverCanvas.SetActive(false); gamePausedCanvas.SetActive(false); Instantiate(playerCharacter); playerCharacter.layer = LayerMask.NameToLayer("UserLayer"); pHealthScript = FindObjectOfType <PlayerHealthScript> (); StartCoroutine(upResist()); }
void OnTriggerExit2D(Collider2D hit) { PlayerHealthScript target = hit.gameObject.GetComponent <PlayerHealthScript>(); if (target) { foreach (GameObject obj in objectsToEnable) { obj.SetActive(false); } } }
IEnumerator invincibilityRoutine(float timelength, PlayerHealthScript playerhealth) { float timer = 0; while (timer < timelength) { timer += Time.deltaTime; yield return null; } playerhealth.hp = 1; }
//public void OnTriggerStay2D(Collider2D hit) { OnTriggerEnter2D(hit); } public void OnTriggerEnter2D(Collider2D hit) { PlayerHealthScript target = hit.gameObject.GetComponent <PlayerHealthScript>(); if (target) { target.GetComponent <SpriteRenderer> ().sortingLayerName = behindWaterLayer; target.GetComponent <PlayerMover>().dashTrail.drawTrail = false; tripScript.tripDashTrail.enabled = false; float surfaceHeight = GetComponent <SpriteRenderer>().bounds.size.y / 2 + transform.position.y; float spreadIncrement = 0.1f; float spreadLeft = 0; float spreadRight = 0; for (int i = 0; i < splashPool.Length; i++) { float x = hit.gameObject.transform.position.x; if (i != 0) { if (i % 2 == 0) //On even number, increase rightIncrement { spreadRight += spreadIncrement; x += spreadRight; } else //On odd number, decrease leftIncrement { spreadLeft -= spreadIncrement; x += spreadLeft; } } Vector3 splashPosition = new Vector3(x, surfaceHeight, -2f); splashPool[i].position = splashPosition; //Debug.Log(leftIncrement + " " + rightIncrement); ParticleSystem[] particleSystems = splashPool[i].gameObject.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem particleSystem in particleSystems) { particleSystem.Play(); } } target.DrownPlayer(); } }
// for full documentation about unity behavior lifecycle // see http://docs.unity3d.com/Manual/ExecutionOrder.html void Awake() { // Animator component animate the object based // on behavior we set in animator animator = GetComponent<Animator> (); // Rigidbody2D component give the object physics // properties like mass, drag, etc. We can interact // with the object using rigidbody2d by using physics // properties, like throwing a ball is essentially // add force to ball to specific direction rigidbody2d = GetComponent<Rigidbody2D> (); playerHealth = GetComponent<PlayerHealthScript> (); }
// Use this for initialization void Start() { HPScript = GetComponent <PlayerHealthScript>(); pauseMenu = GameObject.Find("PauseMenuFill"); pauseMenu.SetActive(false); campos = mainCam.GetComponent <CamPos>(); mouseorbit = GetComponentInChildren <MouseOrbit> (); transform.eulerAngles = new Vector3(0, 0, 90f); isCam2 = false; cam2.SetActive(isCam2); gameObject.audio.pitch = 0.7f; isPaused = false; Screen.showCursor = false; }
// Update is called once per frame void Update() { if (!PlayerHealthScript.isDead()) { if (Input.GetKeyDown(KeyCode.Escape) && pause == false) { Pause(); } else if (Input.GetKeyDown(KeyCode.Escape) && pause == true) { UnPause(); } } }
private void Awake() { if (instance != null) { return; } instance = this; playerControllerScript = GetComponent <HoverCarControl>(); playerCurrHealth = playerMaxHealth; Cursor.lockState = CursorLockMode.Confined; }
private void OnCollisionEnter2D(Collision2D collision) { string tag = collision.gameObject.tag; if (tag == "Ground") { isGrounded = true; numJumps = maxJumps; } if (tag == "Live Wire") { PlayerHealthScript health = GetComponent <PlayerHealthScript>(); health.Damage(health.maxHP); } }
void OnTriggerEnter2D(Collider2D hit) { PlayerHealthScript target = null; if (hit != null) { target = hit.gameObject.GetComponent <PlayerHealthScript>(); } if (target) { playerHere = true; player = hit.gameObject; } }
void OnTriggerEnter2D(Collider2D hit) { PlayerHealthScript target = null; if (hit != null) { target = hit.gameObject.GetComponent <PlayerHealthScript>(); } if (target) { foreach (GameObject obj in objectsToEnable) { obj.SetActive(true); } } }
public void OnTriggerStay2D(Collider2D hit) { PlayerHealthScript target = hit.gameObject.GetComponent <PlayerHealthScript>(); if (target) { GetComponent <Collider2D>().enabled = false; GetComponent <Renderer>().enabled = false; tripper.StartTripping(); if (aura) { aura.emissionRate = 0; } Invoke("EndTrip", duration); } }
void OnTriggerStay(Collider col) { if(timer > dmgInterval/Time.deltaTime){ timer = 0; phs = col.GetComponent<PlayerHealthScript>(); ehs = col.GetComponent<EnemyHealthScript>(); if(phs != null){ // Increase damage if player is too close if(Vector3.Distance(transform.position, col.transform.position) <= .35f){ timer = dmgInterval/Time.deltaTime; phs.HurtHealth(2); } phs.HurtHealth(1); } else if(ehs != null){ ehs.HurtHealth(3, this); } } }
// Update is called once per frame void Update() { pHealthScript = FindObjectOfType <PlayerHealthScript>(); if (pHealthScript.playerIsActive) { speed = 1; } else { speed = 0; } timer += Time.deltaTime * speed; int minutes; float seconds; minutes = Mathf.FloorToInt(timer / 60); seconds = timer % 60; timerText.text = string.Format("{00}:{1:00.00}", minutes, seconds); }
void Awake() { #region Get Components weaponManager = GetComponent <WeaponManager>(); zoomCameraAnimator = transform.Find("Root").transform.Find("FPS Camera").GetComponent <Animator>(); mainCameraAnimator = transform.Find("Root").transform.Find("Main Camera").GetComponent <Animator>(); playerStamina = GetComponent <PlayerStaminaScript>(); playerMovement = GetComponent <PlayerMovement>(); playerHealth = GetComponent <PlayerHealthScript>(); ammoCount = weaponManager.getAmmoCount(); isReloadingWeapon = weaponManager.getReloadState(); footStepsOfThePlayer = GetComponent <PlayerFootsteps>(); #endregion }
private void Attack() { RaycastHit2D hit; if (m_FacingRight) { Vector3 originCentral = new Vector3(transform.position.x - 0.5f, transform.position.y + 0.95f, transform.position.z); Debug.DrawRay(originCentral, new Vector3(-1, 0, 0), Color.blue, 10.0f, false); hit = Physics2D.Raycast(originCentral, new Vector3(-1, 0, 0), 10); } else { Vector3 originCentral = new Vector3(transform.position.x + 0.5f, transform.position.y + 0.95f, transform.position.z); Debug.DrawRay(originCentral, new Vector3(1, 0, 0), Color.blue, 10.0f, false); hit = Physics2D.Raycast(originCentral, new Vector3(1, 0, 0), 3); } if (hit.collider != null) { //Debug.Log("hit"); PlayerHealthScript PlayerHealth = hit.collider.gameObject.GetComponent <PlayerHealthScript>(); if (PlayerHealth != null) { if (superAttackReady) { PlayerHealth.TakeDamage(30); Debug.Log("Super Attack"); superAttackReady = false; } else { PlayerHealth.TakeDamage(10); } } } }
// Use this for initialization void Start() { playerShield = gameObject.transform.FindChild("BubbleShield").gameObject; currShieldHealth = maxShieldHealth; playerHealth = gameObject.GetComponentInParent<PlayerHealthScript>(); }
// private PlayerShoot pst; void Awake() { // ps = VariableScript.scrPlayerScript1; phs = VariableScript.scrPlayerHealthScript1; // pst = VariableScript.scrPlayerShoot1; // baseSight = Camera.main.orthographicSize; // baseSpeed = ps.moveSpeed; // baseChargeTime = pst.TimePerCharge; // baseDamage = pst.damage; // baseHealth = phs.MAX_HP; baseSight = Camera.main.orthographicSize; baseAttackRange = attackRange; baseSpeed = moveSpeed; baseChargeTime = chargeTime; baseDamage = damage; phs.MAX_HP = health; baseHealth = health; }
void Start() { playerHealth = player.GetComponent <PlayerHealthScript>(); //enemyHealth = GetComponent<EnemyHealth>(); //anim = GetComponent<Animator>(); }
void Start() { ps = VariableScript.scrPlayerScript1; phs = VariableScript.scrPlayerHealthScript1; pe = VariableScript.scrPlayerExperience1; pam = ps.GetComponent<PlayerAbilityManager>(); hpStyle.normal.textColor = Color.white; hpStyle.fontSize = 40; attributeStyle.normal.textColor = Color.white; attributeStyle.fontSize = 20; statStyle.normal.textColor = Color.white; statStyle.fontSize = 25; }
public void Attack(ushort damage) { PlayerHealthScript playerhealth = player.GetComponent <PlayerHealthScript>(); playerhealth.TakeDamage(10); }
// Use this for initialization void Start() { pHealthScript = FindObjectOfType <PlayerHealthScript>(); StartCoroutine(SpawnEnemy()); stopSpawn = false; }
void Start() { playerHealth = gameObject.GetComponent<PlayerHealthScript>(); }