Exemple #1
0
    public void BuyMiner()
    {
        int nbMinerInQueue = 0;
        int nbSpaceshipsInQueue = 0;
        List<ShopQueue> shopQueues = constructionQueue.GetBuildQueues();
        foreach (var shopQueue in shopQueues)
        {
            if (shopQueue.spaceshipType == SpaceshipType.Types.Mining)
                nbMinerInQueue += shopQueue.nbrInQueue;
            nbSpaceshipsInQueue += shopQueue.nbrInQueue;
        }

        // If construction queue if not full (or last queue is of same type) and player has money
        if (constructionQueue.CanBuySpaceship(SpaceshipType.Types.Mining) &&
            PlayerInventory.GetActualMoney() >= minerPrice && SpaceshipManager.Instance.GetMyMiningSpaceships().Count + nbMinerInQueue < 50 &&
            SpaceshipManager.Instance.GetMySpaceships().Count + nbSpaceshipsInQueue < maxSpaceships)
        {
            shopMenu.StartAnimation("BuyMiner");
            PlayerInventory.LooseMoney(minerPrice);
            constructionQueue.AddToQueue(SpaceshipType.Types.Mining, 1);
        }
        else
            shopMenu.StartAnimation("CantBuyMiner");
    }
Exemple #2
0
    private void OnGUI()
    {
        int displayIndex = 0;

        shopQueue     = constrQueue.GetBuildQueues();
        queuesDisplay = GetDisplayQueues();
        foreach (ConstructionQueue.ShopQueue actualQueueValue in shopQueue)
        {
            queuesDisplay[displayIndex].text = actualQueueValue.nbrInQueue.ToString();
            if (actualQueueValue.spaceshipType != SpaceshipType.Types.None)
            {
                switch (actualQueueValue.spaceshipType)
                {
                case SpaceshipType.Types.Attack:
                    queuesDisplay[displayIndex].transform.GetChild(0).GetComponent <Image>().sprite = AttackerSprite;
                    break;

                case SpaceshipType.Types.Mining:
                    queuesDisplay[displayIndex].transform.GetChild(0).GetComponent <Image>().sprite = MinerSprite;
                    break;

                case SpaceshipType.Types.Defence:
                    queuesDisplay[displayIndex].transform.GetChild(0).GetComponent <Image>().sprite = DefenderSprite;
                    break;

                case SpaceshipType.Types.None:
                    break;
                }
            }
            else
            {
                queuesDisplay[displayIndex].transform.GetChild(0).GetComponent <Image>().sprite = null;
            }
            displayIndex++;
        }
    }