Ejemplo n.º 1
0
        /// <summary>
        /// 设置头部 UI 信息
        /// </summary>
        private void SetupTag()
        {
            var ib = GetComponentInChildren <InfoBar>();

            _infoBar     = ib.gameObject;
            _infoBarRect = _infoBar.GetComponent <RectTransform>();
            ib.SetupInfo(new InfoData(Level.L1, actorName));

            _hpBar     = GetComponentInChildren <HpBar>();
            _hpBarRect = _hpBar.GetComponent <RectTransform>();
            _hpBar.SetMaxHp(health.health);
            UpdateHpBar(health.health);
        }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     player_hp = StageData._data.GetHP();
     _currentAnimationState = STATE_IDLE;
     _playerRB       = GetComponent <Rigidbody2D>();
     _animator       = GetComponentInChildren <Animator>();
     _renderer       = GetComponentInChildren <SpriteRenderer>();
     _collider       = GetComponent <Collider2D>();
     _isInvulnerable = false;
     _isDead         = false;
     _hpBar.SetMaxHp(StageData._data.GetMAXHP());
     _hpBar.SetHp(player_hp);
 }
Ejemplo n.º 3
0
    public void Start()
    {
        hp              = maxHp;
        hpBar           = gameObject.GetComponentInChildren <HpBar>();
        enemyController = FindObjectOfType <EnemyController>();
        gameController  = FindObjectOfType <GameController>();
        body            = GetComponent <Rigidbody2D>();
        var norm = transform.position / -transform.position.magnitude;

        angle = Mathf.Atan2(norm.y, norm.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
        if (hpBar)
        {
            hpBar.SetMaxHp(hp);
            hpBar.SetHp(hp);
        }
    }
Ejemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        currentHp = maxHp;

        if (gameObject.name == "Player1")
        {
            hpBar = GameObject.Find("P1 Health Bar").GetComponent <HpBar>();
        }
        else if (gameObject.name == "Player2")
        {
            hpBar = GameObject.Find("P2 Health Bar").GetComponent <HpBar>();
        }

        if (hpBar != null)
        {
            hpBar.SetMaxHp(maxHp);
        }
    }