void IInputEvent.CreateCanvas(DataManager dataManager) { nextMenu = this; GameObject canvasObject = new GameObject(); canvas = canvasObject.AddComponent <Canvas> (); canvas.name = "ImageCanvas"; canvas.renderMode = RenderMode.ScreenSpaceOverlay; TextAsset jsonAsset = Resources.Load("Data/ImageMenu", typeof(TextAsset)) as TextAsset; JsonData jsonData = JsonMapper.ToObject(jsonAsset.text); JsonData[] jsonArray = JsonMapper.ToObject <JsonData[]> (jsonData["labels"].ToJson()); foreach (JsonData array in jsonArray) { BaseLabel label = new BaseLabel(); label.Json = array; label.CreateMenuItem(canvas); } GameObject imageObject = MonoBehaviour.Instantiate(canvas.transform.GetChild(0).gameObject) as GameObject; imageObject.name = "Image"; imageObject.transform.SetParent(canvas.transform); Image nameImage = imageObject.GetComponent <Image> (); nameImage.sprite = Resources.Load("UserInterface/" + imageFile, typeof(Sprite)) as Sprite; }
void IInputEvent.CreateCanvas(DataManager dataManager) { nextMenu = this; GameObject canvasObject = new GameObject(); canvas = canvasObject.AddComponent <Canvas> (); canvas.name = "ImageCanvas"; canvas.renderMode = RenderMode.ScreenSpaceOverlay; TextAsset jsonAsset = Resources.Load("Data/ImageMenu", typeof(TextAsset)) as TextAsset; JsonData jsonData = JsonMapper.ToObject(jsonAsset.text); JsonData[] jsonArray = JsonMapper.ToObject <JsonData[]> (jsonData["labels"].ToJson()); BaseLabel label = new BaseLabel(); label.Json = jsonArray[0]; label.CreateMenuItem(canvas); canvas.transform.GetChild(0).GetComponent <Image> ().sprite = Resources.Load("UserInterface/fade", typeof(Sprite)) as Sprite; GameObject imageObject = MonoBehaviour.Instantiate(canvas.transform.GetChild(0).gameObject) as GameObject; imageObject.name = "Image"; imageObject.transform.SetParent(canvas.transform); Image nameImage = imageObject.GetComponent <Image> (); nameImage.sprite = Resources.Load("UserInterface/" + imageFile, typeof(Sprite)) as Sprite; nameImage.rectTransform.position = new Vector3(658f * BattleUI.ratio_width, 390f * BattleUI.ratio_height); nameImage.rectTransform.sizeDelta = new Vector3(600f * BattleUI.ratio_width, 300f * BattleUI.ratio_height); canvas.transform.GetChild(0).GetComponent <Image> ().color = new Color(1, 1, 1, 0.5f); }
void IInputEvent.CreateCanvas(DataManager dataManager) { nextMenu = this; GameObject canvasObject = new GameObject(); canvas = canvasObject.AddComponent <Canvas> (); canvas.name = "ImageCanvas"; canvas.renderMode = RenderMode.ScreenSpaceOverlay; TextAsset jsonAsset = Resources.Load("Data/ImageMenu", typeof(TextAsset)) as TextAsset; JsonData jsonData = JsonMapper.ToObject(jsonAsset.text); JsonData[] jsonArray = JsonMapper.ToObject <JsonData[]> (jsonData["labels"].ToJson()); foreach (JsonData array in jsonArray) { BaseLabel label = new BaseLabel(); label.Json = array; label.CreateMenuItem(canvas); } mauanlImage = canvas.transform.GetChild(0).GetComponent <Image> (); mauanlImage.sprite = Resources.Load("UserInterface/" + filePath[nowNumber], typeof(Sprite)) as Sprite; }
void IInputEvent.CreateCanvas(DataManager dataManager) { nextMenu = this; GameObject canvasObject = new GameObject(); canvas = canvasObject.AddComponent <Canvas> (); canvas.name = "StatusCanvas"; canvas.renderMode = RenderMode.ScreenSpaceOverlay; TextAsset jsonAsset = Resources.Load("Data/StatusMenu", typeof(TextAsset)) as TextAsset; JsonData jsonData = JsonMapper.ToObject(jsonAsset.text); JsonData[] jsonArray = JsonMapper.ToObject <JsonData[]> (jsonData["labels"].ToJson()); foreach (JsonData array in jsonArray) { BaseLabel label = new BaseLabel(); label.Json = array; label.CreateMenuItem(canvas); } JsonData data = jsonData["nameImage"]; GameObject imageObject = MonoBehaviour.Instantiate(canvas.transform.GetChild(0).gameObject) as GameObject; imageObject.name = "CharaName"; imageObject.transform.SetParent(canvas.transform); Image nameImage = imageObject.GetComponent <Image> (); Vector2 bPos = new Vector2((float)((int)data["position_x"]), (float)((int)data["position_y"])); Vector2 bSize = new Vector2((float)((int)data["width"]), (float)((int)data["height"])); nameImage.sprite = Resources.Load("UserInterface/" + dataManager.characterData[dataManager.freeModeData.characterSelectNumber].labelInfo.buttonImageFile[0], typeof(Sprite)) as Sprite; nameImage.rectTransform.position = new Vector3(bPos.x * BattleUI.ratio_width, bPos.y * BattleUI.ratio_height, 0f); nameImage.rectTransform.sizeDelta = new Vector2(bSize.x * BattleUI.ratio_width, bSize.y * BattleUI.ratio_height); data = jsonData["playerImage"]; imageObject = MonoBehaviour.Instantiate(canvas.transform.GetChild(0).gameObject) as GameObject; imageObject.name = "CharaImage"; imageObject.transform.SetParent(canvas.transform); nameImage = imageObject.GetComponent <Image> (); bPos = new Vector2((float)((int)data["position_x"]), (float)((int)data["position_y"])); bSize = new Vector2((float)((int)data["width"]), (float)((int)data["height"])); nameImage.sprite = Resources.Load("UserInterface/" + dataManager.characterData[dataManager.freeModeData.characterSelectNumber].labelInfo.stageImageFile, typeof(Sprite)) as Sprite; nameImage.rectTransform.position = new Vector3(bPos.x * BattleUI.ratio_width, bPos.y * BattleUI.ratio_height, 0f); nameImage.rectTransform.sizeDelta = new Vector2(bSize.x * BattleUI.ratio_width, bSize.y * BattleUI.ratio_height); data = jsonData["gaugeInfo"]; float[] startPos = JsonMapper.ToObject <float[]> (data["position"].ToJson()); float[] size = JsonMapper.ToObject <float[]> (data["size"].ToJson()); float[] distance = JsonMapper.ToObject <float[]> (data["distance"].ToJson()); CharacterStatus statusData = dataManager.characterData[dataManager.freeModeData.characterSelectNumber].status; float[] status = new float[6] { statusData.hp, statusData.skill, statusData.attack, statusData.defense, statusData.agile, statusData.experience }; for (int i = 0; i < 6; i++) { imageObject = MonoBehaviour.Instantiate(canvas.transform.GetChild(0).gameObject) as GameObject; imageObject.name = "Gauge00" + i.ToString(); imageObject.transform.SetParent(canvas.transform); nameImage = imageObject.GetComponent <Image> (); nameImage.sprite = Resources.Load("UserInterface/status_gauge", typeof(Sprite)) as Sprite; nameImage.rectTransform.position = new Vector3((startPos[0] + distance[0] * i) * BattleUI.ratio_width, (startPos[1] + distance[1] * i) * BattleUI.ratio_height, 0f); nameImage.rectTransform.sizeDelta = new Vector2(size[0] * BattleUI.ratio_width, size[1] * BattleUI.ratio_height); nameImage.type = Image.Type.Filled; nameImage.fillMethod = Image.FillMethod.Horizontal; nameImage.fillAmount = status[i] / 999f; } BaseText level = new BaseText(); level.Json = jsonData["text"]; level.CreateText(canvas); level.ChangeText(dataManager.characterData[dataManager.freeModeData.characterSelectNumber].status.level.ToString()); }
void IInputEvent.CreateCanvas(DataManager dataManager) { nextMenu = this; this.dataManager = dataManager; buttonList = new List <BaseButton> (); GameObject canvasObject = new GameObject(); canvas = canvasObject.AddComponent <Canvas> (); canvas.name = "MenuCanvas"; canvas.renderMode = RenderMode.ScreenSpaceOverlay; TextAsset jsonAsset = Resources.Load("Data/BattleMainMenu", typeof(TextAsset)) as TextAsset; JsonData jsonData = JsonMapper.ToObject(jsonAsset.text); JsonData[] jsonArray = JsonMapper.ToObject <JsonData[]> (jsonData["labels"].ToJson()); foreach (JsonData array in jsonArray) { BaseLabel label = new BaseLabel(); label.Json = array; label.CreateMenuItem(canvas); } JsonData data = jsonData["nameLabels"]; GameObject stageName = MonoBehaviour.Instantiate(canvas.transform.GetChild(1).gameObject) as GameObject; stageName.name = "stageName"; stageName.transform.SetParent(canvas.transform); Image stageNameImage = stageName.GetComponent <Image> (); Vector2 bPos = new Vector2((float)((int)data["position_x"]), (float)((int)data["position_y"])); Vector2 bSize = new Vector2((float)((int)data["width"]), (float)((int)data["height"])); stageNameImage.sprite = Resources.Load("UserInterface/" + dataManager.stageData[dataManager.freeModeData.stageSelectNumber].labelInfo.buttonImageFile[0], typeof(Sprite)) as Sprite; stageNameImage.rectTransform.position = new Vector3(bPos.x * BattleUI.ratio_width, bPos.y * BattleUI.ratio_height, 0f); stageNameImage.rectTransform.sizeDelta = new Vector2(bSize.x * BattleUI.ratio_width, bSize.y * BattleUI.ratio_height); cursor = new FilldCursor(); cursor.Json = jsonData["cursor"]; cursor.CreateMenuItem(canvas); data = jsonData["buttonInfo"]; jsonArray = JsonMapper.ToObject <JsonData[]> (jsonData["buttons"].ToJson()); buttonsInfo = new ButtonsInfo[jsonArray.Length]; cursor.max_number = buttonsInfo.Length; for (int i = 0; i < buttonsInfo.Length; i++) { buttonsInfo[i].position = new Vector2((int)data["position_x"] + (int)data["distance_x"] * i, (int)data["position_y"] + (int)data["distance_y"] * i); buttonsInfo[i].size = new Vector2((int)data["width"], (int)data["height"]); buttonsInfo[i].alpha = JsonMapper.ToObject <float[]> (data["alpha"].ToJson()); buttonsInfo[i].pivot = JsonMapper.ToObject <float[]> (data["pivot"].ToJson()); } for (int i = 0; i < jsonArray.Length; i++) { BaseButton button = new BaseButton(); button.Json = jsonArray[i]; button.CreateMenuItem(canvas, buttonsInfo[i]); buttonList.Add(button); } foreach (BaseButton buttons in buttonList) { buttons.ButtonEvent(cursor.select); } conditions = new BaseText(); conditions.Json = jsonData["text"]; conditions.CreateText(canvas); conditions.ChangeText(dataManager.stageData[dataManager.freeModeData.stageSelectNumber].Conditions); }