private void ResourceEditing() { GUILayout.Label("Resource Editing", Style("SubTitle")); GUILayout.BeginVertical(); Dictionary <string, int> propertyMapping = new Dictionary <string, int>(); List <string> propertyNames = new List <string>(); foreach (int propertyKey in activeGameData.PropertyKeys) { GameDataProperty prop = activeGameData.GetProperty(propertyKey); propertyMapping[prop.Name] = prop.Index; propertyNames.Add(prop.Name); } List <int> resourceKeys = activeGameData.ResourceKeys.ToList(); for (int i = 0; i < resourceKeys.Count; ++i) { int resourceKey = resourceKeys[i]; Resource resource = activeGameData.GetResource(resourceKey); GUILayout.BeginHorizontal(Style("box")); GUILayout.Label(resource.Index.ToString(), GUILayout.Width(50)); resource.Name = GUILayout.TextField(resource.Name, GUILayout.Width(150)); int selectedIndex = propertyNames.IndexOf(activeGameData.GetProperty(resource.StoragePropertyIndex).Name); int newSelectedIndex = EditorGUILayout.Popup(selectedIndex, propertyNames.ToArray()); if (selectedIndex != newSelectedIndex) { resource.StoragePropertyIndex = propertyMapping[propertyNames[newSelectedIndex]]; } if (GUILayout.Button("Delete")) { activeGameData.DeleteResource(resource.Index); i--; } GUILayout.EndHorizontal(); } GUILayout.Label("New Resource"); GUILayout.BeginHorizontal(Style("box")); GUILayout.Label("Name", GUILayout.Width(100)); newResourceName = GUILayout.TextField(newResourceName, GUILayout.Width(150)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create")) { activeGameData.AddResource(GameData.MemoryCapacity, newResourceName, 0); } GUILayout.EndVertical(); }
private void OnActiveLineChanged(GameDataProperty property) { activeTextBlocks[activeTextBlocks.Count - 1] = property.GetValue <TextBlock>(); if (ActiveTextContainer == null) { return; } ActiveTextContainer.SetContent(activeTextBlocks); }
protected override void OnPropertyUpdated(GameDataProperty prop) { lastPercentage = Mathf.Clamp01(prop.GetValue <float>()); PercentageBar.localScale = Vector3.Lerp(MinimumScale, MaximumScale, lastPercentage); int intPercentage = (int)(lastPercentage * 100); PercentageText.text = $"{intPercentage}%"; UpdateUsageTexts(); }
private void OnJobProgressUpdated(GameDataProperty prop) { float percentage = Mathf.Clamp01(prop.GetValue <float>()); ProgressBar.localScale = Vector3.Lerp(MinimumScale, MaximumScale, percentage); int intPercentage = (int)(percentage * 100); ProgressPercentageText.text = $"{intPercentage}%"; }
private void OnTabsVisibleChanged(GameDataProperty property) { if (property.GetValue <bool>()) { TabsContainer.gameObject.SetActive(true); } else { TabsContainer.gameObject.SetActive(false); SetTabActive(0); } }
protected void OnPropertyUpdated(GameDataProperty prop) { List <int> unusedKeys = jobViews.Keys.ToList(); List <Job> jobs = prop.GetListValue <Job>(); foreach (Job job in jobs) { if (!unusedKeys.Contains(job.Index)) { RectTransform newJobView = Instantiate(JobListItemPrefab, JobsContainer); JobListItemController newJobController = newJobView.GetComponent <JobListItemController>(); newJobController.WatchedJob = job; jobViews[job.Index] = newJobController; } } foreach (int key in unusedKeys) { Destroy(jobViews[key].gameObject); jobViews.Remove(key); } }
private void PropertyEditing() { GUILayout.Label("Property Editing", Style("SubTitle")); GUILayout.BeginVertical(); List <int> propertyKeys = activeGameData.PropertyKeys.ToList(); for (int i = 0; i < propertyKeys.Count; ++i) { int propertyKey = propertyKeys[i]; GameDataProperty property = activeGameData.GetProperty(propertyKey); GUILayout.BeginHorizontal(Style("box")); GUILayout.Label(property.Index.ToString(), GUILayout.Width(50)); GUILayout.Label(property.PropertyType.ToString(), GUILayout.Width(100)); property.Name = GUILayout.TextField(property.Name, GUILayout.Width(150)); if (property.PropertyType == typeof(Single)) { ((GameDataProperty <float>)property).Value = EditorGUILayout.FloatField(((GameDataProperty <float>)property).Value, GUILayout.Width(50)); } else if (property.PropertyType == typeof(Int32)) { ((GameDataProperty <int>)property).Value = EditorGUILayout.IntField(((GameDataProperty <int>)property).Value, GUILayout.Width(50)); } else if (property.PropertyType == typeof(Boolean)) { ((GameDataProperty <bool>)property).Value = EditorGUILayout.Toggle(((GameDataProperty <bool>)property).Value, GUILayout.Width(50)); } if (GUILayout.Button("Delete")) { activeGameData.DeleteProperty(property.Index); i--; } GUILayout.EndHorizontal(); } GUILayout.Label("New Property"); GUILayout.BeginHorizontal(Style("box")); GUILayout.Label("Name", GUILayout.Width(100)); newPropertyName = GUILayout.TextField(newPropertyName, GUILayout.Width(150)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create Integer")) { activeGameData.AddProperty(newPropertyName, 0); } if (GUILayout.Button("Create Float")) { activeGameData.AddProperty(newPropertyName, 0f); } if (GUILayout.Button("Create Bool")) { activeGameData.AddProperty(newPropertyName, false); } GUILayout.EndVertical(); }
protected virtual void OnPropertyUpdated(GameDataProperty prop) { }
private void OnMultiplierChanged(GameDataProperty prop) { lastMultiplier = prop.GetValue <int>(); UpdateUsageTexts(); }
private void OnCapacityChanged(GameDataProperty prop) { lastCapacity = prop.GetValue <float>(); UpdateUsageTexts(); }