Example #1
0
        public override void SetupInteractableInformation()
        {
            base.SetupInteractableInformation();
            PlayerKingdomData playerData = PlayerGameManager.GetInstance.playerData;

            // IF NO DATA ABOUT THE BUILDING YET
            if (PlayerGameManager.GetInstance != null && playerData.buildingInformationData != null &&
                playerData.buildingInformationData.Count > 0)
            {
                buildingInformation = TransitionManager.GetInstance.currentSceneManager.buildingInformationStorage.ObtainBuildingOperation(informationName);

                BuildingSavedData tmp = playerData.buildingInformationData.Find(x => x.buildingName == buildingInformation.BuildingName);

                if (tmp != null)
                {
                    buildingInformation.buildingCondition = tmp.buildingCondition;
                    buildingInformation.buildingLevel     = tmp.buildingLevel;
                    buildingInformation.buildingType      = tmp.buildingType;
                }
            }
            else if (TransitionManager.GetInstance != null)
            {
                buildingInformation = TransitionManager.GetInstance.currentSceneManager.buildingInformationStorage.ObtainBuildingOperation(informationName);
            }
            else if (testMode)
            {
                buildingInformation = BalconySceneManager.GetInstance.buildingInformationStorage.ObtainBuildingOperation(buildingType);
            }

            UpdateBuildingState();
        }
Example #2
0
        public void SetupOperationCards(BuildingInformationData thisData)
        {
            List <BuildingCardData> cardData = thisData.buildingCard;

            for (int i = 0; i < cardData.Count; i++)
            {
                operationCards[i].cardIcon.sprite = cardData[i].cardIcon;
            }
        }
        public void LoadBuildingStorage()
        {
            if (curBuildingStorage == null)
            {
                buildingStoragePrefab = (GameObject)Resources.Load("Prefabs/Building Operations/Building Operation Storage");
                curBuildingStorage    = (GameObject)Instantiate(buildingStoragePrefab);
            }

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

            curBuildingStorageData = curBuildingStorage.GetComponent <BuildingOperationStorage>();

            if (curBuildingStorageData.buildingOperationList == null)
            {
                curBuildingStorageData.buildingOperationList = new List <BuildingInformationData>();
            }

            curBuildingData       = new BuildingInformationData();
            buildingStorageLoaded = true;
        }
        public void ShowBuildingInformation()
        {
            bool SaveStorage = false;

            if (curBuildingData == null)
            {
                curBuildingData = new BuildingInformationData();
            }

            GUILayout.BeginArea(new Rect(5, 12, leftPanelWidth, 300));


            GUILayout.ExpandWidth(false);
            EditorStyles.textField.wordWrap = true;

            // Building Name
            GUILayout.BeginHorizontal();
            EditorGUIUtility.labelWidth = 34;
            EditorGUILayout.LabelField("Building Name:", EditorStyles.boldLabel, GUILayout.Width(100));
            curBuildingData.BuildingName = EditorGUILayout.TextField(curBuildingData.BuildingName, GUILayout.MaxWidth(300));
            EditorGUILayout.LabelField("Start Condition: ", EditorStyles.boldLabel, GUILayout.Width(100));
            curBuildingData.buildingCondition = (BuildingCondition)EditorGUILayout.EnumPopup(curBuildingData.buildingCondition, GUILayout.MaxWidth(100));
            GUILayout.EndHorizontal();

            // Building Information
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Type: ", EditorStyles.boldLabel, GUILayout.Width(100));
            curBuildingData.buildingType = (BuildingType)EditorGUILayout.EnumPopup(curBuildingData.buildingType, GUILayout.MaxWidth(100));
            EditorGUILayout.LabelField("Repair Price: ", EditorStyles.boldLabel, GUILayout.Width(100));
            curBuildingData.repairPrice = EditorGUILayout.IntField(curBuildingData.repairPrice, GUILayout.MaxWidth(100));
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            GUILayout.BeginArea(new Rect(5, 50, 300, 300));
            GUILayout.BeginHorizontal();
            GUILayout.Label("Cards (Max 3): ", EditorStyles.boldLabel, GUILayout.Width(100));
            bool addCard    = false;
            bool removeCard = false;

            addCard = GUILayout.Button("Add Card", GUILayout.MaxWidth(100));
            if (curBuildingData.buildingCard == null)
            {
                curBuildingData.buildingCard = new List <BuildingCardData>();
            }

            if (addCard)
            {
                if (curBuildingData.buildingCard.Count >= 3)
                {
                    return;
                }

                addCard = false;
                BuildingCardData tmp = new BuildingCardData();
                tmp.cardName = "New Card";

                curBuildingData.buildingCard.Add(tmp);
                selectedCardIdx = curBuildingData.buildingCard.Count - 1;
                curSelectedCard = curBuildingData.buildingCard[selectedCardIdx];
            }
            removeCard = GUILayout.Button("Remove Card", GUILayout.Width(120));
            if (removeCard)
            {
                if (curBuildingData.buildingCard.Count > 0)
                {
                    curBuildingData.buildingCard.RemoveAt(curBuildingData.buildingCard.Count - 1);
                }
            }
            GUILayout.EndHorizontal();

            float widthX = 300;

            // Cards
            Rect          cardSpriteRect = new Rect(60, 40, 180, 240);
            List <string> cardList       = new List <string>();

            if (curBuildingData.buildingCard == null)
            {
                curBuildingData.buildingCard = new List <BuildingCardData>();
            }
            else
            {
                if (curBuildingData.buildingCard.Count > 0)
                {
                    for (int i = 0; i < curBuildingData.buildingCard.Count; i++)
                    {
                        cardList.Add(curBuildingData.buildingCard[i].cardName);
                    }
                    GUILayout.BeginHorizontal();
                    selectedCardIdx = EditorGUILayout.Popup(selectedCardIdx, cardList.ToArray(), GUILayout.Width(150));
                    if (curSelectedCard != curBuildingData.buildingCard[selectedCardIdx])
                    {
                        curSelectedCard = curBuildingData.buildingCard[selectedCardIdx];
                    }
                    if (curSelectedCard != null)
                    {
                        curSelectedCard.cardName = GUILayout.TextField(curSelectedCard.cardName, GUILayout.Width(150));
                    }
                    GUILayout.EndHorizontal();

                    curSelectedCard.cardIcon = (Sprite)EditorGUI.ObjectField(cardSpriteRect, curSelectedCard.cardIcon, typeof(Sprite), false);
                }
                else
                {
                    GUILayout.Label("[No Card Available]", GUILayout.Width(200));
                }
            }
            GUILayout.EndArea();
            // ACTION
            GUILayout.BeginArea(new Rect(310, 80, 450, 300));
            bool  addAction    = false;
            bool  removeButton = false;
            float spritePosY   = 0;
            Rect  spriteRect   = new Rect(160, spritePosY, 150, 15);

            if (curSelectedCard != null)
            {
                GUILayout.BeginHorizontal();
                addAction = GUILayout.Button("Add Action", GUILayout.MaxWidth(100));
                if (curSelectedCard.actionTypes == null)
                {
                    curSelectedCard.actionTypes = new List <CardActiondata>();
                }

                if (addAction)
                {
                    if (curSelectedCard == null)
                    {
                        return;
                    }
                    if (curSelectedCard.actionTypes.Count >= 3)
                    {
                        return;
                    }

                    addAction = false;
                    curSelectedCard.actionTypes.Add(new CardActiondata());
                }
                removeButton = GUILayout.Button("Remove Button", GUILayout.MaxWidth(100));
                if (removeButton)
                {
                    if (curSelectedCard.actionTypes.Count > 0)
                    {
                        curSelectedCard.actionTypes.RemoveAt(curSelectedCard.actionTypes.Count - 1);
                    }
                }
                GUILayout.EndHorizontal();
                actionScrollPos = GUILayout.BeginScrollView(actionScrollPos, new GUIStyle("RL Background"), GUILayout.Width(350), GUILayout.Height(position.height - 550));
                for (int i = 0; i < curSelectedCard.actionTypes.Count; i++)
                {
                    GUILayout.BeginHorizontal();
                    curSelectedCard.actionTypes[i].actionType = (CardActionType)EditorGUILayout.EnumPopup(curSelectedCard.actionTypes[i].actionType, GUILayout.MaxWidth(140));
                    GUILayout.EndHorizontal();

                    if (i == 0)
                    {
                        spriteRect = new Rect(2, 20, 150, 15);
                    }
                    else
                    {
                        spriteRect = new Rect(2, (i * 70), 150, 15);
                    }
                    Texture2D tmp;
                    float     posY = 0;
                    if (i == 0)
                    {
                        posY = 10;
                    }
                    else
                    {
                        posY = i * 75;
                    }
                    switch (curSelectedCard.actionTypes[i].actionType)
                    {
                    case CardActionType.MessageOnly:
                        GUILayout.BeginHorizontal();
                        curSelectedCard.actionTypes[i].message = GUILayout.TextField(curSelectedCard.actionTypes[i].message, GUILayout.Width(150));
                        GUILayout.EndHorizontal();
                        break;

                    case CardActionType.LogoWithMessage:
                        GUILayout.BeginHorizontal();
                        curSelectedCard.actionTypes[i].logoIcon = (Sprite)EditorGUILayout.ObjectField(curSelectedCard.actionTypes[i].logoIcon, typeof(Sprite), false, GUILayout.Width(100));

                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal();

                        curSelectedCard.actionTypes[i].message = GUILayout.TextField(curSelectedCard.actionTypes[i].message, GUILayout.Width(150));
                        GUILayout.EndHorizontal();
                        break;

                    case CardActionType.CostMessageOnly:
                        break;

                    case CardActionType.LogoOnly:
                        GUILayout.BeginHorizontal();
                        curSelectedCard.actionTypes[i].logoIcon = (Sprite)EditorGUILayout.ObjectField(curSelectedCard.actionTypes[i].logoIcon, typeof(Sprite), false, GUILayout.Width(100));
                        GUILayout.EndHorizontal();
                        break;

                    default:
                        break;
                    }
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Hover Info:", GUILayout.Width(70));
                    curSelectedCard.actionTypes[i].AdditionalInformationMessage = GUILayout.TextField(curSelectedCard.actionTypes[i].AdditionalInformationMessage, GUILayout.Width(250), GUILayout.Height(60));
                    GUILayout.EndHorizontal();
                    GUILayout.Space(10);
                }
                GUILayout.EndScrollView();
            }
            GUILayout.EndArea();
        }
        public void ShowBuildingList()
        {
            bool addBuilding    = false;
            bool saveBuilding   = false;
            bool removeBuilding = false;

            EditorStyles.textField.wordWrap = true;

            GUILayout.BeginArea(new Rect(680, 10, 400, position.height - 375));
            GUILayout.BeginHorizontal();
            GUILayout.Box("Building List", titleText, GUILayout.Width(295), GUILayout.Height(20));
            GUILayout.EndHorizontal();

            buildingScrollPos = GUILayout.BeginScrollView(buildingScrollPos, new GUIStyle("RL Background"), GUILayout.Width(300), GUILayout.Height(position.height - 400));

            if (curBuildingStorageData != null && curBuildingStorageData.buildingOperationList != null && curBuildingStorageData.buildingOperationList.Count > 0)
            {
                for (int i = 0; i < curBuildingStorageData.buildingOperationList.Count; i++)
                {
                    bool   isClicked = false;
                    string listName  = "";

                    GUILayout.BeginHorizontal();
                    isClicked = GUILayout.Button(curBuildingStorageData.buildingOperationList[i].BuildingName, (selectedBuildingData != null && curBuildingStorageData.buildingOperationList[i].BuildingName == selectedBuildingData.BuildingName) ? selectedText : notSelectedText, GUILayout.Width(300));
                    if (!string.IsNullOrEmpty(curBuildingStorageData.buildingOperationList[i].BuildingName))
                    {
                        listName = "[" + curBuildingStorageData.buildingOperationList[i].BuildingName + "]";
                    }
                    GUILayout.EndHorizontal();

                    if (isClicked)
                    {
                        if (curBuildingStorageData.buildingOperationList[i] != null)
                        {
                            selectedBuildingData = curBuildingStorageData.buildingOperationList[i];
                            selectedBuildingIdx  = i;
                            curBuildingData      = selectedBuildingData;
                            if (selectedBuildingData.buildingCard != null && selectedBuildingData.buildingCard.Count > 0)
                            {
                                curSelectedCard = selectedBuildingData.buildingCard[0];
                            }
                            else
                            {
                                curSelectedCard = null;
                            }

                            selectedCardIdx = 0;

                            GUI.FocusControl(null);
                            isClicked = false;
                        }
                    }
                }
            }
            GUILayout.EndScrollView();

            GUILayout.EndArea();


            GUILayout.BeginArea(new Rect(680, position.height - 360, 400, 225));

            GUILayout.BeginHorizontal();
            saveBuilding = GUILayout.Button((curBuildingData == selectedBuildingData) ? "Modify" : "Save", GUILayout.MaxWidth(100));
            addBuilding  = GUILayout.Button("Create New", GUILayout.MaxWidth(100));
            if (selectedBuildingData != null && curBuildingStorageData.buildingOperationList.Find(x => x.BuildingName == selectedBuildingData.BuildingName) != null)
            {
                removeBuilding = GUILayout.Button("Remove", GUILayout.MaxWidth(100));
            }
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            if (saveBuilding)
            {
                if (curBuildingStorageData.buildingOperationList.Contains(curBuildingData))
                {
                    selectedBuildingData = curBuildingData;
                }
                else
                {
                    curBuildingStorageData.buildingOperationList.Add(curBuildingData);
                    curBuildingData = new BuildingInformationData();
                }
                Save();
                selectedBuildingData = null;
                curSelectedCard      = null;
                curBuildingData      = new BuildingInformationData();
                curSelectedAction    = null;
                selectedActionIdx    = 0;
            }
            if (addBuilding)
            {
                selectedBuildingData = null;
                curBuildingData      = new BuildingInformationData();
                curSelectedCard      = null;
                GUI.FocusControl(null);
            }
            if (removeBuilding)
            {
                removeBuilding = false;
                if (selectedBuildingData != null)
                {
                    curBuildingStorageData.buildingOperationList.RemoveAt(selectedBuildingIdx);
                    selectedBuildingData = null;
                }
                Save();
                GUI.FocusControl(null);
            }
        }