Exemplo n.º 1
0
    private void Start()
    {
        _image.sprite = Resources.Load <Sprite>("Sprites/cost_upgrade");

        _tooltipTrigger.EnableToolTip(true);
        _tooltipTrigger.SetToolTipText("Cost Upgrade:   " + UpgradeCost.ToString(), "Reduces total cost of leveling up by " + (1.0f - amount).ToString("P"));
    }
Exemplo n.º 2
0
    public void UpgradeClick()
    {
        if (_playerWallet.Coins < Int32.Parse(_upgradeCost))
        {
            HighlightedImage.color = Color.red;
            NotEnoughCashText.gameObject.SetActive(true);
            StartCoroutine(SetBack());
            return;
        }

        HighlightedImage.color = Color.cyan;
        _playerWallet.SpendCoins(Int32.Parse(_upgradeCost));

        if (ButtonValue == "WEAPON")
        {
            _upgradeable.SetLevel(_upgradeable.GetLevel() + 1);
            _upgradeable.SetAttack(Int32.Parse(UpgradeCost.GetStats()[_upgradeable.GetLevel()].ToString()));
        }
        else if (ButtonValue == "DEFENCE")
        {
            _playerAttack.HealthLevel += 1;
            _playerAttack.Defence      = Int32.Parse(UpgradeCost.GetDefenceStats()[_playerAttack.HealthLevel].ToString());
        }

        StartCoroutine(SetBack());
    }
Exemplo n.º 3
0
        internal void OnDayEnding(object sender, DayEndingEventArgs e)
        {
            CheckLetterStatus();
            AddLetterIfNeeded();
            Monitor.Log("Day ending");
            if (Data.GetLevel() >= 2) //run these checks before we check for upgrades
            {
                Monitor.Log("Watering the Greenhouse", LogLevel.Info);
                WaterGreenHouse();
            }
            if (Data.GetLevel() >= 3)
            {
                Monitor.Log("Watering entire farm", LogLevel.Info);
                WaterFarm();
            }
            if (!Data.FinalUpgrade)
            {
                var greenhouse = Game1.getFarm().buildings.Where(x => x.buildingType == "Greenhouse" && x.daysUntilUpgrade > 1).FirstOrDefault();
                if (greenhouse != null && !Data.IsUpgrading)
                {
                    UpgradeCost cost = Config.DifficultySettings.Find(x => x.Difficulty == difficulty);
                    greenhouse.daysUntilUpgrade.Value += (Data.GetLevel()) switch
                    {
                        0 => cost.FirstUpgrade.DaysToConstruct - 1,
                        1 => cost.SecondUpgrade.DaysToConstruct - 1,
                        2 => cost.FinalUpgrade.DaysToConstruct - 1,
                        _ => 0
                    };

                    Data.IsUpgrading = true;
                }
                greenhouse = Game1.getFarm().buildings.Where(x => x.buildingType == "Greenhouse" && x.daysUntilUpgrade == 1).FirstOrDefault();
                if (greenhouse != null)
                {
                    Monitor.Log("Greenhouse Upgrade completed, moving to next level", LogLevel.Info);
                    greenhouse.daysUntilUpgrade.Value = 0;
                    if (!Data.FirstUpgrade)
                    {
                        Data.FirstUpgrade = true;
                    }
                    else if (!Data.SecondUpgrade)
                    {
                        Data.SecondUpgrade = true;
                    }
                    else if (!Data.FinalUpgrade)
                    {
                        Data.FinalUpgrade = true;
                    }
                    else
                    {
                        Monitor.Log("Tried to Upgrade sprinklers while all upgrades already completed", LogLevel.Error);
                    }
                    Data.IsUpgrading = false;
                }
            }
        }
Exemplo n.º 4
0
        public static UpgradeCost LoadUpgradeCost(string path)
        {
            if (!File.Exists(path))
            {
                return(null);
            }
            UpgradeCost cost = new UpgradeCost();

            String[] line;
            line          = File.ReadAllLines(path);
            cost.id       = int.Parse(line[0].Split(',')[0]);
            cost.type     = line[0].Split(',')[1];
            cost.NewLevel = float.Parse(line[0].Split(',')[2]);
            for (int i = 2; i < line.Length; i++)
            {
                String[] split = line[i].Split(',');
                foreach (String s in split)
                {
                    s.Replace(" ", "");
                }
                if (split[0].ToLower().Contains("metapoints"))
                {
                    cost.MetaPointCost += int.Parse(split[1]);
                }
                if (split[0].ToLower().Contains("money"))
                {
                    cost.MoneyRequired += int.Parse(split[1]);
                }
                else
                {
                    if (MyDefinitionId.TryParse(split[0], split[1], out MyDefinitionId id))
                    {
                        if (cost.itemsRequired.ContainsKey(id))
                        {
                            cost.itemsRequired[id] += int.Parse(split[2]);
                        }
                        else
                        {
                            cost.itemsRequired.Add(id, int.Parse(split[2]));
                        }
                    }
                }
            }
            switch (cost.type.ToLower())
            {
            case "slots":
                slotUpgrades.Add(cost.id, cost);
                break;

            default:
                AlliancePlugin.Log.Error("Upgrade file has no defined type");
                break;
            }
            return(cost);
        }
Exemplo n.º 5
0
Arquivo: Tower.cs Projeto: bluwy/QTD
        /// <summary>
        /// Update tower's relevant components depending on the level
        /// </summary>
        protected virtual void UpdateStats()
        {
            GetComponent <CircleCollider2D>().radius = AttackRange;
            _rangeCircle.transform.localScale        = new Vector3(AttackRange, AttackRange, AttackRange);
            _sellText.text = SellPrice.ToString();
            _upgradeButton.gameObject.SetActive(!IsMaxLevel);

            if (!IsMaxLevel)
            {
                _upgradeText.text = UpgradeCost.ToString();
            }
        }
Exemplo n.º 6
0
 private void ShowInformation()
 {
     GameManager.Instance.ui.SetInformationPanelTowers(new string[]
     {
         transform.name,
         ModelNumber.ToString(),
         "N/a",
         Energy.ToString(),
         Speed.ToString(),
         UpgradeCost.ToString(),
         Name
     });
 }
Exemplo n.º 7
0
        private BluePrint GetBluePrint(int level)
        {
            string desc;
            Dictionary <int, int> buildMats;
            int         money;
            UpgradeCost cost = Config.DifficultySettings.Find(x => x.Difficulty == difficulty);
            int         days;

            if (level == 1)
            {
                desc      = "Automated Sprinklers on the ceiling of your greenhouse, runs every morning";
                money     = cost.FirstUpgrade.Gold;
                buildMats = BuildMaterials1;
                days      = cost.FirstUpgrade.DaysToConstruct;
            }
            else if (level == 2)
            {
                desc      = "Automated Sprinklers on the ceiling of your greenhouse, Runs every morning and night";
                money     = cost.SecondUpgrade.Gold;
                buildMats = BuildMaterials2;
                days      = cost.SecondUpgrade.DaysToConstruct;
            }
            else
            {
                desc      = "Hidden underground sprinklers all over the farm, runs morning and night";
                money     = cost.FinalUpgrade.Gold;
                buildMats = BuildMaterials3;
                days      = cost.FinalUpgrade.DaysToConstruct;
            }
            return(new BluePrint("Greenhouse")
            {
                displayName = "Sprinkler System Upgrade",
                description = desc,
                moneyRequired = money,
                nameOfBuildingToUpgrade = "Greenhouse",
                itemsRequired = buildMats,
                daysToConstruct = days,
                maxOccupants = MaxOccupantsID,
                blueprintType = "Upgrades"
            });
        }
Exemplo n.º 8
0
        private BluePrint GetBluePrint(int level)
        {
            string desc;
            Dictionary <int, int> buildMats;
            int         money;
            UpgradeCost cost = Config.DifficultySettings.Find(x => x.Difficulty == difficulty);

            if (level == 1)
            {
                desc      = I18n.CarpenterShop_FirstUpgradeDescription();
                money     = cost.FirstUpgrade.Gold;
                buildMats = BuildMaterials1;
            }
            else if (level == 2)
            {
                desc      = I18n.CarpenterShop_SecondUpgradeDescription();
                money     = cost.SecondUpgrade.Gold;
                buildMats = BuildMaterials2;
            }
            else
            {
                desc      = I18n.CarpenterShop_FinalUpgradeDescription();
                money     = cost.FinalUpgrade.Gold;
                buildMats = BuildMaterials3;
            }
            return(new BluePrint("Greenhouse")
            {
                displayName = I18n.CarpenterShop_BluePrintName(),
                description = desc,
                moneyRequired = money,
                nameOfBuildingToUpgrade = "Greenhouse",
                itemsRequired = buildMats,
                maxOccupants = MaxOccupantsID,
                blueprintType = "Upgrades",
                daysToConstruct = 2
            });
        }
 private void Start()
 {
     _image.sprite = Resources.Load <Sprite>("Sprites/damage_upgrade");
     _tooltipTrigger.EnableToolTip(true);
     _tooltipTrigger.SetToolTipText("Damage Upgrade:   " + UpgradeCost.ToString(), "Increases total damage by " + (amount - 1.0f).ToString("P"));
 }
Exemplo n.º 10
0
 private void Start()
 {
     _image.sprite = Resources.Load <Sprite>("Sprites/mana_upgrade");
     _tooltipTrigger.EnableToolTip(true);
     _tooltipTrigger.SetToolTipText("Mana Upgrade:   " + UpgradeCost.ToString(), "Reduces total mana usage by " + (1.0f - amount).ToString("P"));
 }
Exemplo n.º 11
0
    // Update is called once per frame
    void Update()
    {
        if (!GameOverScreen)
        {
            if (ButtonValue == "WEAPON")
            {
                _upgradeCost = UpgradeCost.GetCosts()[_upgradeable.GetLevel()].ToString();
            }
            else if (ButtonValue == "DEFENCE")
            {
                _upgradeCost = UpgradeCost.GetDefenceUpgrades()[_playerAttack.HealthLevel].ToString();
            }

            CostText.text = _upgradeCost;
        }


        if (Highlighted)
        {
            if (!HighlightedImage.gameObject.activeSelf)
            {
                HighlightedImage.gameObject.SetActive(true);
            }

            if (Input.GetKeyDown(KeyCode.Return))
            {
                if (!GameOverScreen && !TitleScreen)
                {
                    UpgradeClick();
                }
                else
                {
                    if (ButtonValue == "YES")
                    {
                        StartCoroutine(ReloadScene());
                    }
                    else if (ButtonValue == "NO")
                    {
                        SceneManager.LoadScene("TitleScreen");
                    }
                    else if (ButtonValue == "TitleScreen")
                    {
                        SceneManager.LoadScene("CreditsScene");
                    }
                    else if (ButtonValue == "Play")
                    {
                        SceneManager.LoadScene("EntryCutscene");
                    }
                    else if (ButtonValue == "Controls")
                    {
                        // load control screen
                        SceneManager.LoadScene("Controls");
                    }
                }
            }
        }
        else
        {
            if (HighlightedImage.gameObject.activeSelf)
            {
                HighlightedImage.gameObject.SetActive(false);
            }
        }
    }
Exemplo n.º 12
0
        public void UnlockHangar()
        {
            if (!AlliancePlugin.config.HangarEnabled)
            {
                Context.Respond("Alliance hangar is not enabled.");
                return;
            }
            Boolean console = false;

            if (Context.Player == null)
            {
                console = true;
            }
            MyFaction fac = MySession.Static.Factions.GetPlayerFaction(Context.Player.IdentityId);

            if (fac == null)
            {
                Context.Respond("You must be in a faction to use alliance features.");
                return;
            }
            Alliance alliance = AlliancePlugin.GetAlliance(fac);

            if (alliance == null)
            {
                Context.Respond("You are not a member of an alliance.");
                return;
            }
            if (AlliancePlugin.HasFailedUpkeep(alliance))
            {
                Context.Respond("Alliance failed to pay upkeep. Upgrades disabled.");
                return;
            }
            if (!alliance.hasUnlockedHangar)
            {
                ConcurrentBag <MyGroups <MyCubeGrid, MyGridPhysicalGroupData> .Group> gridWithSubGrids = GridFinder.FindLookAtGridGroup(Context.Player.Character);


                List <MyCubeGrid> grids = new List <MyCubeGrid>();
                foreach (var item in gridWithSubGrids)
                {
                    foreach (MyGroups <MyCubeGrid, MyGridPhysicalGroupData> .Node groupNodes in item.Nodes)
                    {
                        MyCubeGrid grid = groupNodes.NodeData;



                        if (grid.Projector != null)
                        {
                            continue;
                        }

                        if (FacUtils.GetPlayersFaction(FacUtils.GetOwner(grid)) != null)
                        {
                            if (FacUtils.InSameFaction(FacUtils.GetOwner(grid), Context.Player.IdentityId))
                            {
                                if (!grids.Contains(grid))
                                {
                                    grids.Add(grid);
                                }
                            }
                        }
                        else
                        {
                            if (FacUtils.GetOwner(grid).Equals(Context.Player.Identity.IdentityId))
                            {
                                if (!grids.Contains(grid))
                                {
                                    grids.Add(grid);
                                }
                            }
                        }
                    }
                }
                //Do stuff with taking components from grid storage
                //GridCosts localGridCosts = GetComponentsAndCost(projectedGrid);
                //gridCosts.setComponents(localGridCosts.getComponents());

                UpgradeCost cost = new UpgradeCost();
                List <VRage.Game.ModAPI.IMyInventory> invents = new List <VRage.Game.ModAPI.IMyInventory>();
                foreach (MyCubeGrid grid in grids)
                {
                    invents.AddList(ShipyardCommands.GetInventories(grid));
                }


                cost = ShipyardCommands.LoadUnlockCost(AlliancePlugin.path + "//HangarUnlockCost.txt");
                if (cost != null)
                {
                    if (cost.MetaPointCost > 0)
                    {
                        if (alliance.CurrentMetaPoints < cost.MetaPointCost)
                        {
                            Context.Respond("Cannot afford the meta point cost of " + cost.MetaPointCost);
                            return;
                        }
                    }
                    if (cost.MoneyRequired > 0)
                    {
                        if (EconUtils.getBalance(Context.Player.IdentityId) >= cost.MoneyRequired)
                        {
                            if (ShipyardCommands.ConsumeComponents(invents, cost.itemsRequired, Context.Player.SteamUserId))
                            {
                                alliance.CurrentMetaPoints -= cost.MetaPointCost;
                                EconUtils.takeMoney(Context.Player.IdentityId, cost.MoneyRequired);
                                alliance.hasUnlockedHangar = true;
                                HangarData hangar = alliance.LoadHangar();

                                AlliancePlugin.SaveAllianceData(alliance);
                                ShipyardCommands.SendMessage("[Alliance Hangar]", "Unlocking the hangar. You were charged: " + String.Format("{0:n0}", cost.MoneyRequired) + " and components taken", Color.Green, (long)Context.Player.SteamUserId);
                            }
                        }
                        else
                        {
                            ShipyardCommands.SendMessage("[Alliance Hangar]", "You cant afford the upgrade price of: " + String.Format("{0:n0}", cost.MoneyRequired), Color.Red, (long)Context.Player.SteamUserId);
                        }
                    }
                    else
                    {
                        if (ShipyardCommands.ConsumeComponents(invents, cost.itemsRequired, Context.Player.SteamUserId))
                        {
                            alliance.CurrentMetaPoints -= cost.MetaPointCost;
                            alliance.hasUnlockedHangar  = true;
                            HangarData hangar = alliance.LoadHangar();

                            AlliancePlugin.SaveAllianceData(alliance);
                        }
                    }
                }
                else
                {
                    Context.Respond("Error loading upgrade details.");
                    return;
                }
            }
        }
Exemplo n.º 13
0
        public void Upgrade(Boolean upgrade = false)
        {
            if (!AlliancePlugin.config.HangarEnabled)
            {
                Context.Respond("Hangar not enabled.");
                return;
            }
            if (Context.Player != null)
            {
                IMyFaction faction = FacUtils.GetPlayersFaction(Context.Player.IdentityId);
                if (faction == null)
                {
                    ShipyardCommands.SendMessage("[Hangar]", " You arent in a faction.", Color.Red, (long)Context.Player.SteamUserId);
                    return;
                }
                Alliance alliance = AlliancePlugin.GetAlliance(faction as MyFaction);
                if (alliance == null)
                {
                    Context.Respond("You are not a member of an alliance with an unlocked shipyard.");
                    return;
                }
                if (AlliancePlugin.HasFailedUpkeep(alliance))
                {
                    Context.Respond("Alliance failed to pay upkeep. Upgrades disabled.");
                    return;
                }
                if (!alliance.hasUnlockedHangar)
                {
                    ShipyardCommands.SendMessage("[Alliance Hangar]", "To unlock use !ah unlock", Color.Cyan, (long)Context.Player.SteamUserId);
                    return;
                }
                HangarData  hangar = alliance.LoadHangar();
                UpgradeCost cost   = new UpgradeCost();
                if (!upgrade)
                {
                    ShipyardCommands.SendMessage("[Alliance Hangar]", "To upgrade use !ah upgrade true ,while looking at an owned grid.", Color.Cyan, (long)Context.Player.SteamUserId);
                    StringBuilder sb = new StringBuilder();


                    try
                    {
                        cost = slotUpgrades[hangar.SlotUpgradeNum += 1];
                    }
                    catch (Exception ex)
                    {
                        Context.Respond("Cannot upgrade any further as there are no more defined upgrade files.");
                        return;
                    }
                    if (cost != null)
                    {
                        if (cost.MoneyRequired > 0)
                        {
                            ShipyardCommands.SendMessage("[Alliance Hangar]", "SC Cost for next slot upgrade " + String.Format("{0:n0}", cost.MoneyRequired), Color.Cyan, (long)Context.Player.SteamUserId);
                        }
                        if (cost.MetaPointCost > 0)
                        {
                            ShipyardCommands.SendMessage("[Alliance Hangar]", "Metapoint cost for next slot upgrade " + cost.MetaPointCost, Color.Cyan, (long)Context.Player.SteamUserId);
                        }
                        sb.AppendLine("Items required.");
                        foreach (KeyValuePair <MyDefinitionId, int> id in cost.itemsRequired)
                        {
                            sb.AppendLine(id.Key.ToString() + " - " + id.Value);
                        }
                        Context.Respond(sb.ToString());
                    }
                }
                else
                {
                    ConcurrentBag <MyGroups <MyCubeGrid, MyGridMechanicalGroupData> .Group> gridWithSubGrids = GridFinder.FindLookAtGridGroupMechanical(Context.Player.Character);


                    List <MyCubeGrid> grids = new List <MyCubeGrid>();
                    foreach (var item in gridWithSubGrids)
                    {
                        foreach (MyGroups <MyCubeGrid, MyGridMechanicalGroupData> .Node groupNodes in item.Nodes)
                        {
                            MyCubeGrid grid = groupNodes.NodeData;



                            if (grid.Projector != null)
                            {
                                continue;
                            }

                            if (FacUtils.GetPlayersFaction(FacUtils.GetOwner(grid)) != null)
                            {
                                if (FacUtils.InSameFaction(FacUtils.GetOwner(grid), Context.Player.IdentityId))
                                {
                                    if (!grids.Contains(grid))
                                    {
                                        grids.Add(grid);
                                    }
                                }
                            }
                            else
                            {
                                if (FacUtils.GetOwner(grid).Equals(Context.Player.Identity.IdentityId))
                                {
                                    if (!grids.Contains(grid))
                                    {
                                        grids.Add(grid);
                                    }
                                }
                            }
                        }
                    }
                    List <VRage.Game.ModAPI.IMyInventory> invents = new List <VRage.Game.ModAPI.IMyInventory>();
                    foreach (MyCubeGrid grid in grids)
                    {
                        invents.AddList(ShipyardCommands.GetInventories(grid));
                    }

                    if (hangar.SlotsAmount >= AlliancePlugin.config.MaxHangarSlots)
                    {
                        Context.Respond("Cannot upgrade any further");
                        return;
                    }

                    try
                    {
                        cost = slotUpgrades[hangar.SlotUpgradeNum += 1];
                    }
                    catch (Exception)
                    {
                        Context.Respond("Cannot upgrade any further as there are no more defined upgrade files.");
                        return;
                    }
                    if (cost != null)
                    {
                        if (cost.MetaPointCost > 0)
                        {
                            if (alliance.CurrentMetaPoints < cost.MetaPointCost)
                            {
                                Context.Respond("Cannot afford the meta point cost of " + cost.MetaPointCost);
                                return;
                            }
                        }
                        if (cost.MoneyRequired > 0)
                        {
                            if (EconUtils.getBalance(Context.Player.IdentityId) >= cost.MoneyRequired)
                            {
                                if (ShipyardCommands.ConsumeComponents(invents, cost.itemsRequired, Context.Player.SteamUserId))
                                {
                                    alliance.CurrentMetaPoints -= cost.MetaPointCost;
                                    EconUtils.takeMoney(Context.Player.IdentityId, cost.MoneyRequired);
                                    hangar.SlotsAmount = (int)cost.NewLevel;
                                    hangar.SlotUpgradeNum++;
                                    hangar.SaveHangar(alliance);
                                    AlliancePlugin.SaveAllianceData(alliance);
                                    ShipyardCommands.SendMessage("[Alliance Hangar]", "Upgrading slots. You were charged: " + String.Format("{0:n0}", cost.MoneyRequired), Color.LightBlue, (long)Context.Player.SteamUserId);
                                }
                            }
                            else
                            {
                                ShipyardCommands.SendMessage("[Alliance Hangar]", "You cant afford the upgrade price of: " + String.Format("{0:n0}", cost.MoneyRequired), Color.Red, (long)Context.Player.SteamUserId);
                            }
                        }
                        else
                        {
                            if (ShipyardCommands.ConsumeComponents(invents, cost.itemsRequired, Context.Player.SteamUserId))
                            {
                                alliance.CurrentMetaPoints -= cost.MetaPointCost;
                                hangar.SlotsAmount          = (int)cost.NewLevel;
                                hangar.SlotUpgradeNum++;
                                hangar.SaveHangar(alliance);
                                AlliancePlugin.SaveAllianceData(alliance);
                            }
                        }
                    }
                    else
                    {
                        Context.Respond("Error loading upgrade details.");
                        return;
                    }
                }
            }
        }