Inheritance: MonoBehaviour
示例#1
0
 void Start()
 {
     playerHealth    = this;
     healthText      = GetComponentInChildren <TextMeshProUGUI>();
     defaultColor    = healthText.color;
     defaultGradient = healthText.colorGradient;
     effectColor     = defaultColor;
     effectGradient  = defaultGradient;
 }
	// Use this for initialization
	void Start () {
		animationScript = GetComponent<PlayerAnimation> ();
		jumpScript = GetComponent<PlayerJump> ();
		localSpriteRenderer = GetComponent<SpriteRenderer> ();
		scoreScript = GetComponent<TheScoreSystem> ();
		currentHealth = maxHealth;

		healthUIScript = gameUI.GetComponent<UIHealth> ();
	}
示例#3
0
    public void UpdateHealth()
    {
        UIHealth Health = DmgBar.GetComponent <UIHealth>();

        Health.PercentHealth -= 10;
        if (Health.PercentHealth <= 0)
        {
            //Game Over
            SceneManager.GetComponent <SceneFunctions>().SwitchtoGGScene();
        }
    }
示例#4
0
    void Destroyer()
    {
        GameObject GO = Instantiate(Explosion, transform.position, Quaternion.identity);
        UIHealth   uh = GetComponent <UIHealth>();

        if (uh != null)
        {
            uh.healthbar.fillAmount = 0;
        }
        Destroy(gameObject);
        Destroy(GO, 0.08f);
    }
示例#5
0
    public void UpdateHealth(int Dmg)
    {
        //Updates Player Health Functions
        UIHealth Health = DmgBar.GetComponent <UIHealth>();

        Health.Damage(Dmg);
        if (Health.PercentHealth <= 0)
        {
            //Game Over
            SceneManager.GetComponent <SceneFunctions>().SwitchtoGGScene();
        }
    }
示例#6
0
 // Start is called before the first frame update
 void Start()
 {
     health = maxHealth;
     if (gameObject.tag == "Player")
     {
         healthIndicator = GameObject.Find("UIHealth").GetComponent <UIHealth>();
     }
     if (healthIndicator)
     {
         healthIndicator.setHealth(health);
     }
 }
    void Start()
    {
        ragdoll             = GetComponent <RagdollScript>();
        currentHealth       = maxHealth;
        skinnedMeshRenderer = GetComponentInChildren <SkinnedMeshRenderer>();
        healthbar           = GetComponentInChildren <UIHealth>();

        var rigidBodies = GetComponentsInChildren <Rigidbody>();

        foreach (var rigidbody in rigidBodies)
        {
            HitBox hitBox = rigidbody.gameObject.AddComponent <HitBox>();
            hitBox.health = this;
        }
    }
示例#8
0
 public void Init(LogicBase _owner, LaneManager _lane, Spawnable _type, UIHealth _healthUI, float _damageAmount)
 {
     if (init == false)
     {
         owner          = _owner;
         lane           = _lane;
         creatureType   = _type;
         uiHealth       = _healthUI;
         damageAmount   = _damageAmount;
         range          = _type == Spawnable.Bunny ? TournamentManager._instance.bunnyRange : TournamentManager._instance.unicornRange;
         init           = true;
         activeLaneNode = lane.GetFirstLaneNode(owner);
         activeLaneNode.activeCreature = this;
         owner._Creatures.Add(this);
         rightFacing = owner._RightFacing;
         // Debug.Log ("Creature owned by " + owner);
     }
 }
示例#9
0
 private void OnCollisionEnter(Collision collision)
 {
     //be able to jump again, when you have hit the ground
     if (collision.gameObject.tag == "ground")
     {
         grounded = true;
         animator.SetBool("isJumping", false);
     }
     //take damage when hit by bullet
     if (collision.gameObject.tag == "EnemyBullet")
     {
         takeDamage(10);
         if (health <= 0 && !isDead)
         {
             isDead = true;
             UIHealth.IncrementDeadCount();
         }
     }
 }
示例#10
0
 void Awake()
 {
     instance = this;
 }
示例#11
0
 // Start is called before the first frame update
 void Awake()
 {
     // Make this object the only instance
     instance = this;
 }
示例#12
0
 // Use this for initialization
 void Awake()
 {
     Instance = this;
 }
示例#13
0
    // Update is called once per frame
    void Update()
    {
        //bad
        if(mHealthUI == null) {
            if(UIModalManager.instance != null) {
                mHealthUI = UIModalManager.instance.transform.parent.GetComponentInChildren<UIHealth>();
                if(mHealthUI != null) {
                    mHealthUI.Attach(transform);
                    mHealthUI.gameObject.SetActive(mCurHealth < maxHealth);
                }
            }
        }

        switch(mCurState) {
            case State.None:
                break;

            case State.RegenWait:
                mCurTime += Time.deltaTime;
                if(mCurTime >= regenDelay) {
                    SetState(State.Regen);
                }
                break;

            case State.Regen:
                mCurHealth += (idleRegen ? regenRateIdle : regenRate) * Time.deltaTime;
                if(mCurHealth >= maxHealth) {
                    mCurHealth = maxHealth;
                    SetState(State.None);
                }
                else {
                    if(mTiler != null) {
                        mTiler.numTiles = minTileRes + (maxTileRes - minTileRes) * (mCurHealth / maxHealth);
                    }

                    ApplyHealthText();
                }
                break;

            case State.Dead:
                if(mTiler != null) {
                    mCurTime += Time.deltaTime;
                    if(mCurTime < minTileDeathDelay) {
                        mTiler.numTiles = minTileRes + (mCurTime / minTileDeathDelay) * (minTileDeathRes - minTileRes);
                    }
                    else {
                        mTiler.numTiles = minTileDeathRes;
                        mTiler = null;
                    }
                }
                break;
        }
    }
示例#14
0
 void Awake()
 {
     Instance = this;//instanciamos est objeto
 }
示例#15
0
 // Use this for initialization
 void Start()
 {
     textUI = GetComponent<Text>();
     mutex = 215;
     mutey = 40;
     health = GameObject.FindObjectOfType<UIHealth>();
     regen = GameObject.FindObjectOfType<UIRegen>();
     speed = GameObject.FindObjectOfType<UISpeed>();
     maturation = GameObject.FindObjectOfType<UIMaturation>();
     metabolism = GameObject.FindObjectOfType<UIMetabolism>();
     sight = GameObject.FindObjectOfType<UISight>();
     mutations = GameObject.FindObjectOfType<UIMutations>();
     mute1 = GameObject.FindObjectOfType<UIMute1>(); mute2 = GameObject.FindObjectOfType<UIMute2>(); mute3 = GameObject.FindObjectOfType<UIMute3>(); mute4 = GameObject.FindObjectOfType<UIMute4>();
     mute5 = GameObject.FindObjectOfType<UIMute5>(); mute6 = GameObject.FindObjectOfType<UIMute6>(); mute7 = GameObject.FindObjectOfType<UIMute7>(); mute8 = GameObject.FindObjectOfType<UIMute8>();
     mute9 = GameObject.FindObjectOfType<UIMute9>(); mute10 = GameObject.FindObjectOfType<UIMute10>();
 }
示例#16
0
 private void Awake()
 {
     instance = this;
 }