Пример #1
0
        private void BuyPlayerSupplies(int windowID)
        {
            GUI.contentColor = backgroundColor;

            SetHealth(0);
            SetHappiness(0);

            GUI.Label(new Rect(85, 30, 150, 30), "Grain", customTextStyle);
            GUI.Label(new Rect(245, 30, 150, 30), "Hay", customTextStyle);
            GUI.Label(new Rect(380, 30, 150, 30), "Pellets", customTextStyle);
            GUI.Label(new Rect(85, 70, 150, 30), "€" + grainCost, customTextStyle);
            GUI.Label(new Rect(240, 70, 150, 30), "€" + hayCost, customTextStyle);
            GUI.Label(new Rect(385, 70, 150, 30), "€" + pelletsCost, customTextStyle);

            if (GUI.Button(new Rect(80, 105, 75, 75), "", buttonGrain))                 // Add to player class / inventory
            {
                if (GameController.Instance().player.cash >= grainCost)
                {
                    GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                    GameController.Instance().player.grain++;
                    GameController.Instance().player.cash = GameController.Instance().player.cash - grainCost;
                }
            }

            if (GUI.Button(new Rect(230, 105, 75, 75), "", buttonHay))                          // Add to player class / inventory
            {
                if (GameController.Instance().player.cash >= hayCost)
                {
                    GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                    GameController.Instance().player.hay++;
                    GameController.Instance().player.cash = GameController.Instance().player.cash - hayCost;
                }
            }

            if (GUI.Button(new Rect(380, 105, 75, 75), "", buttonPellets))              // Add to player class / inventory
            {
                if (GameController.Instance().player.cash >= pelletsCost)
                {
                    GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                    GameController.Instance().player.pellet++;
                    GameController.Instance().player.cash = GameController.Instance().player.cash - pelletsCost;
                }
            }

            GUI.Label(new Rect(110, 190, 150, 30), "" + GameController.Instance().player.grain, customTextStyle);
            GUI.Label(new Rect(260, 190, 150, 30), "" + GameController.Instance().player.hay, customTextStyle);
            GUI.Label(new Rect(410, 190, 150, 30), "" + GameController.Instance().player.pellet, customTextStyle);

            if (GUI.Button(new Rect(535, 180, 50, 50), "", buttonX))
            {
                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                GameController.Instance().globalSuppliesUI = false;
            }
        }
Пример #2
0
        public void MusicLevelChange()
        {
            GameController.Instance().musicLevel = gameObject.GetComponent <UISlider>().value;
            //AudioListener.volume = GameController.Instance().musicLevel;

            if (GameController.Instance().musicLevel < 0.05f)
            {
                GameController.Instance().musicLevel = 0.05f;
                gameObject.GetComponent <UISlider>().value = GameController.Instance().musicLevel;
            }
        }
Пример #3
0
        public void Start()
        {
            if (gameObject.name.Equals("FX Slider"))
            {
                gameObject.GetComponent <UISlider>().value = GameController.Instance().fxLevel;
            }

            if (gameObject.name.Equals("Music Slider"))
            {
                gameObject.GetComponent <UISlider>().value = GameController.Instance().musicLevel;
            }
        }
Пример #4
0
        void OnGUI()
        {
            GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), backgroundTexture);

            if (!isLoading)
            {
                GUI.Label(new Rect(Screen.width * .23f, Screen.height * (buttonPadding - .225f), Screen.width * .58f, Screen.height * .16f), "", labelGameTitle);
            }

            if (!isLoading)
            {
                if (GUI.Button(new Rect(Screen.width * .28f, Screen.height * (buttonPadding * 1.05f), Screen.width * .45f, Screen.height * .15f), "", buttonNewStyle))
                {
                    GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                    StartCoroutine(WaitFor(1));                         // Load player name scene
                }
            }

            if (!isLoading)
            {
                if (GUI.Button(new Rect(Screen.width * .28f, Screen.height * (buttonPadding * 1.92f), Screen.width * .45f, Screen.height * .15f), "", buttonLoadStyle))
                {
                    GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                    GameController.Instance().loadPlayer = true;

                    bool fileTest1 = File.Exists(Application.persistentDataPath + "/player.dat");
                    bool fileTest2 = File.Exists(Application.persistentDataPath + "/cows.dat");

                    if (fileTest1 || fileTest2)
                    {
                        StartCoroutine(WaitFor(2));                                     // Load player farm scene
                        isLoading         = true;
                        backgroundTexture = backgroundLoading;
                    }
                    else
                    {
                        StartCoroutine(WaitForSec(3));
                        isLoading         = true;
                        backgroundTemp    = backgroundTexture;
                        backgroundTexture = backgroundNoGame;
                    }
                }
            }

            if (!isLoading)
            {
                if (GUI.Button(new Rect(Screen.width * .37f, Screen.height * (buttonPadding * 2.9f), Screen.width * .225f, Screen.height * .145f), "", buttonExitStyle))
                {
                    GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                    StartCoroutine(WaitFor(10));                        // Exit game
                }
            }
        }
Пример #5
0
        private void CowMoreInfo(int windowID)
        {
            GUI.contentColor = backgroundColor;

            SetHealth(cow.health / 100f);
            SetHappiness(cow.happiness / 10f);

            healthBar.transform.position    = new Vector2(windowRect.center.x + 70, 300);
            happinessBar.transform.position = new Vector2(windowRect.center.x + 70, 265);

            if (!cow.gender == true)
            {
                cowGender = "Female";

                if (cow.pregnant == true)
                {
                    cowPregnant = "Yes";
                }
            }
            else
            {
                cowGender    = "Male";
                cow.pregnant = false;
                cowPregnant  = "No";
            }

            GUI.Label(new Rect(35, 40, 80, 25), "", labelAge);
            GUI.Label(new Rect(142, 40, 150, 30), "" + cow.age, customTextStyle);
            GUI.Label(new Rect(35, 72, 90, 25), "", labelBreed);
            GUI.Label(new Rect(142, 72, 150, 30), "" + cowGender, customTextStyle);
            GUI.Label(new Rect(35, 105, 110, 30), "", labelHappiness);
            GUI.Label(new Rect(35, 140, 90, 25), "", labelHealth);
            GUI.Label(new Rect(35, 175, 110, 30), "", labelPregnant);
            GUI.Label(new Rect(160, 175, 150, 30), "" + cowPregnant, customTextStyle);
            GUI.Label(new Rect(35, 210, 90, 25), "", labelGender);
            GUI.Label(new Rect(142, 210, 150, 30), "" + cowGender, customTextStyle);
            GUI.Label(new Rect(35, 245, 90, 30), "", labelWeight);
            GUI.Label(new Rect(142, 245, 150, 30), "" + cow.weight + " KG", customTextStyle);

            if (GUI.Button(new Rect(38, 300, 80, 40), "", buttonFeed))
            {
                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                GameController.Instance().farmCowMoreInfoUI = false;
                GameController.Instance().farmCowFeedUI     = true;
            }

            if (GUI.Button(new Rect(285, 292, 50, 50), "", buttonX))
            {
                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                GameController.Instance().farmCowMoreInfoUI = false;
                GameController.Instance().farmCowUI         = true;
            }
        }
Пример #6
0
        private IEnumerator WaitFor(int level)
        {
            yield return(new WaitForSeconds(1.0f));

            if (level == 10)
            {
                Application.Quit();
            }
            else
            {
                GameController.Instance().ResetMenus();
                Application.LoadLevel(level);
            }
        }
Пример #7
0
        // Menu for controlling to either buy or sell animals
        private void Menu(int windowID)
        {
            GUI.contentColor = backgroundColor;

            SetHealth(0f);
            SetHappiness(0f);

            if (isLoading)
            {
                GUI.Label(new Rect(200, 32, 270, 50), "", labelLoading);
            }

            if (bidResult)
            {
                GUI.Label(new Rect(190, 32, 270, 50), "", biddingResult);
            }

            if (!isLoading)
            {
                if (!bidResult)
                {
                    if (GUI.Button(new Rect(130, 35, 115, 55), "", buttonBuy))
                    {
                        GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                        GameController.Instance().martCowMenuUI   = false;
                        GameController.Instance().martCowBuyBidUI = true;
                        joyStick.gameObject.SetActive(false);
                        LookAtRing();
                    }
                }
            }

            if (!isLoading)
            {
                if (!bidResult)
                {
                    if (GUI.Button(new Rect(330, 35, 115, 45), "", buttonSell))
                    {
                        GetComponent <AudioSource> ().PlayOneShot(buttonSound, 0.6f);
                        GameController.Instance().martCowMenuUI    = false;
                        GameController.Instance().martCowSellBidUI = true;
                        MartBidControl.cowList.SetActive(true);
                        joyStick.gameObject.SetActive(false);
                        LookAtRing();
                    }
                }
            }
        }
Пример #8
0
        public void PopulateList()
        {
            int count = 0;

            foreach (var cow in GameController.Instance().cows)
            {
                ++count;
                GameObject newButton = Instantiate(cowButton) as GameObject;
                CowButton  genButton = newButton.GetComponent <CowButton>();
                genButton.GetComponentInChildren <Text>().text = "Cow " + count;
                genButton.name             = "" + count;
                genButton.imageIcon.sprite = icon;
                genButton.transform.SetParent(contentPanel);
                GameController.Instance().cowButtons.Add(newButton);
            }
        }
Пример #9
0
        // Menu for current player status, cash & name
        private void PlayerInfo(int windowID)
        {
            GUI.contentColor = backgroundColor;

            GUI.Label(new Rect(20, 25, 150, 30), GameController.Instance().player.name, customTextStyle);
            GUI.Label(new Rect(20, 60, 150, 30), "Cash: € " + GameController.Instance().player.cash, customTextStyle);

            SetHealth(0);
            SetHappiness(0);

            if (GUI.Button(new Rect(260, 33, 180, 53), "", buttonSupplies))
            {
                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                GameController.Instance().globalPlayerUI   = false;
                GameController.Instance().globalSuppliesUI = true;
            }
        }
Пример #10
0
 void Start()
 {
     try
     {
         if (GameController.Instance().newGame)
         {
             InitNewGame();
         }
         else
         {
             LoadGame();
         }
     }
     catch (UnityException e)
     {
         Debug.Log("Error - " + e);
     }
 }
Пример #11
0
        private void LoadSaveInfo(int windowID)
        {
            SetHealth(0);
            SetHappiness(0);

            GUI.contentColor = backgroundColor;

            if (GUI.Button(new Rect(50, 30, 150, 50), "", buttonLoad))
            {
                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                GameController.Instance().Load();
            }

            if (GUI.Button(new Rect(275, 30, 150, 50), "", buttonSave))
            {
                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                GameController.Instance().Save();
            }
        }
Пример #12
0
        void OnGUI()
        {
            GUI.color = foregroundColor;

            if (GameController.Instance().martCowMenuUI)
            {
                windowRect = new Rect(Screen.width * .29f, Screen.height - 150f, 620, 100);
                windowRect = GUI.Window(0, windowRect, Menu, "Menu");
            }
            else if (GameController.Instance().globalPlayerUI)
            {
                windowRect = new Rect(Screen.width * .29f, Screen.height - 150f, 620, 100);
                windowRect = GUI.Window(0, windowRect, PlayerInfo, "Mart");
            }
            else if (GameController.Instance().globalSuppliesUI)
            {
                windowRect = new Rect(Screen.width * .29f, Screen.height - 300f, 620, 250);
                windowRect = GUI.Window(0, windowRect, BuyPlayerSupplies, "Buy Supplies");
            }
            else if (GameController.Instance().martCowBuyBidUI)
            {
                CheckScreenSize();
                windowRect = GUI.Window(0, windowRect, CowBuyBid, "Buying");
            }
            else if (GameController.Instance().martCowSellBidUI)
            {
                CheckScreenSize();
                windowRect = GUI.Window(0, windowRect, CowSellBid, "Selling");
            }
            else if (GameController.Instance().martSceneTransitionUI)
            {
                windowRect = new Rect(Screen.width * .29f, Screen.height - 150f, 620, 100);
                windowRect = GUI.Window(0, windowRect, SceneTransition, "Select");
            }

            if (timerStart)
            {
                if (!timerChecked)
                {
                    StartCoroutine(TimerDec(1));
                }
            }
        }
Пример #13
0
        private void ClearStats()
        {
            MartBidControl.biddingCow = new Cow();

            MartBidControl.currentTimer  = 0;
            MartBidControl.currentCowBid = 0;

            // Clear all buttons && re-populate list
            CreateScrollList.RemoveAllButtons();
            GameController.Instance().scrollCowList.PopulateList();

            timerStart   = false;
            timerChecked = true;
            cowInRing    = false;
            MartBidControl.biddingOver   = true;
            MartBidControl.playerBidLast = false;

            SetHealth(0);
            SetHappiness(0);
        }
Пример #14
0
        // Initialization of new game
        private void LoadGame()
        {
            // Else load player data from file
            if (GameController.Instance().loadPlayer)
            {
                // Loading from file & spawning cows by looping through loaded list of cows
                GameController.Instance().Load();

                foreach (Cow cow in GameController.Instance().cows)
                {
                    GetRandomPos();
                    // Using location variables to spawn cows & resetting current scene then spawn
                    cow.currScene = GameController.GetSceneName();
                    if (CowMaker.SpawnCow(cow, Random.Range(farmTopLeftPos.x, farmBottomRightPos.x), Random.Range(farmTopLeftPos.y, farmBottomRightPos.y), Vector3.zero) == 1)
                    {
                        cow.cowController.Wait();
                    }
                }
            }
        }
Пример #15
0
        public void Start()
        {
            int startingMoney = 25000;
            int grain         = 0;
            int hay           = 0;
            int pellet        = 0;
            int cowsBought    = 0;

            switch (GameController.Instance().gameDifficulty)
            {
            case "Easy":
                startingMoney = 35000;
                grain         = 10;
                hay           = 10;
                pellet        = 5;
                break;

            case "Normal":
                startingMoney = 20000;
                grain         = 5;
                hay           = 5;
                pellet        = 5;
                break;

            case "Hard":
                startingMoney = 10000;
                grain         = 5;
                hay           = 1;
                pellet        = 0;
                break;

            default:
                startingMoney = 25000;
                grain         = 5;
                hay           = 5;
                pellet        = 5;
                break;
            }

            GameController.Instance().player = new Farmer("Farmer", startingMoney, grain, hay, pellet, cowsBought, GameController.Instance().gameDifficulty, GameController.Instance().fxLevel);
        }
Пример #16
0
        void OnGUI()
        {
            GUI.color = foregroundColor;

            if (GameController.Instance().globalPlayerUI)
            {
                windowRect = new Rect(Screen.width * .29f, Screen.height - 150f, 620, 100);
                windowRect = GUI.Window(0, windowRect, PlayerInfo, "Farm");
            }
            else if (GameController.Instance().globalSuppliesUI)
            {
                windowRect = new Rect(Screen.width * .29f, Screen.height - 250f, 620, 200);
                windowRect = GUI.Window(0, windowRect, PlayerSupplies, "Supplies");
            }
            else if (GameController.Instance().farmCowUI&& cowGameObject != null)
            {
                windowRect = new Rect(Screen.width * .29f, Screen.height - 150f, 620, 100);
                windowRect = GUI.Window(0, windowRect, CowInfo, cow.name);
            }
            else if (GameController.Instance().farmCowMoreInfoUI&& cowGameObject != null)
            {
                windowRect = new Rect(Screen.width * .4f, Screen.height - 420f, 355, 365);
                windowRect = GUI.Window(0, windowRect, CowMoreInfo, cow.name);
            }
            else if (GameController.Instance().farmCowFeedUI&& cowGameObject != null)
            {
                windowRect = new Rect(Screen.width * .32f, Screen.height - 350f, 555, 295);
                windowRect = GUI.Window(0, windowRect, CowFeed, cow.name);
            }
            else if (GameController.Instance().loadSaveUI)
            {
                windowRect = new Rect(Screen.width * .29f, Screen.height - 150f, 620, 100);
                windowRect = GUI.Window(0, windowRect, LoadSaveInfo, "Load / Save");
            }
            else if (GameController.Instance().farmSceneTransitionUI)
            {
                windowRect = new Rect(Screen.width * .29f, Screen.height - 150f, 620, 100);
                windowRect = GUI.Window(0, windowRect, SceneTransition, "Select");
            }
        }
Пример #17
0
        // Initialization of new game
        private void InitNewGame()
        {
            GameController.Instance().cows.Clear();
            int cowAmount;

            // Check what difficulty the game is set to, set correct stats to player character
            switch (GameController.Instance().gameDifficulty)
            {
            case "Easy":
                cowAmount = 5;
                break;

            case "Normal":
                cowAmount = 3;
                break;

            case "Hard":
                cowAmount = 2;
                break;

            default:
                cowAmount = 3;
                break;
            }

            for (int i = 0; i < cowAmount; i++)
            {
                // Generate cow instance, spawn cow with location variables
                Cow cow = CowMaker.GenerateCow();
                GetRandomPos();
                // Using location variables to spawn cows
                if (CowMaker.SpawnCow(cow, Random.Range(farmTopLeftPos.x, farmBottomRightPos.x), Random.Range(farmTopLeftPos.y, farmBottomRightPos.y), Vector3.zero) == 1)
                {
                    GameController.Instance().cows.Add(cow);
                }
            }

            GameController.Instance().newGame = false;
        }
Пример #18
0
        void OnGUI()
        {
            GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), backgroundTexture);

            if (!isLoading)
            {
                GUI.Label(new Rect(Screen.width * .272f, Screen.height * .05f, Screen.width * .45f, Screen.height * .16f), "", labelPlayer);
                GUI.SetNextControlName("PlayerInput");
                // Getting player name from text field
                playerName = GUI.TextField(new Rect(0, Screen.height * .40f, Screen.width, Screen.height * .22f), playerName, textFieldStyle);
            }

            if (!isLoading)
            {
                if (GUI.Button(new Rect(Screen.width * .725f, Screen.height * .81f, Screen.width * .24f, Screen.height * .16f), "", buttonPlayStyle))
                {
                    // Now going to load new scene with new player data
                    isLoading = true;
                    GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                    GameController._instance.player = new Farmer("Farmer", 25000, 0, 0, 0, 0, GameController.Instance().gameDifficulty, GameController.Instance().fxLevel);
                    GameController.Instance().player.name = playerName;
                    GameController.Instance().newGame = true;
                    StartCoroutine(WaitFor(3));
                    backgroundTexture = backgroundLoading;
                }
            }

            if (!isLoading)
            {
                if (GUI.Button(new Rect(Screen.width * .035f, Screen.height * .82f, Screen.width * .240f, Screen.height * .13f), "", buttonBackStyle))
                {
                    // Now loading menu scene
                    GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                    StartCoroutine(WaitFor(0));
                }
            }
        }
Пример #19
0
 public void SetDifficulty()
 {
     GameController.Instance().gameDifficulty = gameObject.GetComponent <UIPopupList>().value;
 }
Пример #20
0
 public void OnChangeName()
 {
     GameController.Instance().player.name = gameObject.GetComponent <UIInput>().value;
 }
Пример #21
0
 public static void RemoveCowButton(int index)
 {
     Destroy(GameController.Instance().cowButtons[index]);
     GameController.Instance().cowButtons.RemoveAt(index);
 }
Пример #22
0
 public static void GetCowDetails(string buttonName)
 {
     GameController.Instance().cowSelected = true;
     GameController.Instance().cowIndex    = (int.Parse(buttonName) - 1);
     MartBidControl.cowList.SetActive(false);
 }
Пример #23
0
 void Start()
 {
     GameController.Instance().scrollCowList = this;
     PopulateList();
 }
Пример #24
0
 public void Start()
 {
     gameObject.GetComponent <UIPopupList>().value = GameController.Instance().gameDifficulty;
 }
Пример #25
0
        private void CowBuyBid(int windowID)
        {
            GUI.contentColor = backgroundColor;

            SetHealth(MartBidControl.biddingCow.health / 100f);
            SetHappiness(MartBidControl.biddingCow.happiness / 10f);

            healthBar.transform.position    = new Vector2(windowRect.center.x + 64, healthHappinessPaddingY + 35);
            happinessBar.transform.position = new Vector2(windowRect.center.x + 64, healthHappinessPaddingY);

            if (!MartBidControl.biddingCow.gender == true)
            {
                cowGender = "Female";

                if (MartBidControl.biddingCow.pregnant == true)
                {
                    cowPregnant = "Yes";
                }
            }
            else
            {
                cowGender = "Male";
                MartBidControl.biddingCow.pregnant = false;
                cowPregnant = "No";
            }

            GUI.Label(new Rect(110, 20, 150, 30), GameController.Instance().player.name, customTextStyle);
            GUI.Label(new Rect(90, 50, 150, 30), "Cash: € " + GameController.Instance().player.cash, customTextStyle);
            GUI.Label(new Rect(110, 90, 150, 30), "Going In: " + MartBidControl.currentTimer + "s", customTextStyle);
            GUI.Label(new Rect(25, 135, 80, 25), "", labelAge);
            GUI.Label(new Rect(132, 132, 150, 30), "" + MartBidControl.biddingCow.age, customTextStyle);
            GUI.Label(new Rect(25, 170, 90, 25), "", labelBreed);
            GUI.Label(new Rect(132, 170, 150, 30), "" + MartBidControl.biddingCow.breed, customTextStyle);
            GUI.Label(new Rect(25, 205, 110, 30), "", labelHappiness);
            GUI.Label(new Rect(25, 240, 90, 25), "", labelHealth);
            GUI.Label(new Rect(25, 275, 110, 30), "", labelPregnant);
            GUI.Label(new Rect(150, 275, 150, 30), "" + cowPregnant, customTextStyle);
            GUI.Label(new Rect(25, 313, 90, 25), "", labelGender);
            GUI.Label(new Rect(132, 313, 150, 30), "" + cowGender, customTextStyle);
            GUI.Label(new Rect(25, 350, 90, 30), "", labelWeight);
            GUI.Label(new Rect(132, 350, 150, 30), "" + MartBidControl.biddingCow.weight + " KG", customTextStyle);

            GUI.Label(new Rect(65, 400, 150, 30), "Current Bid: € " + MartBidControl.currentCowBid, customTextStyle);

            if (!cowInRing)
            {
                if (GUI.Button(new Rect(70, 445, 170, 35), "", buttonStartBid))
                {
                    if (MartBidControl.cowsInMart.Count != 0)
                    {
                        GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                        GameController.Instance().cowIndex = Random.Range(0, MartBidControl.cowsInMart.Count - 1);
                        MartBidControl.biddingCow = MartBidControl.cowsInMart[GameController.Instance().cowIndex];
                        StartBidding();
                    }
                }
            }

            if (!MartBidControl.playerBidLast && cowInRing)
            {
                if (GameController.Instance().player.cash >= MartBidControl.currentCowBid)
                {
                    if (GUI.Button(new Rect(125, 445, 80, 40), "", buttonBid))
                    {
                        GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                        BidOnCow(null, MartBidControl.currentCowBid += 500);
                        MartBidControl.playerBidLast = true;
                        LookAtRing();
                    }
                }
            }

            if (!cowInRing)
            {
                if (GUI.Button(new Rect(295, 450, 35, 35), "", buttonX))
                {
                    GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                    GameController.Instance().martCowMenuUI   = true;
                    GameController.Instance().martCowBuyBidUI = false;
                    joyStick.gameObject.SetActive(true);
                    cameraControl.FollowPlayer();
                }
            }
        }
Пример #26
0
        private void CowFeed(int windowID)              // Finish Me!
        {
            GUI.contentColor = backgroundColor;

            SetHealth(cow.health / 100f);
            SetHappiness(cow.happiness / 10f);

            GUI.Label(new Rect(30, 215, 110, 30), "", labelHappiness);
            GUI.Label(new Rect(30, 250, 90, 25), "", labelHealth);

            healthBar.transform.position    = new Vector2(windowRect.center.x - 30, 120);
            happinessBar.transform.position = new Vector2(windowRect.center.x - 30, 85);

            GUI.Label(new Rect(85, 40, 150, 30), "Grain", customTextStyle);
            GUI.Label(new Rect(245, 40, 150, 30), "Hay", customTextStyle);
            GUI.Label(new Rect(380, 40, 150, 30), "Pellets", customTextStyle);

            if (GUI.Button(new Rect(80, 75, 75, 75), "", buttonGrain))
            {
                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);

                if (GameController.Instance().player.grain >= 1)
                {
                    GameController.Instance().player.grain--;
                    FeedCow(1);
                }
            }

            if (GUI.Button(new Rect(230, 75, 75, 75), "", buttonHay))
            {
                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);

                if (GameController.Instance().player.hay >= 1)
                {
                    GameController.Instance().player.hay--;
                    FeedCow(2);
                }
            }

            if (GUI.Button(new Rect(380, 75, 75, 75), "", buttonPellets))
            {
                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);

                if (GameController.Instance().player.pellet >= 1)
                {
                    GameController.Instance().player.pellet--;
                    FeedCow(3);
                }
            }

            GUI.Label(new Rect(110, 160, 150, 30), "" + GameController.Instance().player.grain, customTextStyle);
            GUI.Label(new Rect(260, 160, 150, 30), "" + GameController.Instance().player.hay, customTextStyle);
            GUI.Label(new Rect(410, 160, 150, 30), "" + GameController.Instance().player.pellet, customTextStyle);

            if (GUI.Button(new Rect(475, 230, 50, 50), "", buttonX))
            {
                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                GameController.Instance().farmCowMoreInfoUI = true;
                GameController.Instance().farmCowFeedUI     = false;
            }
        }
Пример #27
0
        private void CowSellBid(int windowID)
        {
            GUI.contentColor = backgroundColor;

            if (!GameController.Instance().cowSelected)
            {
                GUI.Label(new Rect(70, 30, 210, 45), "", labelSelect);
            }

            scrollCowList.transform.position = new Vector2(windowRect.center.x, scrollListPaddingY);

            if (GameController.Instance().cowSelected&& GameController.Instance().cows.Count != 0)
            {
                SetHealth(GameController.Instance().cows[GameController.Instance().cowIndex].health / 100f);
                SetHappiness(GameController.Instance().cows[GameController.Instance().cowIndex].happiness / 10f);

                healthBar.transform.position    = new Vector2(windowRect.center.x + 64, healthHappinessPaddingY + 35);
                happinessBar.transform.position = new Vector2(windowRect.center.x + 64, healthHappinessPaddingY);

                if (!GameController.Instance().cows[GameController.Instance().cowIndex].gender == true)
                {
                    cowGender = "Female";

                    if (GameController.Instance().cows[GameController.Instance().cowIndex].pregnant == true)
                    {
                        cowPregnant = "Yes";
                    }
                }
                else
                {
                    cowGender = "Male";
                    GameController.Instance().cows[GameController.Instance().cowIndex].pregnant = false;
                    cowPregnant = "No";
                }

                GUI.Label(new Rect(110, 20, 150, 30), GameController.Instance().player.name, customTextStyle);
                GUI.Label(new Rect(90, 50, 150, 30), "Cash: € " + GameController.Instance().player.cash, customTextStyle);
                GUI.Label(new Rect(110, 90, 150, 30), "Going In: " + MartBidControl.currentTimer + "s", customTextStyle);
                GUI.Label(new Rect(25, 135, 80, 25), "", labelAge);
                GUI.Label(new Rect(132, 132, 150, 30), "" + GameController.Instance().cows[GameController.Instance().cowIndex].age, customTextStyle);
                GUI.Label(new Rect(25, 170, 90, 25), "", labelBreed);
                GUI.Label(new Rect(132, 170, 150, 30), "" + GameController.Instance().cows[GameController.Instance().cowIndex].breed, customTextStyle);
                GUI.Label(new Rect(25, 205, 110, 30), "", labelHappiness);
                GUI.Label(new Rect(25, 240, 90, 25), "", labelHealth);
                GUI.Label(new Rect(25, 275, 110, 30), "", labelPregnant);
                GUI.Label(new Rect(150, 275, 150, 30), "" + cowPregnant, customTextStyle);
                GUI.Label(new Rect(25, 313, 90, 25), "", labelGender);
                GUI.Label(new Rect(132, 313, 150, 30), "" + cowGender, customTextStyle);
                GUI.Label(new Rect(25, 350, 90, 30), "", labelWeight);
                GUI.Label(new Rect(132, 350, 150, 30), "" + GameController.Instance().cows[GameController.Instance().cowIndex].weight + " KG", customTextStyle);

                GUI.Label(new Rect(65, 400, 150, 30), "Current Bid: € " + MartBidControl.currentCowBid, customTextStyle);

                if (!cowInRing)
                {
                    if (GUI.Button(new Rect(105, 445, 120, 40), "", buttonSell))
                    {
                        if (GameController.Instance().cows.Count != 0)
                        {
                            if (!cowInRing)
                            {
                                GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                                MartBidControl.biddingCow = GameController.Instance().cows[GameController.Instance().cowIndex];
                                CowMaker.SpawnCow(MartBidControl.biddingCow, 109f, 137f, Vector3.zero);
                                StartBidding();
                                CreateScrollList.RemoveCowButton(GameController.Instance().cowIndex);
                            }
                        }
                    }
                }
            }

            if (!cowInRing)
            {
                if (GUI.Button(new Rect(295, 450, 35, 35), "", buttonX))
                {
                    GetComponent <AudioSource>().PlayOneShot(buttonSound, 0.6f);
                    if (GameController.Instance().cowSelected)
                    {
                        GameController.Instance().cowSelected = false;
                        MartBidControl.cowList.SetActive(true);
                        SetHealth(0f);
                        SetHappiness(0f);
                    }
                    else
                    {
                        GameController.Instance().martCowMenuUI    = true;
                        GameController.Instance().martCowSellBidUI = false;
                        MartBidControl.cowList.SetActive(false);
                        joyStick.gameObject.SetActive(true);
                        cameraControl.FollowPlayer();
                    }
                }
            }
        }