示例#1
0
    // Use this for initialization
    void Start()
    {
        if (GameObject.Find("TheBrain") != null)
        {
            brain = GameObject.Find("TheBrain").GetComponent <TheBrain>();
        }
        else
        {
            Debug.Log("The Brain was not found for this object");
            brain = new TheBrain();

            brain.Time         = float.PositiveInfinity;
            brain.PlayersMoney = 100;
            brain.InitalizePlayerItemCount();
            brain.InitalizePlayerIncenseCount();
            brain.currIncense = TheBrain.IncenseTypes.Base;
        }

        currLevelID = SceneManager.GetActiveScene().buildIndex;
        if (pauseMenu != null)
        {
            pauseMenu.SetActive(false);
        }
        //brain.nextSceneIndex = SceneManager.GetSceneByName(resetLevel).buildIndex;
        _closeDoors = GameObject.Find("CloseDoors");
        _closeDoors.SetActive(false);

        if (!Regex.IsMatch(SceneManager.GetActiveScene().name, "Shop"))
        {
            _inShop = false;
        }
        else
        {
            _inShop = true;
        }

        foreach (AudioSource sound in soundSystem)
        {
            sound.Play();
        }

        //nextLevel = SceneManager.GetSceneByBuildIndex(brain.nextSceneIndex).name;
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        _currentState = playerState.FREE;
        // TODO: Discover a more efficient way to find the below game object
        // I made it worse, but this was to ensure enstantiation of the brain on startup.
        //  I don't think there will be horrible performance issues. -JW
        if (GameObject.Find("TheBrain") != null)
        {
            brain = GameObject.Find("TheBrain").GetComponent <TheBrain>();
        }
        else
        {
            Debug.Log("The Brain was not found for this object");
            brain = new TheBrain();

            brain.Time         = float.PositiveInfinity;
            brain.PlayersMoney = 100;
            brain.InitalizePlayerItemCount();
            brain.InitalizePlayerIncenseCount();
            brain.currIncense = TheBrain.IncenseTypes.Base;

            debugMode = true;
        }

        _controller = gameObject.GetComponent <CharacterController2D>();
        _animator   = gameObject.GetComponent <AnimationController2D>();
        gameCamera.GetComponent <CameraFollow2D>().startCameraFollow(this.gameObject);

        _invincibilitySprite = GameObject.Find("Invincible");
        _invincibilitySprite.SetActive(false);

        TimeInitialization();

        BankAccount.AddToBank(brain.PlayersMoney);
        _prevY = gameObject.transform.position.y;

        _playerCollider = gameObject.GetComponent <BoxCollider2D>();

        _source = GetComponent <AudioSource>();
        _source.Play();
    }
示例#3
0
    // Use this for initialization
    void Start()
    {
        if (GameObject.Find("TheBrain") != null)
        {
            brain = GameObject.Find("TheBrain").GetComponent <TheBrain>();
        }
        else
        {
            Debug.Log("The Brain was not found for this object");
            brain = new TheBrain();

            brain.Time         = float.PositiveInfinity;
            brain.PlayersMoney = 100;
            brain.InitalizePlayerItemCount();
            brain.InitalizePlayerIncenseCount();
            brain.currIncense = TheBrain.IncenseTypes.Base;
        }

        bombDisplay = GetComponent <Text>();
        pretext     = bombDisplay.text;
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        if (GameObject.Find("TheBrain") != null)
        {
            brain = GameObject.Find("TheBrain").GetComponent <TheBrain>();
        }
        else
        {
            Debug.Log("The Brain was not found for this object");
            brain = new TheBrain();

            brain.Time         = float.PositiveInfinity;
            brain.PlayersMoney = 100;
            brain.InitalizePlayerItemCount();
            brain.InitalizePlayerIncenseCount();
            brain.currIncense = TheBrain.IncenseTypes.Base;
        }

        player = GameObject.Find("Player").GetComponent <PlayerController>();

        _animator = GetComponent <AnimationController2D>();
        cart      = new ShoppingCart();

        BombCount.text          = cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Bomb).ToString();
        InvincibilityCount.text = cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Invincible).ToString();

        BombPricing.text          = (10 * cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Bomb)).ToString();
        InvincibilityPricing.text = (10 * cart.GetNumOfSpecificItem(TheBrain.ItemTypes.Invincible)).ToString();

        TotalCount.text   = cart.GetTotalSizeOfCart().ToString();
        TotalPricing.text = player.BankAccount.TotalWithdrawalAmount.ToString();

        Sprite currIncense;

        if (brain.currIncense != TheBrain.IncenseTypes.None)
        {
            currIncense = brain.IncenseSprites[(int)brain.currIncense];
        }
        else
        {
            currIncense = brain.IncenseSprites[0];
        }


        //conversionTimer = new TimerController(brain.TotalTime, currIncense,
        //                                    currentTimeConversionBar, conversionTimerText);

        //conversionTimer.ReduceTimer((brain.TotalTime - brain.Time) * 60);

        prevValue = currentTimeConversionBar.value = maxSliderValue = (brain.Time / (brain.TotalTime));

        float conversionCalc = 5 + (7 * (9 - (10 * (brain.Time / (brain.TotalTime)))));

        float barX = (conversionCalc > 0) ? conversionCalc : 0;

        subtractedConversionBar.rectTransform.offsetMax = new Vector2(-barX, subtractedConversionBar.rectTransform.offsetMax.y);

        double minutes = brain.Time;             //Divide the guiTime by sixty to get the minutes.
        double seconds = (brain.Time * 60) % 60; //Use the euclidean division for the seconds

        conversionTimerText.text = string.Format("{0:00} : {1:00}", Math.Floor(minutes), Math.Floor(seconds));
    }