예제 #1
0
    //////////////////////////////////////////////////////////////////////


    public void ResetGame()
    {
        ConfigComp.PrintDebug("LevelControllerComp.ResetGame ");
        gameOverMenuPainel.SetActive(true);

        var texts = gameOverMenuPainel.transform.GetComponentsInChildren <Text>();

        soundtrackText   = null;
        soundEffectsText = null;
        foreach (var text in texts)
        {
            if (text.tag.Equals("SoundtrackText"))
            {
                ConfigComp.PrintDebug("LevelControllerComp.ResetGame SoundtrackText ");
                soundtrackText = text;
            }
            else
            if (text.tag.Equals("SoundEffectsText"))
            {
                ConfigComp.PrintDebug("LevelControllerComp.ResetGame SoundEffectsText ");
                soundEffectsText = text;
            }
        }
        changeTextSoundtrack();
        changeTextSoundEffects();

        PauseGame(true);

        Config.playSoundByGameOver();

        var buttons = gameOverMenuPainel.transform.GetComponentsInChildren <Button>();

        Button continueButton = null;

        foreach (var button in buttons)
        {
            if (button.name.Equals("ContinueButton"))
            {
                continueButton = button;
                break;
            }
        }

        if (continueButton != null)
        {
#if UNITY_ADS
            //Se o button continue for clicado, iremos tocar o anúncio
            StartCoroutine(ShowContinue(continueButton));
            //buttonContinue.onClick.AddListener(UnityAdControler.ShowRewardAd);
#else
            //Se nao existe add, nao precisa mostrar o botao Continue
            continueButton.gameObject.SetActive(false);
#endif
        }
    }
예제 #2
0
 private void Awake()
 {
     if (configComp != null)
     {
         Destroy(gameObject);
     }
     else
     {
         configComp = this;
         DontDestroyOnLoad(gameObject);
     }
 }
예제 #3
0
    // Use this for initialization
    void Start()
    {
        configComp = FindObjectOfType <ConfigComp>();

        if (GameObject.FindGameObjectWithTag("SoundtrackImage"))
        {
            soundtrack = GameObject.FindGameObjectWithTag("SoundtrackImage").GetComponent <Image>();
        }
        if (GameObject.FindGameObjectWithTag("SoundEffectsImage"))
        {
            soundEffects = GameObject.FindGameObjectWithTag("SoundEffectsImage").GetComponent <Image>();
        }

        changeImageSountrack();
        changeImageSoundEffects();
    }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        //ConfigComp.PrintDebug("LevelControllerComp.Start");

        configComp = FindObjectOfType <ConfigComp>();

        spaceShipComp = FindObjectOfType <SpaceShipComp>();

        goText                    = GameObject.FindGameObjectWithTag("GoText").GetComponent <Text>();
        infoLevelValue            = GameObject.FindGameObjectWithTag("InfoLevelValue").GetComponent <Text>();
        infoAsteroidsValue        = GameObject.FindGameObjectWithTag("InfoAsteroidsValue").GetComponent <Text>();
        infoMaxAsteroidsValue     = GameObject.FindGameObjectWithTag("InfoMaxAsteroidsValue").GetComponent <Text>();
        infoMaxLostAsteroidsValue = GameObject.FindGameObjectWithTag("InfoMaxLostAsteroidsValue").GetComponent <Text>();
        infoShieldValue           = GameObject.FindGameObjectWithTag("InfoShieldValue").GetComponent <Text>();
        infoBonusValue            = GameObject.FindGameObjectWithTag("InfoBonusValue").GetComponent <Text>();

        Initialize();


        numMaxAsteroidPerLevel     = (numAsteroidsType1 + numAsteroidsType2 + numAsteroidsType3);
        InfoMaxAsteroidsValue.text = numMaxAsteroidPerLevel < 0 ? "0" : numMaxAsteroidPerLevel.ToString();

        InfoMaxLostAsteroidsValue.text = numMaxLostAsteroids.ToString();

        InfoLevelValue.text = SceneManager.GetActiveScene().buildIndex.ToString();

        UpdateValueAsteroids();
        UpdateValueLostAsteroids();
        UpdateValueShield();
        UpdateValueBonus();

        ListSpots();

        if (Config.IsShieldActivated())
        {
            if (Config.numTypeShield > 0)
            {
                spaceShipComp.loadShieldSpaceShip();
            }
        }
    }
예제 #5
0
    private void KeyboardMovement()
    {
        float eixoX  = Input.GetAxis("Horizontal");
        float valueX = eixoX * 10 * Time.deltaTime;

        if (valueX != 0)
        {
            ConfigComp.PrintDebug("SpaceShipComp.KeyboardMovement - valueX = " + valueX + " - " + Mathf.Clamp(valueX, 0f, 15f));
        }
        Vector2 direcao = new Vector2(valueX, 0);

        transform.Translate(direcao);
        if (transform.position.x < 1)
        {
            Vector2 spaceShipPos = new Vector2(1, transform.position.y);
            transform.position = spaceShipPos;
        }

        if (transform.position.x > 15)
        {
            Vector2 spaceShipPos = new Vector2(15, transform.position.y);
            transform.position = spaceShipPos;
        }
    }