private void Awake() { if (Instance == null) { Instance = this; } }
// Use this for initialization void Start() { drawGUI = false; GameObject go = GameObject.FindGameObjectWithTag("Player"); ph = (PlayerHealthBar)go.GetComponent(typeof(PlayerHealthBar)); }
private void Start() { player = FindObjectOfType <PlayerController>(); healthKit = FindObjectOfType <PlayerHealthKitController>(); healthBarUI = FindObjectOfType <PlayerHealthBar>(); healthKitBar = FindObjectOfType <PlayerHealthKitBar>(); }
// Start is called before the first frame update void Start() { if (UponDeath == null) { UponDeath = new UnityEvent(); } thing = this.gameObject; // Gets sound source GameObject source = GameObject.Find("Sound Source"); sound = source.GetComponent <SoundPlayonEvent>(); // Sets component of Player HB, and runs it for the first time GameObject play = GameObject.FindGameObjectWithTag("Player"); player = play.GetComponent <PlayerHealthBar>(); player.HealthChange(CurrentHealth, MaximumHealth); //unused bit for boss /* * Scene currentScene = SceneManager.GetActiveScene(); * // Gets script off of health bar object, and runs it once * if (currentScene.buildIndex == 6) * { * GameObject enemy = GameObject.Find("Boss Health"); * boss = enemy.GetComponent<BossHealthBar>(); * boss.BarChange(); * } */ }
public GameLayer() : base(CCColor4B.Black) { player = new Player(); AddChild(player, PLAYER_INDEX); healthBar = new PlayerHealthBar(); AddChild(healthBar, HEALTH_BAR_INDEX); lblScore = new CCLabel(SCORE_CONTENT + score, "Fonts/MarkerFelt", 22, CCLabelFormat.SpriteFont); lblScore.AnchorPoint = new CCPoint(0f, 1f); lblScore.Schedule(s => { lblScore.Text = SCORE_CONTENT + score; }); AddChild(lblScore, SCORE_INDEX); mniPause = new CCMenuItemImage(new CCSprite("btnPause.png"), new CCSprite("btnPauseSelected.png"), delegate(object obj) { //GameView.Paused = !GameView.Paused; }); mnuPause = new CCMenu(new CCMenuItem[] { mniPause }); mnuPause.AlignItemsVertically(); mnuPause.AnchorPoint = CCPoint.AnchorUpperRight; AddChild(mnuPause, PAUSE_BUTTON_INDEX); //check collision Schedule(s => CheckCollision()); //player shoots bullets Schedule(s => visiblePlayerBullets.Add(AddPlayerBullet()), PLAYER_SHOOTING_INTEVAL); //spawn enemies Schedule(s => SpawnEnemies(), 2f); }
void Start() { rigidBody = GetComponent <Rigidbody>(); audioSource = GetComponent <AudioSource>(); player = GetComponent <PlayerHealthBar>(); playerFuel = GetComponent <PlayerFuelBar>(); astronaut = GameObject.FindWithTag("Player"); anim = GetComponentInChildren <Animator>(); }
void HealPlayer() { PlayerManager.p_instance.p_health += 5; if (PlayerManager.p_instance.p_health >= 100) { PlayerManager.p_instance.p_health = 100; } PlayerHealthBar.SetHealthBarValue(PlayerHealthBar.GetHealthBarValue() + .05f); }
void DamagePlayer() { PlayerManager.p_instance.p_health -= 10; PlayerHealthBar.SetHealthBarValue(PlayerHealthBar.GetHealthBarValue() - 0.10f); if (PlayerManager.p_instance.p_health <= 0) { OnPlayerDeath(); } }
// Start is called before the first frame update void Start() { playerGroundedCheck = GetComponentInChildren <PlayerGroundedCheck>(); playerTransform = GetComponent <Transform>(); player = GetComponent <Rigidbody2D>(); playerCollider = GetComponent <CapsuleCollider2D>(); playerAttack = GetComponent <playerAttack>(); UI = FindObjectOfType <Canvas>(); healthBar = UI.GetComponentInChildren <PlayerHealthBar>(); }
void Awake() { //reference player health bar script playerHealthBar = GetComponent<PlayerHealthBar>(); //get reference to player object player = GameObject.FindGameObjectWithTag(Tags.player); playerAnim = player.GetComponent<Animator>(); }
// Start is called before the first frame update void Start() { DefendDefense = 0; EnemyDefendDefense = 0; EnemyBarFill = EnemyHealthBar.GetComponent <Image>(); PlayerBarFill = PlayerHealthBar.GetComponent <Image>(); EnemySignatureCharges = Random.Range(1, 2); State = States.Idle; PlayerTurn = true; playerDefense = PlayerPrefs.GetFloat("_Defense"); Abilities[0] = PlayerPrefs.GetInt("Ability_1"); Abilities[1] = PlayerPrefs.GetInt("Ability_2"); Abilities[2] = PlayerPrefs.GetInt("Ability_3"); Abilities[3] = PlayerPrefs.GetInt("Ability_4"); if (Abilities[1] == 0) { Abilities[1] = 1; } if (Abilities[2] == 0) { Abilities[2] = 2; } if (Abilities[3] == 0) { Abilities[3] = 3; } PlayerAbilities[0] = AbilityList.Abilities[Abilities[0]]; PlayerAbilities[1] = AbilityList.Abilities[Abilities[1]]; PlayerAbilities[2] = AbilityList.Abilities[Abilities[2]]; PlayerAbilities[3] = AbilityList.Abilities[Abilities[3]]; _Ability1.GetComponentInChildren <TextMeshProUGUI>().text = PlayerAbilities[0].ButtonText; _Ability1.GetComponentInChildren <TextMeshProUGUI>().color = PlayerAbilities[0].ButtonTextColor; _Ability2.GetComponentInChildren <TextMeshProUGUI>().text = PlayerAbilities[1].ButtonText; _Ability2.GetComponentInChildren <TextMeshProUGUI>().color = PlayerAbilities[1].ButtonTextColor; _Ability3.GetComponentInChildren <TextMeshProUGUI>().text = PlayerAbilities[2].ButtonText; _Ability3.GetComponentInChildren <TextMeshProUGUI>().color = PlayerAbilities[2].ButtonTextColor; _Ability4.GetComponentInChildren <TextMeshProUGUI>().text = PlayerAbilities[3].ButtonText; _Ability4.GetComponentInChildren <TextMeshProUGUI>().color = PlayerAbilities[3].ButtonTextColor; int i = Random.Range(0, EnemyList.EnemyList.Length); StartingEnemy = EnemyList.EnemyList[i]; EnemyTitle.GetComponent <TextMeshProUGUI>().text = StartingEnemy.Name; EnemyTitle.GetComponent <TextMeshProUGUI>().color = StartingEnemy.NameColor; _Enemy.GetComponent <Animator>().runtimeAnimatorController = StartingEnemy.DefaultAnimation; DefaultEnemyAnimation = StartingEnemy.DefaultAnimation; EnemyAbilities[0] = StartingEnemy.BasicAttack; EnemyAbilities[1] = StartingEnemy.DefenseAbility; EnemyAbilities[2] = StartingEnemy.UtilityAbility; EnemyAbilities[3] = StartingEnemy.SignatureAbility; }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); PlayerHealthBar playerHealthBar = (PlayerHealthBar)target; if (GUILayout.Button("OnTakingDamage")) { playerHealthBar.OnTakingDamage(playerHealthBar.player.playerId, (float)playerHealthBar.player.playerId.currentHealth / (float)playerHealthBar.player.playerId.maxHealth); } }
// Use this for initialization void Start() { GameObject go = GameObject.FindGameObjectWithTag("Player"); target = go.transform; myTransform = transform; maxDistance = 3; coolDownTimer = 0; damage = -1; ph = (PlayerHealthBar)go.GetComponent(typeof(PlayerHealthBar)); }
private void Attack() { float distance = Vector3.Distance(_target.transform.position, transform.position); Vector3 dir = (_target.transform.position - transform.position).normalized; float direction = Vector3.Dot(dir, transform.forward); if (distance <= 2.5f && direction > 0) { PlayerHealthBar eh = (PlayerHealthBar)_target.GetComponent("PlayerHealthBar"); eh.AddjustCurrentHealth(-10); } }
public void Start() { playerHealthBar = FindObjectOfType <PlayerHealthBar>(); player = FindObjectOfType <Player>(); powerLines = FindObjectsOfType <PowerLine>(); joints = new Dictionary <PowerLine, PowerLine>(); timer = FindObjectOfType <Timer>(); gameOver = FindObjectOfType <GameOver>(); SetPlayerHealth(player.power, player.powerMax); menuMusic.Play(); gameMusic.Stop(); }
// when the collsion of the two players happens //void OnCollisionStay(Collision collisionInfo) //{ // if (collisionInfo.gameObject.tag =="Player") // { // if(Attack()) // collisionInfo.collider.SendMessageUpwards("PlayerDamage",damage,SendMessageOptions) // } //} private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { anim.SetBool("isAttacking", true); PlayerHealthBar ph = other.GetComponent <PlayerHealthBar>(); if (ph != null) { ph.TakeDamage(damagePlayer); } } }
// Use this for initialization void Start() { // Debug.Log ("VI TRI HIEN TAI CUA THANH THOI GIAN: " + timeBarTransform.position); questionFadeScript = questionPanel.GetComponent <QuestionFadeScript>(); monsterFadeScript = monsterPanel.GetComponent <MonsterFadeScript>(); playerHealthBarScript = playerHealthBar.GetComponent <PlayerHealthBar> (); questionManagerScript = quesManager.GetComponent <QuestionManager>(); statusDialogScript = statusDialog.GetComponent <StatusDialogScript> (); buttonControllerScript = buttonController.GetComponent <ButtonController> (); cachedY = timeBarTransform.position.y; maxXValue = timeBarTransform.position.x; minXValue = timeBarTransform.position.x - timeBarTransform.rect.width; currentTime = maxTime; oldPos = timeBarTransform.position; }
void Start() { controller = GetComponent <PlayerController> (); controller.Init(); healthBar = GetComponent <PlayerHealthBar> (); healthBar.Init(); Debug.Log(" 1. Keyboard Arrow is move"); Debug.Log(" 2. Num 1 -> Camera Shake"); Debug.Log(" 3. Num 2, 3 -> Health Bar"); Debug.Log(" 4. Num 4, 5 -> Focus Camera"); Debug.Log(" 5. Num Space -> Sound Play, SkillEffect"); SoundManager.ins.PlayMusic(audioBGM); }
private void Start() { playerTransform = GetComponent <Transform>(); playerAgent = GetComponent <NavMeshAgent>(); hammerBehaviour = GetComponentInChildren <HammerBehaviour>(); basicAttackTrigger = GetComponentInChildren <AttackTrigger>(); cameraBehaviour = GameObject.FindWithTag("CameraController").GetComponent <CameraBehaviour>(); thorAnimator = GetComponentInChildren <Animator>(); timeManager = GameObject.FindWithTag("manager").GetComponent <TimeManager>(); audioPlayer = GetComponent <AudioPlayer>(); musicAmbientController = GameObject.FindWithTag("MusicAmbientController").GetComponent <MusicAmbientController>(); foreach (AnimationClip animation in thorAnimator.runtimeAnimatorController.animationClips) { //animationsList.Add(new AnimationClipName(animation.name, animation)); if (animation.name == "throwHammer") { throwDuration = animation.length / 1.4f; } if (animation.name == "hit_01") { attackDuration = animation.length; } if (animation.name == "slowArea") { slowAreaInitDelay = animation.length / 1.3f; } if (animation.name == "lightboltRain") { lightRainCastInitDuration = animation.length; } } agentSpeed = playerAgent.speed; maxLife = life; playerHealthBar = GameObject.Find("GameplayUI").GetComponent <PlayerHealthBar>(); StartCoroutine(SetInitLife()); endingPlayer = playerHealthBar.gameObject.GetComponent <PlayEnding>(); passiveInitDuration = passiveDuration; particleInstancer = GameObject.FindWithTag("ParticleInstancer").GetComponent <ParticleInstancer>(); }
// Start is called before the first frame update void Start() { //gold = InitialGold; lives = MaxLives; PlayerHealth = GameObject.Find("/Grid/Canvas/Health_Blood").GetComponent <PlayerHealthBar>(); PlayerHealth.maxLives = MaxLives; PlayerHealth.lives = lives; remainingEnemies = GetComponent <EnemyGenerator>().Waves.Sum(w => w.Amount); SBM = GameObject.Find("GameManagement").GetComponent <SketchBoxesManagement>(); //EvalPanel = GameObject.Find("Evaluation"); //VictoryText = GameObject.Find("/Evaluation/Victory"); //GameOverText = GameObject.Find("/Evaluation/GameOver"); //Debug.Log(GameObject.Find("/Evaluation/Canvas/TotalScores")); totalScore = GameObject.Find("/Evaluation/Canvas/TotalScores/Scores").GetComponent <Score>(); simScore = GameObject.Find("/Evaluation/Canvas/Similarity/Scores").GetComponent <Score>(); speedScore = GameObject.Find("/Evaluation/Canvas/Speed/Scores").GetComponent <Score>(); EvalPanel.SetActive(false); }
// Use this for initialization void Awake() { playerHealth = player.GetComponent<PlayerHealthBar>(); }
void Start() { thePlayerHealth = FindObjectOfType <HealthManager>(); thePlayerHealthBar = FindObjectOfType <PlayerHealthBar>(); }
private PlayerHealthBar playerHealth; // Reference to the PlayerControl script. void Awake () { // Setting up the reference. player = GameObject.FindGameObjectWithTag("Player").transform; playerHealth = GetComponent<PlayerHealthBar>(); }
void Start() { PlayerHealthBar = GameObject.Find("PlayerHealthBar").GetComponent <PlayerHealthBar>(); }
private void Awake() { Instance = this; }
private void Awake() { monsterHealthBar = GameObject.Find("MonsterHealthbar").GetComponent <MonsterHealthBar>(); playerHealthBar = GameObject.Find("PlayerHealthbar").GetComponent <PlayerHealthBar>(); }
void Awake() { instance = this; }
// Use this for initialization void Start() { PHB = FindObjectOfType <PlayerHealthBar>(); }