private IEnumerator executeAttributePoints() { AttributeScript tempScript = attributeContent.GetComponent <AttributeScript>(); string requestUrl = apiUrl + "game?"; requestUrl += "userid=" + PlayerPrefs.GetString("userid") + "&atkNumber=" + tempScript.atkNumber.text + "&hpNumber=" + tempScript.hpNumber.text + "&defNumber=" + tempScript.defNumber.text + "&freePointsATK=" + tempScript.freePointsToUseOnATK.text + "&freePointsHP=" + tempScript.freePointsToUseOnHP.text + "&freePointsDEF=" + tempScript.freePointsToUseOnDEF.text; UnityWebRequest attributePointsRequest = UnityWebRequest.Put(requestUrl, "put-request"); yield return(attributePointsRequest.SendWebRequest()); if (attributePointsRequest.isNetworkError || attributePointsRequest.isHttpError) { yield break; } JSONNode responseText = JSON.Parse(attributePointsRequest.downloadHandler.text); if (responseText == "success") { Debug.Log("Pointchange was successful"); } }
// Use this for initialization void Start() { unitScript = GetComponent <UnitScript>(); attrScript = GetComponent <AttributeScript>(); unitScript.facingDir = (Direction)Random.Range(0, (int)Direction.TOTAL); }
protected virtual void PopulateDropdown() { attrDetails = FindGameScript().GetCachedAttributes(); List <string> tempNames = new List <string>(); for (int i = 0; i < attrDetails.Length; i++) { AttributeScript currentAttrDetail = attrDetails[i]; if (currentAttrDetail == null) { continue; } string attributeName = currentAttrDetail.GetAttributeName(); if (attributeName.Trim() != "") { tempNames.Add(attributeName); } } dropdownself.GetComponent <Dropdown>().AddOptions(tempNames); }
private AttributeScript[] GetAttributesGridValues() { int numberOfChildren = attributesGrid.transform.childCount; AttributeScript[] attributes = new AttributeScript[numberOfChildren]; for (int i = 0; i < numberOfChildren; i++) { Transform currChild = attributesGrid.transform.GetChild(i); string currentAttrName = currChild.GetComponent <InputField>().text; Transform currAttrType = currChild.Find("DropdownAttrType"); int currentAttrTypeValue = (int)currAttrType.GetComponentInChildren <Dropdown>().value; Transform currDropdownAttrAttachment = currAttrType.Find("DropdownAttrAttachment"); if (currentAttrTypeValue == AttributeScript.ATTRIBUTE_TYPE_DISCRETE) { Transform parentOfFields = currDropdownAttrAttachment.GetChild(0).Find("Scroll View"). Find("Viewport").Find("Content"); int numChild = parentOfFields.childCount; string[] choices = new string[numChild]; for (int j = 0; j < numChild; j++) { choices[j] = parentOfFields.GetChild(j).GetComponent <InputField>().text; } attributes[i] = new AttributeScript(currentAttrName, currentAttrTypeValue, choices); } else if (currentAttrTypeValue == AttributeScript.ATTRIBUTE_TYPE_CONTINUOUS) { Transform continuousAttrParent = currDropdownAttrAttachment.GetChild(0); string assignedStart = continuousAttrParent.Find("AssignedStartField").GetComponent <InputField>().text; string assignedEnd = continuousAttrParent.Find("AssignedEndField").GetComponent <InputField>().text; string limitStart = continuousAttrParent.Find("LimitStartField").GetComponent <InputField>().text; string limitEnd = continuousAttrParent.Find("LimitEndField").GetComponent <InputField>().text; attributes[i] = new AttributeScript(currentAttrName, currentAttrTypeValue, Int32.Parse(assignedStart), Int32.Parse(assignedEnd), Int32.Parse(limitStart), Int32.Parse(limitEnd)); } } return(attributes); }
private void HandleSelectedAttribute(AttributeScript attributeDetail, bool toRefresh = true) { type = attributeDetail.GetAttributeType(); Transform discreteObj = transform.parent.Find("DiscreteCase"); Transform continuousObj = transform.parent.Find("ContinuousCase"); if (type == AttributeScript.ATTRIBUTE_TYPE_DISCRETE) { discreteObj.gameObject.SetActive(true); continuousObj.gameObject.SetActive(false); Transform discreteContent = discreteObj.Find("Scroll View").Find("Viewport").Find("Content"); RemoveAllChild(discreteContent.gameObject); string[] choices = attributeDetail.GetAttributeChoiceNames(); for (int i = 0; i < choices.Length; i++) { GameObject choiceField = Instantiate(discreteAttrChancePrefab, discreteContent); string choiceName = choices[i]; choiceField.transform.Find("Text").GetComponent <Text>().text = choiceName; } } else if (type == AttributeScript.ATTRIBUTE_TYPE_CONTINUOUS) { discreteObj.gameObject.SetActive(false); continuousObj.gameObject.SetActive(true); GameObject[] objToReset = new GameObject[4]; if (toRefresh) { objToReset[0] = continuousObj.Find("X(Value)1").gameObject; objToReset[1] = continuousObj.Find("Y(Percent)1").gameObject; objToReset[2] = continuousObj.Find("X(Value)2").gameObject; objToReset[3] = continuousObj.Find("Y(Percent)2").gameObject; for (int i = 0; i < objToReset.Length; i++) { objToReset[i].GetComponent <InputField>().text = ""; } } } }
private void HandleSelectedAttribute(AttributeScript attributeDetail, bool toRefresh = true) { type = attributeDetail.GetAttributeType(); Transform discreteObj = transform.parent.Find("DiscreteCase"); Transform continuousObj = transform.parent.Find("ContinuousCase"); if (type == AttributeScript.ATTRIBUTE_TYPE_DISCRETE) { discreteObj.gameObject.SetActive(true); continuousObj.gameObject.SetActive(false); Dropdown dropdownOptions = discreteObj.Find("Dropdown").GetComponent <Dropdown>(); dropdownOptions.ClearOptions(); List <string> newOptions = new List <string>(); string[] choices = attributeDetail.GetAttributeChoiceNames(); for (int i = 0; i < choices.Length; i++) { string choiceName = choices[i]; newOptions.Add(choiceName); } dropdownOptions.AddOptions(new List <string>(choices)); if (toRefresh) { dropdownOptions.value = 0; } } else if (type == AttributeScript.ATTRIBUTE_TYPE_CONTINUOUS) { discreteObj.gameObject.SetActive(false); continuousObj.gameObject.SetActive(true); if (toRefresh) { continuousObj.Find("ChangeField").GetComponent <InputField>().text = ""; } } }
public void RunUpgrade() { if (!hasInitialized) { playerAttr = SpawnManagerScript.Instance.playerScript.attrScript; UISubjectScript.Instance.Notify(NotificationType.Player_Health, SpawnManagerScript.Instance.playerScript.unitScript.health.ToString()); hasInitialized = true; } int startNotification = (int)NotificationType.Player_Offense; for (int i = 0; i < (int)AttributeType.Total; i++) { UISubjectScript.Instance.Notify((NotificationType)(startNotification + i), playerAttr.attributeCount[i].ToString()); } UISubjectScript.Instance.Notify(NotificationType.PointsRemaining, pointsRemaining.ToString()); UISubjectScript.Instance.Notify(NotificationType.Level, playerAttr.level.ToString()); if (pointsRemaining <= 0) { GameManagerScript.Instance.curState = GameState.PlayerMove; } }
// Use this for initialization void Start() { unitScript = GetComponent <UnitScript>(); attrScript = GetComponent <AttributeScript>(); }
public virtual void OnDropDownValueChanged() { chosenAttributeDetail = attrDetails[dropdownself.value]; }