Beispiel #1
0
        void Start()
        {
            try
            {
                MartBidControl.bidderList = new List <Bidder>();

                for (int i = 0; i < Random.Range(3, 5); i++)
                {
                    Bidder newBidder = BidderMaker.SpawnBidder("", martTopRight, martBottomLeft);
                    MartBidControl.bidderList.Add(newBidder);
                }

                for (int i = 0; i < Random.Range(10, 15); i++)
                {
                    Cow newCow = CowMaker.GenerateCow();
                    CowMaker.SpawnCow(newCow, Random.Range(martTopLeftOutside.x, martBottomRightOutside.x), Random.Range(martTopLeftOutside.y, martBottomRightOutside.y), forward);
                }

                MartBidControl.cowsInMart = new List <Cow>();

                // Spawn new cows in the mart & store them in a list
                for (int i = 0; i < Random.Range(5, 8); i++)
                {
                    Cow newCow = CowMaker.GenerateCow();
                    if (CowMaker.SpawnCow(newCow, Random.Range(bottomLeft.x, topRight.x), Random.Range(bottomLeft.y, topRight.y), forward) == 1)
                    {
                        try
                        {
                            newCow.cowController.Wait();
                            MartBidControl.cowsInMart.Add(newCow);
                        }
                        catch (System.Exception error)
                        {
                            Debug.Log("Error: " + error);
                        }
                    }
                }
            }
            catch (UnityException e)
            {
                Debug.Log("Error - " + e);
            }
        }
Beispiel #2
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();
                    }
                }
            }
        }
Beispiel #3
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;
        }
Beispiel #4
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();
                    }
                }
            }
        }