public override void CreateBackGround() { counter = 30; TextAsset jsonAsset = Resources.Load("Data/GalleryUIData", typeof(TextAsset)) as TextAsset; JsonData jsonData = JsonMapper.ToObject(jsonAsset.text); imageList = new ImageList(); imageList.Json = jsonData["imagelistInfo"]; imageList.CreateImageList(canvas); cursor_a = new AnimationCursor(); cursor_a.Json = jsonData["cursor"]; cursor_a.CreateMenuItem(canvas); labelList.Add(cursor_a); cursor_a.StartAnimation(new float[1] { 1 }, (float)counter); previewImage = new Image[2]; for (int i = 0; i < previewImage.Length; i++) { GameObject obj = new GameObject(); obj.name = "previewImage"; obj.transform.SetParent(canvas.transform); previewImage[i] = obj.AddComponent <Image> (); previewImage[i].rectTransform.anchorMax = Vector2.zero; previewImage[i].rectTransform.anchorMin = Vector2.zero; previewImage[i].rectTransform.position = new Vector3(Screen.width / 2f, Screen.height / 2f, 0f); previewImage[i].rectTransform.sizeDelta = new Vector2(Screen.width, Screen.height); previewImage[i].color = new Color(1, 1, 1, 0); } previewImage[0].sprite = Resources.Load("UserInterface/fade", typeof(Sprite)) as Sprite; JsonData[] jsonArray = JsonMapper.ToObject <JsonData[]> (jsonData["labels"].ToJson()); foreach (JsonData array in jsonArray) { AnimationLabel label = new AnimationLabel(); label.Json = array; labelList.Add(label); label.CreateMenuItem(canvas); label.StartAnimation(new float[1] { 1 }, (float)counter); } remarkText = new BaseText(); remarkText.Json = jsonData["text"]; remarkText.CreateText(canvas); cursor_a.max_number = imageList.textData.Length; cursor_a.SetCursorPosition(imageList.ChangeSelectImage(0)); remarkText.ChangeText(imageList.textData [0]); }
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); }