Esempio n. 1
0
    // Use this for initialization
    public void Start()
    {
        exeButton = exeButton.GetComponent <Button>();
        sound     = GetComponent <AudioSource>();
        exeButton.onClick.AddListener(taskOnClick2);
        transform.position = points [0].position;
        target [0]         = "Suitcase3";
        target [1]         = "Suitcase2";
        target [2]         = "Suitcase";

        l = 0;
        for (int l = 0; l < 3; l++)
        {
            queueArray [l] = -1;
        }

        //lifepanel
        life = new lives();
        livesPanel.transform.GetChild(0).gameObject.SetActive(false);
        livesPanel.transform.GetChild(1).gameObject.SetActive(false);
        livesPanel.transform.GetChild(2).gameObject.SetActive(false);
        for (int i = 0; i < life.getLives(); i++)
        {
            livesPanel.transform.GetChild(i).gameObject.SetActive(true);
        }
    }
Esempio n. 2
0
    void LoseLife()
    {
        GameObject gameMan = GameObject.FindWithTag("gameMan"); //Creates an instance of game manager so that the component lives can be used
        lives      player  = gameMan.GetComponent <lives>();    //Creates an instance of the lives script so that lives can be accessed

        player._lives--;
    }
Esempio n. 3
0
    // Use this for initialization
    public void Start()
    {
        Button button2 = btn2.GetComponent <Button>();

        rb    = GetComponent <Rigidbody> ();
        sound = GetComponent <AudioSource>();
        button2.onClick.AddListener(taskOnClick2);
        transform.position = points [0].position;

        l = 0;
        for (int l = 0; l < 3; l++)
        {
            queueArray [l] = -1;
        }

        //lifePanel
        life = new lives();
        livesPanel.transform.GetChild(0).gameObject.SetActive(false);
        livesPanel.transform.GetChild(1).gameObject.SetActive(false);
        livesPanel.transform.GetChild(2).gameObject.SetActive(false);
        for (int i = 0; i < life.getLives(); i++)
        {
            livesPanel.transform.GetChild(i).gameObject.SetActive(true);
        }
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        GameObject gameMan = GameObject.FindWithTag("gameMan"); //Creates an instance of mole manager so that the component spawner can be used
        lives      player  = gameMan.GetComponent <lives>();    //Creates an instance of the spawner script so that score can be accessed

        text.text = "Lives: " + player._lives;
    }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        GameObject gameMan = GameObject.FindWithTag("gameMan");
        lives      player  = gameMan.GetComponent <lives>();
        int        life    = player._lives;

        if (life == 0)
        {
            //SceneManager.LoadScene("DeathScreen");
        }
    }
Esempio n. 6
0
    private void Awake() //получение ссылок
    {
        rb        = GetComponent <Rigidbody2D>();
        animator  = GetComponent <Animator>();
        sprite    = GetComponentInChildren <SpriteRenderer>();
        extraJump = extraJumpValue;

        livesBar = FindObjectOfType <lives>();

        bullet = Resources.Load <bullet>("knife"); //ссылка на префаб
    }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        GameObject gameMan = GameObject.FindWithTag("gameMan");
        lives      player  = gameMan.GetComponent <lives>();
        int        life    = player._lives;

        if (life == 0)
        {
            //deathScreen.SetActive(true);
        }
    }
Esempio n. 8
0
    // Use this for initialization
    public void Start()
    {
        sound     = GetComponent <AudioSource>();
        exeButton = exeButton.GetComponent <Button>();
        exeButton.onClick.AddListener(taskOnClick2);
        transform.position = points [0].position;
        l = 0;
        for (int l = 0; l < 3; l++)
        {
            queueArray [l] = -1;
        }

        life = new lives();
    }
Esempio n. 9
0
    private void Start()
    {
        //Anim toma los componentes del animator y currentlive toma los componentes del scrip lives
        anim        = GetComponentInChildren <Animator>();
        currentLive = GameObject.FindObjectOfType <lives>();

        animCamera = GameObject.Find("Main Camera").GetComponentInChildren <Animator>();

        //Se da el valor de vida guardado con playerprefs
        if (PlayerPrefs.HasKey("Live"))
        {
            PlayerPrefs.GetInt("Live", live);
        }
    }
Esempio n. 10
0
    void Update()
    {
        if (player)
        {
            lives playerscript = player.GetComponent <lives>();
            stocks = playerscript.live;
        }
        print(stocks);

        if (stocks == 0)
        {
            print("in");
            button.gameObject.SetActive(true);
            button2.gameObject.SetActive(true);
        }
    }
Esempio n. 11
0
 // Use this for initialization
 void Start()
 {
     player = gameMan.GetComponent <lives>();        //Creates an instance of the spawner script so that score can be accessed
     text   = GetComponent <Text>();
 }
Esempio n. 12
0
    // Update is called once per frame
    void Update()
    {
        if (!difficultySelected)
        {
            if (GameObject.Find("Easy button").GetComponent <difficultyButton>().m_difficulty == "Easy")
            {
                difficultySelected = true;
                minAliveTime       = 4.0f; //ATM timer = 5.0 and despawntimer = 9.0f
                maxAliveTime       = 5.5f;
                minDespawnTime     = 5.5f;
                maxDespawnTime     = 6.0f;
                GameObject.Find("Easy button").SetActive(false);
                GameObject.Find("Medium button").SetActive(false);
                GameObject.Find("Hard button").SetActive(false);
            }

            else if (GameObject.Find("Medium button").GetComponent <difficultyButton>().m_difficulty == "Medium")
            {
                difficultySelected = true;
                minAliveTime       = 2.0f; //ATM timer = 5.0 and despawntimer = 9.0f
                maxAliveTime       = 3.0f;
                minDespawnTime     = 3.0f;
                maxDespawnTime     = 4.0f;
                GameObject.Find("Easy button").SetActive(false);
                GameObject.Find("Medium button").SetActive(false);
                GameObject.Find("Hard button").SetActive(false);
            }

            else if (GameObject.Find("Hard button").GetComponent <difficultyButton>().m_difficulty == "Hard")
            {
                difficultySelected = true;
                minAliveTime       = 0.75f; //ATM timer = 5.0 and despawntimer = 9.0f
                maxAliveTime       = 1.25f;
                minDespawnTime     = 1.25f;
                maxDespawnTime     = 2.75f;
                GameObject.Find("Easy button").SetActive(false);
                GameObject.Find("Medium button").SetActive(false);
                GameObject.Find("Hard button").SetActive(false);
            }
        }

        if (difficultySelected)
        {
            if (countdown <= 0.0f)
            {
                if (firsttime)
                {
                    firsttime = false;
                    lives.SetActive(true);
                    countdownScreen.SetActive(false);
                    GameObject.Find("countdown").SetActive(false);
                    other = moles[selectedMole];
                }

                lives gameMan = GameObject.FindWithTag("gameMan").GetComponent <lives>();
                if (gameMan._lives <= 0)
                {
                    SceneManager.LoadScene("Leaderboard");
                }
                other = moles[selectedMole];
                if (other.GetComponent <hit>().whacked == true && !spawning) //If whacked is true
                {
                    spawning = true;
                    other.GetComponent <hit>().whacked = false;
                    timer         = 0.0f;
                    despawn_timer = randomAliveTime;

                    audio.Play();
                    //Now spawn new mole
                    selectedMole = newnumber();
                    moles[selectedMole].GetComponent <hit>().poof.SetActive(false);

                    randomDespawnTime = Random.Range(minDespawnTime, maxDespawnTime);
                    randomAliveTime   = Random.Range(minAliveTime, maxAliveTime);
                }
                //Mole missed
                else if (timer >= randomAliveTime && !spawning) //If whacked is false
                {
                    moles[selectedMole].SetActive(false);

                    LoseLife();
                    selectedMole      = newnumber();
                    spawning          = true;
                    timer             = 0.0f;
                    despawn_timer     = randomAliveTime;
                    randomDespawnTime = Random.Range(minDespawnTime, maxDespawnTime);
                    randomAliveTime   = Random.Range(minAliveTime, maxAliveTime);
                }

                else if (despawn_timer >= randomDespawnTime && spawning)
                {
                    selectedMole = newnumber();
                    moles[selectedMole].SetActive(true);

                    timer         = 0.0f;
                    despawn_timer = randomAliveTime;
                    spawning      = false;
                }

                if (game_timer >= 5.0f)
                {
                    minAliveTime   = 0.75f;
                    maxAliveTime   = 1.0f;
                    minDespawnTime = 1.0f;
                    maxDespawnTime = 2.25f;
                }

                if (game_timer >= 10.0f)
                {
                    minAliveTime   = 0.75f;
                    maxAliveTime   = 0.95f;
                    minDespawnTime = 0.95f;
                    maxDespawnTime = 2.25f;
                }

                //game_timer += Time.deltaTime;
                despawn_timer += Time.deltaTime;
                timer         += Time.deltaTime;
                //Debug.Log("Timer is at: " +  timer);
            }
            else
            {
                float newNum;
                newNum = Mathf.Round(countdown);
                GameObject.Find("countdown").GetComponent <Text>().text = newNum.ToString();

                countdownScreen.SetActive(true);
                countdown -= Time.deltaTime;
            }
        }
        else
        {
            easybutton.SetActive(true);
            medbutton.SetActive(true);
            hardbutton.SetActive(true);
            countdownScreen.SetActive(true);
        }
    }
Esempio n. 13
0
 // Use this for initialization
 void Start()
 {
     levelManager = GameObject.FindObjectOfType <LevelManager>();
     audioSource  = GameObject.FindObjectOfType <AudioSource>();
     liveDisplay  = GameObject.FindObjectOfType <lives>();
 }