Esempio n. 1
0
 void Awake()
 {
     hpBarGo     = transform.root.Find("EnermyHpBar").gameObject;
     bossHpBarGo = transform.root.Find("BossHpBar").gameObject;
     _instance   = this;
     this.gameObject.SetActive(false);//Boss HpBar和普通怪HpBar都设为false;
 }
Esempio n. 2
0
    private void ChangeHpBar(int index)
    {
        _currentHpBar.gameObject.SetActive(false);
        _currentHpBarindex = index;
        _currentHpBar      = _hpBarControllers[_currentHpBarindex];

        _currentHpBar.gameObject.SetActive(true);
        _hpbarlabel.text = _currentHpBar.name;
        Debug.Log("change HP bar to " + _currentHpBar.name);
    }
Esempio n. 3
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject gCO = GameObject.FindWithTag("GameController");

        gC              = gCO.GetComponent <GameController>();
        rBody           = GetComponent <Rigidbody2D>();
        hpO             = GameObject.FindWithTag("HpStatus");
        hpBarController = hpO.GetComponent <HpBarController>();

        Debug.Log($"Current firerateLev:{gC.FirerateLev}");
    }
Esempio n. 4
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject gCO = GameObject.FindWithTag("GameController");

        gC = gCO.GetComponent <GameController>();
        GameObject hpbCO = GameObject.FindWithTag("HpStatus");

        hpbC = hpbCO.GetComponent <HpBarController>();
        GameObject pO = GameObject.FindWithTag("Player");

        player = pO.GetComponent <PlayerMovement>();
    }
Esempio n. 5
0
    private void Start()
    {
        if (!player)
        {
            selectionPrefab = Resources.Load <GameObject>("Prefabs/Selection");
            bloodPrefab     = Resources.Load <GameObject>("Prefabs/Blood");
            hpBarPrefab     = Resources.Load <GameObject>("Prefabs/2D/HP Bar");
            player          = PlayerController.FindOrCreate();
        }

        //rb = GetComponent<Rigidbody>();

        hp = 500;
        GameObject hpObject = (GameObject)Instantiate(hpBarPrefab,
                                                      transform.position,
                                                      Quaternion.identity,
                                                      GameObject.Find("Canvas").transform);

        hpBar = hpObject.GetComponent <HpBarController>().Prepare(transform, hp);

        CalculateRadius();
    }
Esempio n. 6
0
 private void Awake()
 {
     Hp = GetComponent <HpBarController>();
 }
    // Start is called before the first frame update
    void Start()
    {
        HP = 100;
        GameObject hpO = GameObject.FindWithTag("HpStatus");

        hpBarController = hpO.GetComponent <HpBarController>();

        startingLives = 3;
        switch (SceneManager.GetActiveScene().name)
        {
        case ("Main"):
            Debug.Log("Start scene!");
            StartButton.SetActive(true);
            ExitButton.SetActive(true);
            titleLabel.gameObject.SetActive(true);
            scoreLabel.gameObject.SetActive(false);
            HighscoreLabel.gameObject.SetActive(false);
            livesLabel.gameObject.SetActive(false);
            break;

        case ("Level1Scene"):
            StartButton.SetActive(false);
            ExitButton.SetActive(false);
            titleLabel.gameObject.SetActive(false);
            scoreLabel.gameObject.SetActive(true);
            HighscoreLabel.gameObject.SetActive(true);
            livesLabel.gameObject.SetActive(true);

            Debug.Log("Level1 scene!");
            Score       = storage.score;
            Lives       = startingLives;
            audioSource = GetComponent <AudioSource>();
            break;

        case ("Level2Scene"):
            StartButton.SetActive(false);
            ExitButton.SetActive(false);
            titleLabel.gameObject.SetActive(false);
            scoreLabel.gameObject.SetActive(true);
            HighscoreLabel.gameObject.SetActive(true);
            livesLabel.gameObject.SetActive(true);

            Debug.Log("Level1 scene!");
            Score       = storage.score;
            Lives       = storage.lives;
            audioSource = GetComponent <AudioSource>();
            break;

        case ("Level3Scene"):
            StartButton.SetActive(false);
            ExitButton.SetActive(false);
            titleLabel.gameObject.SetActive(false);
            scoreLabel.gameObject.SetActive(true);
            HighscoreLabel.gameObject.SetActive(true);
            livesLabel.gameObject.SetActive(true);

            Debug.Log("Level1 scene!");
            Score       = storage.score;
            Lives       = storage.lives;
            audioSource = GetComponent <AudioSource>();
            break;

        case ("Test_Scene"):
            StartButton.SetActive(false);
            ExitButton.SetActive(false);
            titleLabel.gameObject.SetActive(false);
            scoreLabel.gameObject.SetActive(true);
            HighscoreLabel.gameObject.SetActive(true);
            livesLabel.gameObject.SetActive(true);

            Debug.Log("Test scene!");
            Score = storage.score;
            Lives = startingLives;
            break;

        case ("GameOver_Scene"):
            Score = storage.score;
            Lives = storage.lives;
            hpBarController.health = 0.0f;
            StartButton.SetActive(false);
            RetryButton.SetActive(true);
            ExitButton.SetActive(true);
            titleLabel.gameObject.SetActive(false);
            scoreLabel.gameObject.SetActive(true);
            HighscoreLabel.gameObject.SetActive(true);
            livesLabel.gameObject.SetActive(true);
            break;
        }
    }