Пример #1
0
 /*public static TheBrain GetInstance(){
     if(instance == null){
         throw new Exception("You need to load a save game first.");
     }
     return instance;
 }*/
 public static TheBrain GetInstance()
 {
     if (instance == null) {
         instance = new TheBrain ();
     }
     return instance;
 }
Пример #2
0
        protected override void OnUpdate()
        {
            _animatorComp.SetBool("isWalking", _mover.IsWalking);
            _animatorComp.SetBool("isAttacking", _attacker.IsAttacking);
            TheBrain.OnUpdate();

            _internalTimer -= Time.deltaTime;
            if (_internalTimer < 0)
            {
                _internalTimer = 0.25f;
                if (_attacker != null && AttackEffects != null)
                {
                    //turn off attack effect objects after their particles and sounds are off
                    for (int i = 0; i < AttackEffects.Length; i++)
                    {
                        if (AttackEffects[i].activeInHierarchy)
                        {
                            bool stay = false;
                            if (AttackEffects[i].GetComponent <ParticleSystem>() != null && AttackEffects[i].GetComponent <ParticleSystem>().isPlaying)
                            {
                                stay = true;
                            }
                            if (AttackEffects[i].GetComponent <AudioSource>() != null && AttackEffects[i].GetComponent <AudioSource>().isPlaying)
                            {
                                stay = true;
                            }
                            if (!stay)
                            {
                                AttackEffects[i].SetActive(false);
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
    /*public static TheBrain GetInstance(){
     *      if(instance == null){
     *              throw new Exception("You need to load a save game first.");
     *      }
     *      return instance;
     * }*/

    public static TheBrain GetInstance()
    {
        if (instance == null)
        {
            instance = new TheBrain();
        }
        return(instance);
    }
Пример #4
0
        public void ImHit()
        {
            TheBrain.ImHit();

            if (IsDead)
            {
                TheBrain.Die();
                SpawnItems();
            }
            _animatorComp.SetTrigger("isDamaged");
        }
Пример #5
0
    private void drawLevelSelection(Rect drawingRect)
    {
        int        oldFontSize   = GUI.skin.label.fontSize;
        TextAnchor oldAlignment  = GUI.skin.label.alignment;
        int        titleFontSize = 24;

        GUI.skin.label.fontSize = titleFontSize;
        //print ("Draw Level Selection at " + drawingRect.ToString ());
        string prefix = "< ";
        string suffix = " >";

        if (selectedLevel == 0)
        {
            prefix = "";
        }
        else if (selectedLevel == availableLevels.Count - 1)
        {
            suffix = "";
        }
        print(selectedLevel);
        string selectedLevelName = availableLevels [selectedLevel];
        string contentTitle      = prefix + selectedLevelName + suffix;

        GUI.BeginGroup(drawingRect);
        GUI.Label(new Rect(0, 0, drawingRect.width, 50), contentTitle);
        // TODO LevelStats anzeigen
        if (TheBrain.GetInstance().LoadedSaveGame())
        {
            int[] scoreList          = TheBrain.GetInstance().GetScoreListForLevel(selectedLevelName);
            float scoreLabelHeight   = 20;
            int   scoreLabelFontSize = 16;
            GUI.skin.label.fontSize = scoreLabelFontSize;
            //GUI.skin.label.alignment = TextAnchor.UpperLeft;
            //string scoreListString = "";
            for (int i = 0; i < scoreList.Length; i++)
            {
                int score = scoreList [i];
                //print(score);
                string scoreRow = (i + 1).ToString() + ". " + (score.ToString());
                //print(scoreRow);
                GUI.Label(new Rect(5, 50 + (i * 20), drawingRect.width / 2, 30), scoreRow);
            }
        }
        else
        {
            print("not ready");
        }
        GUI.EndGroup();
        GUI.skin.label.alignment = oldAlignment;
        GUI.skin.label.fontSize  = oldFontSize;
        //print (scoreListString);
    }
Пример #6
0
    private IEnumerator EndLevel()
    {
        this.currentLevelScore += (int)((finishScore + timeToBeat + Lander.GetInstance().GetFuel()) + 0.5f);
        //this.currentLevelScore += (int)( + 0.5f);
        TheBrain.GetInstance().ApplyCurrentScore(currentLevelScore);

        SetMessageLabelText("Well done ...", 48, 3);

        yield return(new WaitForSeconds(3));

        // TODO vernünftiges Verhalten für das Beenden eines Levels
        SetGameOver();
    }
Пример #7
0
    // Use this for initialization
    void Start()
    {
        // should initialize TheBrain
        receiver = WiimoteReceiver.Instance;
        receiver.connect();
        //if(TheBrain.GetInstance().LoadedSaveGame()){
        TheBrain.GetInstance().LoadSaveGame(selectedSaveGame);

        /*} else {
         *      print("already loaded");
         * }*/
        this.availableLevels = TheBrain.GetInstance().GetAvailableLevels();
        if (audio == null)
        {
            gameObject.AddComponent(typeof(AudioSource));
        }
    }
Пример #8
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag != "NPC" && !IsDead)
     {
         //    Debug.Log("npc triggered by " + other.transform.name);
         if ((TheBrain.CurrentState == NPCState.Patrol || TheBrain.CurrentState == NPCState.Attack) && _mover.IsWalking)
         {
             if (TheBrain.CurrentState == NPCState.Patrol)
             {
                 TheBrain.StartIdle();
             }
             else if (TheBrain.CurrentState == NPCState.Attack)
             { // dont attack here, only stop runing because it may be collided with non-player also
                 TheBrain.StopWalking();
             }
         }
     }
 }
Пример #9
0
 void Start()
 {
     //currentLandingPad = 0;
     Debug.Log("Fake load level in LandingPadGroup");
     instance         = this;
     elapsedTime      = 0;
     this.landingPads = gameObject.GetComponentsInChildren <LandingPlatform> ();
     TheBrain.GetInstance().StartNewLevel(Application.loadedLevelName);
     this.currentLevelScore       = 0;
     Physics.gravity              = new Vector3(0, -gravityForce, 0);
     this.messageLabelDisplayTime = 4;
     this.messageLabelfontSize    = 48;
     print("Finished Fake load");
     Time.timeScale = 1;
     if (gameObject.audio == null)
     {
         gameObject.AddComponent(typeof(AudioSource));
     }
 }
Пример #10
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;
    }
Пример #11
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();
    }
Пример #12
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;
    }
Пример #13
0
    void OnGUI()
    {
        // Set up gui skin
        //GUI.skin = guiSkin;

        // Our GUI is laid out for a 1920 x 1200 pixel display (16:10 aspect). The next line makes sure it rescales nicely to other resolutions.
        //GUI.matrix = Matrix4x4.TRS (new Vector3 (0, 0, 0), Quaternion.identity, new Vector3 (Screen.height / nativeVerticalResolution, Screen.height / nativeVerticalResolution, 1));

        if (isPaused || gameOver)
        {
            currentButtons = isPaused ? pauseMenuButtonNames : endMenuButtonNames;

            // TODO wrap with GUI.Box
            //print ("center: " + (Screen.width / 2).ToString ());
            float width        = 100;
            float heigthButton = 50;
            float x            = (Screen.width / 2) - (width / 2);
            float yPadding     = 10;
            float y            = (Screen.height / 2) - (heigthButton * 2);

            if (WiimoteReceiver.Instance.wiimotes.ContainsKey(1))
            {
                //print ("Got WiiMote in Menu");
                Wiimote wiimote = WiimoteReceiver.Instance.wiimotes [1];
                if (wiimote.BUTTON_A > 0)
                {
                    //GUI.b
                    string focusedControl = GUI.GetNameOfFocusedControl();
                    if (focusedControl.Length > 0)
                    {
                        if (isPaused && activeMenuButton == 0)
                        {
                            print("Continue");
                            Time.timeScale = 1;
                            isPaused       = false;
                        }
                        else if (currentButtons [currentButtons.Length - 2].Equals(focusedControl))
                        {
                            print("Restart");
                            Application.LoadLevel(TheBrain.GetInstance().GetCurrentLevelName());
                        }
                        else if (currentButtons [currentButtons.Length - 1].Equals(focusedControl))
                        {
                            print("Main Menu!");
                            Application.LoadLevel(0);
                        }
                    }
                }
            }
            //activeMenuButton = GUI.SelectionGrid (new Rect (x, y, width, height*4), activeMenuButton, selectionStrings, 1);
            GUI.skin = NormalSkin;
            string menuTitle = isPaused ? "Pause" : "Game Over";
            float  heightb   = (heigthButton * currentButtons.Length) + (yPadding * (currentButtons.Length - 1));
            GUI.Box(new Rect(x - 20, y - 30, width + 40, heightb + 40), menuTitle);
            GUI.FocusControl(currentButtons [activeMenuButton]);

            for (int i = 0; i < currentButtons.Length; i++)
            {
                GUI.SetNextControlName(currentButtons [i]);
                GUI.Button(new Rect(x, y + (i * (heigthButton + yPadding)), width, heigthButton), currentButtons [i]);
            }
            //GUI.F
        }
        else
        {
            if (messageLabelText != null)
            {
                if (messageLabelDisplayTime > 0)
                {
                    GUI.skin = NormalSkin;
                    NormalSkin.label.fontSize = messageLabelfontSize;
                    float width  = 300;
                    float height = 150;
                    float x      = (Screen.width / 2) - (width / 2);
                    float y      = (Screen.height / 2) - (height / 2);
                    GUI.Label(new Rect(x, y, width, height), messageLabelText, "label");
                    //messageLabelDisplayTime -= Time.smoothDeltaTime;
                }
                else
                {
                    messageLabelText = null;
                }
            }
        }
    }
Пример #14
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));
    }
Пример #15
0
 public override void LoadGame(IGameState gameState)
 {
     base.LoadGame(gameState);
     TheBrain.OnLoad("npc_" + _AOComponent.UniqueID);
 }
Пример #16
0
 public override void SaveGame(IGameState gameState)
 {
     base.SaveGame(gameState);
     TheBrain.OnSave("npc_" + _AOComponent.UniqueID);
 }