public void AddMiningCard(OreData oreData)
        {
            GameObject card = leftCard;

            if (oreData.title == siliconOre.title)
            {
                card = leftCard;
                //leftOre = GetOre(oreData);
            }
            else if (oreData.title == ironOre.title)
            {
                card = middleCard;
            }
            else if (oreData.title == titainumOre.title)
            {
                card = rightCard;
            }
            card.SetActive(true);
            card.transform.GetChild(0).GetComponent <TMP_Text>().text = oreData.title;
            card.transform.GetChild(1).GetComponent <Image>().sprite  = oreData.panelImage;

            card.transform.GetChild(5).GetComponent <Button>().onClick.RemoveAllListeners();
            card.transform.GetChild(5).GetComponent <Button>().onClick.AddListener(delegate() { MineButton(oreData); });
            SetCardValues(card, oreData);
        }
 public Ore(OreData _oreData)
 {
     data       = _oreData;
     rate       = _oreData.rateStart;
     rateCap    = data.rateCap;
     rateBottom = data.RateBottom;
     amount     = 0;
     staffed    = 0;
 }
        void SetCardValues(GameObject card, OreData oreData)
        {
            card.transform.GetChild(0).GetComponent <TMP_Text>().text = oreData.title;
            Ore ore = GetOre(oreData);

            card.transform.GetChild(2).GetChild(2).GetComponent <TMP_Text>().text = ore.Staffed.ToString();
            card.transform.GetChild(3).GetComponent <TMP_Text>().text             = ore.Amount.ToString();
            card.transform.GetChild(4).GetComponent <TMP_Text>().text             = "$" + ore.Rate.ToString("F2");
        }
Example #4
0
 void LoadOre(OreData oreData)
 {
     if (shipStatus == 2 && shipStorage < shipCap)
     {
         int shipSpace = shipCap - shipStorage;
         (shipInventory, shipSpace) = gameManager.oreManager.LoadOre(oreData, shipInventory, shipSpace);
         shipStorage = shipCap - shipSpace;
     }
     else if (shipStatus != 2)
     {
         gameManager.textManager.SendMessageToChat("Ship not on mars", Message.MessageType.info);
     }
     ClearScreen();
     WriteToScreen();
 }
        public void Mine(OreData oreData, int growth)
        {
            Ore ore = GetOre(oreData);

            if (storage + growth <= capacity)
            {
                storage += growth;
                ore.MineOre(growth);
            }
            else if (storage + growth > capacity)
            {
                ore.MineOre(capacity - storage);
                capacity = storage;
            }
        }
        public void AddStaff(OreData oreData)
        {
            Ore ore = GetOre(oreData);

            if (isAddingStaff && drillSpare > 0 && gameManager.popSpare > 0)
            {
                ore.AddStaff(true);
                drillSpare--;
                gameManager.popSpare--;
            }
            else if (!isAddingStaff && ore.Staffed > 0)
            {
                ore.AddStaff(false);
                drillSpare++;
                gameManager.popSpare++;
            }
        }
        public Ore GetOre(OreData oreData)
        {
            Ore ore = null;

            for (int i = 0; i < ores.Count; i++)
            {
                if (oreData.title == ores[i].data.title)
                {
                    ore = ores[i];
                }
            }
            if (ore != null)
            {
                return(ore);
            }
            return(null);
        }
 public (List <ShipItem>, int) LoadOre(OreData oreData, List <ShipItem> shipInventory, int shipSpace)
 {
     for (int i = 0; i < shipInventory.Count; i++)
     {
         if (shipInventory[i].data.resource == CommodityData.Resource.Ore && shipInventory[i].data.type == CommodityData.Type.Resource)
         {
             if (oreData == null || shipInventory[i].data.OreData == oreData)
             {
                 Ore ore = GetOre(shipInventory[i].data.OreData);
                 if (ore != null)
                 {
                     if (shipSpace <= 0)
                     {
                         break;
                     }
                     else if (ore.Amount <= shipSpace)
                     {
                         shipSpace -= ore.Amount;
                         shipInventory[i].AddAmount(ore.Amount);
                         storage -= ore.Amount;
                         gameManager.textManager.SendMessageToChat(ore.Amount + " " + ore.data.title + " Loaded into ship", Message.MessageType.info);
                         ore.LoadOre(ore.Amount);
                     }
                     else
                     {
                         shipInventory[i].AddAmount(shipSpace);
                         storage -= shipSpace;
                         gameManager.textManager.SendMessageToChat(shipSpace + " " + ore.data.title + " Loaded into ship", Message.MessageType.info);
                         ore.LoadOre(shipSpace);
                         shipSpace = 0;
                         break;
                     }
                 }
             }
         }
     }
     return(shipInventory, shipSpace);
 }
Example #9
0
 public void LoadOreButton(OreData oreData)
 {
     LoadOre(oreData);
 }
        public void CreateOre(OreData oreData)
        {
            Ore newOre = new Ore(oreData);

            ores.Add(newOre);
        }
 public void SellOre(OreData oreData, int amount)
 {
     gameManager.money += Mathf.RoundToInt(GetOre(oreData).SellOre(rateAmountInterval, amount, gameManager.textManager));
 }
 public void MineButton(OreData oreData)
 {
     Mine(oreData, 1);
 }