Esempio n. 1
0
 public void NextTurn()
 {
     if (CheckObjective())
     {
         UIManager.SetText("GameFinishedText", "Good job!");
         UIManager.ToggleCanvasGroup("DialogWindows", true);
     }
     else
     {
         CurrentSales = new Money();
         CurrentSales.AddResource(ResourceType.BLUE, UnityEngine.Random.Range(1000, 5000));
         CurrentSales.AddResource(ResourceType.GREEN, UnityEngine.Random.Range(500, 4000));
         CurrentSales.AddResource(ResourceType.ORANGE, UnityEngine.Random.Range(250, 2500));
         CurrentSales.AddResource(ResourceType.PINK, UnityEngine.Random.Range(100, 2000));
         CurrentSales.AddResource(ResourceType.PURPLE, UnityEngine.Random.Range(100, 2000));
         CurrentSales.AddResource(ResourceType.RED, UnityEngine.Random.Range(50, 1500));
         ShowSales();
         ShowBackpack();
         ShowMovesLeft();
         if (CheckBankrupt())
         {
             UIManager.SetText("GameFinishedText", "Bankrupt :(");
             UIManager.ToggleCanvasGroup("DialogWindows", true);
         }
         else if (CheckLoss())
         {
             UIManager.SetText("GameFinishedText", "The order was cancelled, you took to long :(");
             UIManager.ToggleCanvasGroup("DialogWindows", true);
         }
     }
 }
Esempio n. 2
0
    public void StartGame()
    {
        Backpack = new Money();
        Backpack.AddResource(ResourceType.GOLD, UnityEngine.Random.Range(1000, 1500));
        Objective = new Money();
        ResourceType resourceGoal = (ResourceType)UnityEngine.Random.Range(1, 7);
        int          amountGoal;

        switch (resourceGoal)
        {
        case ResourceType.BLUE:
            amountGoal = UnityEngine.Random.Range(1, 3);
            break;

        case ResourceType.GREEN:
            amountGoal = UnityEngine.Random.Range(1, 3);
            break;

        case ResourceType.ORANGE:
            amountGoal = UnityEngine.Random.Range(1, 4);
            break;

        case ResourceType.PINK:
            amountGoal = UnityEngine.Random.Range(2, 4);
            break;

        case ResourceType.PURPLE:
            amountGoal = UnityEngine.Random.Range(2, 4);
            break;

        case ResourceType.RED:
            amountGoal = UnityEngine.Random.Range(3, 5);
            break;

        default:
            amountGoal = 0;
            break;
        }
        Objective.AddResource(resourceGoal, amountGoal);
        Move = 0;

        ShowObjective();
        NextTurn();
    }
Esempio n. 3
0
    public void GameButtonClick(string value)
    {
        string[] values = value.Split(' ');
        switch (values [0])
        {
        case "Restart":
            UIManager.ToggleCanvasGroup("DialogWindows", false);
            StartGame();
            break;

        case "Sell":
            switch (values [1])
            {
            case "Blue":
                Backpack.AddResource(ResourceType.BLUE, -1);
                Backpack.AddResource(ResourceType.GOLD, CurrentSales.GetResource(ResourceType.BLUE));
                break;

            case "Green":
                Backpack.AddResource(ResourceType.GREEN, -1);
                Backpack.AddResource(ResourceType.GOLD, CurrentSales.GetResource(ResourceType.GREEN));
                break;

            case "Orange":
                Backpack.AddResource(ResourceType.ORANGE, -1);
                Backpack.AddResource(ResourceType.GOLD, CurrentSales.GetResource(ResourceType.ORANGE));
                break;

            case "Pink":
                Backpack.AddResource(ResourceType.PINK, -1);
                Backpack.AddResource(ResourceType.GOLD, CurrentSales.GetResource(ResourceType.PINK));
                break;

            case "Purple":
                Backpack.AddResource(ResourceType.PURPLE, -1);
                Backpack.AddResource(ResourceType.GOLD, CurrentSales.GetResource(ResourceType.PURPLE));
                break;

            case "Red":
                Backpack.AddResource(ResourceType.RED, -1);
                Backpack.AddResource(ResourceType.GOLD, CurrentSales.GetResource(ResourceType.RED));
                break;
            }
            Move++;
            NextTurn();
            break;

        case "Buy":
            switch (values [1])
            {
            case "Blue":
                Backpack.AddResource(ResourceType.BLUE, 1);
                Backpack.AddResource(ResourceType.GOLD, -CurrentSales.GetResource(ResourceType.BLUE));
                break;

            case "Green":
                Backpack.AddResource(ResourceType.GREEN, 1);
                Backpack.AddResource(ResourceType.GOLD, -CurrentSales.GetResource(ResourceType.GREEN));
                break;

            case "Orange":
                Backpack.AddResource(ResourceType.ORANGE, 1);
                Backpack.AddResource(ResourceType.GOLD, -CurrentSales.GetResource(ResourceType.ORANGE));
                break;

            case "Pink":
                Backpack.AddResource(ResourceType.PINK, 1);
                Backpack.AddResource(ResourceType.GOLD, -CurrentSales.GetResource(ResourceType.PINK));
                break;

            case "Purple":
                Backpack.AddResource(ResourceType.PURPLE, 1);
                Backpack.AddResource(ResourceType.GOLD, -CurrentSales.GetResource(ResourceType.PURPLE));
                break;

            case "Red":
                Backpack.AddResource(ResourceType.RED, 1);
                Backpack.AddResource(ResourceType.GOLD, -CurrentSales.GetResource(ResourceType.RED));
                break;
            }
            Move++;
            NextTurn();
            break;
        }
    }