Example #1
0
        public void UpgradeThisTech(BaseTechnology thisTech)
        {
            curPlayer.currentTechnologies.Find(x => x.technologyName == thisTech.technologyName).currentLevel += 1;

            if (TransitionManager.GetInstance != null && !TransitionManager.GetInstance.isNewGame && SaveData.SaveLoadManager.GetInstance != null)
            {
                SaveData.SaveLoadManager.GetInstance.SaveCurrentData();
            }
        }
Example #2
0
        public int ObtainTechUpgradePrice(BaseTechnology thisTech)
        {
            int price = 100;

            // APPLY DISCOUNTS
            price = thisTech.goldLevelRequirements[thisTech.currentLevel];

            BaseTechnologyData discountTech = PlayerGameManager.GetInstance.playerData.currentTechnologies.Find(x => x.improvedType == ResourceType.Coin && x.coinTechType == CoinTechType.IncreaseDiscount);

            int discountAmount = discountTech.bonusIncrement * discountTech.currentLevel;

            price -= discountAmount;
            return(price);
        }
    public void LoadTechStorage()
    {
        technologyStoragePrefab = (GameObject)Resources.Load("Prefabs/Technology/Tech Storage");
        curTechnologyStorage    = (GameObject)Instantiate(technologyStoragePrefab);

        if (curTechnologyStorage == null)
        {
            Debug.LogWarning("Storage not found! Check Reference");
            return;
        }

        curTechStorageData = curTechnologyStorage.GetComponent <KingdomTechnologyStorage>();
        currentTechnology  = new BaseTechnology();
        techStorageLoaded  = true;
    }
    public void AddCurrentTech()
    {
        if (curTechStorageData.technologies.Find(x => x.technologyName == currentTechnology.technologyName) != null)
        {
            int idx = curTechStorageData.technologies.FindIndex(x => x.technologyName == currentTechnology.technologyName);
            curTechStorageData.technologies[idx] = currentTechnology;
        }
        else
        {
            curTechStorageData.technologies.Add(currentTechnology);
        }

        currentTechnology = null;
        GUI.FocusControl(null);
        Save();
    }
    public void ShowTechStorageList()
    {
        GUILayout.BeginArea(new Rect(450, 12, leftPanelWidth, 300));

        EditorGUILayout.BeginVertical();
        techStorageList = EditorGUILayout.BeginScrollView(techStorageList, new GUIStyle("RL Background"), GUILayout.Width(250), GUILayout.Height(position.height - 350));
        for (int i = 0; i < curTechStorageData.technologies.Count; i++)
        {
            GUILayout.BeginHorizontal();
            bool isclicked = false;
            isclicked = GUILayout.Button(curTechStorageData.technologies[i].technologyName, (currentTechnology != null && curTechStorageData.technologies[i].technologyName == currentTechnology.technologyName) ? selectedText : notSelectedText);
            GUILayout.EndHorizontal();
            if (isclicked)
            {
                GUI.FocusControl(null);
                if (curTechStorageData.technologies[i] != null)
                {
                    currentTechnology = curTechStorageData.technologies[i];
                    curTechIdx        = i;
                }
            }
        }
        EditorGUILayout.EndScrollView();

        EditorGUILayout.BeginHorizontal();
        bool remove = GUILayout.Button("Remove", GUILayout.Width(120));

        if (remove)
        {
            if (currentTechnology.technologyName == curTechStorageData.technologies[curTechIdx].technologyName)
            {
                curTechStorageData.technologies.RemoveAt(curTechIdx);
                currentTechnology = new BaseTechnology();
            }
        }

        bool save = GUILayout.Button("Save", GUILayout.Width(120));

        if (save)
        {
            Save();
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
        GUILayout.EndArea();
    }