Beispiel #1
0
        public override void CreateMenuItem(Canvas canvas, ButtonsInfo info)
        {
            string[] filePath = JsonMapper.ToObject <string[]> (Json["filePath"].ToJson());
            buttonImage   = new Image[filePath.Length];
            rectTransform = new RectTransform[buttonImage.Length];
            alphaAmount   = new float[buttonImage.Length];

            information = info;

            for (int i = 0; i < buttonImage.Length; i++)
            {
                GameObject buttonObject = new GameObject();
                buttonObject.name             = filePath[i];
                buttonObject.transform.parent = canvas.transform;

                buttonImage[i]             = buttonObject.AddComponent <Image> ();
                rectTransform[i]           = buttonObject.GetComponent <RectTransform> ();
                buttonImage[i].sprite      = Resources.Load(defaultPath + filePath[i], typeof(Sprite)) as Sprite;
                rectTransform[i].anchorMax = Vector2.zero;
                rectTransform[i].anchorMin = Vector2.zero;
                rectTransform[i].pivot     = new Vector2(information.pivot[0] / 2f, information.pivot[1] / 2f);

                rectTransform[i].position  = new Vector3(information.position.x * ratio_width, information.position.y * ratio_height, 0f);
                rectTransform[i].sizeDelta = new Vector2(information.size.x * ratio_width, information.size.y * ratio_height);
                buttonImage[i].color       = new Color(1, 1, 1, 0f);
            }
        }
Beispiel #2
0
        public virtual void CreateMenuItem(Canvas canvas)
        {
            string[] filePath = JsonMapper.ToObject <string[]> (Json["filePath"].ToJson());
            buttonImage   = new Image[filePath.Length];
            rectTransform = new RectTransform[buttonImage.Length];

            information          = new ButtonsInfo();
            information.position = new Vector2((float)((int)Json["position_x"]), (float)((int)Json["position_y"]));
            information.size     = new Vector2((float)((int)Json["width"]), (float)((int)Json["height"]));
            information.alpha    = JsonMapper.ToObject <float[]> (Json["alpha"].ToJson());


            for (int i = 0; i < buttonImage.Length; i++)
            {
                GameObject buttonObject = new GameObject();
                buttonObject.name             = filePath[i];
                buttonObject.transform.parent = canvas.transform;

                buttonImage[i]             = buttonObject.AddComponent <Image> ();
                rectTransform[i]           = buttonObject.GetComponent <RectTransform> ();
                buttonImage[i].sprite      = Resources.Load(defaultPath + filePath[i], typeof(Sprite)) as Sprite;
                rectTransform[i].anchorMax = Vector2.zero;
                rectTransform[i].anchorMin = Vector2.zero;
                rectTransform[i].pivot     = Vector2.zero;

                rectTransform[i].position  = new Vector3(information.position.x * ratio_width, information.position.y * ratio_height, 0f);
                rectTransform[i].sizeDelta = new Vector2(information.size.x * ratio_width, information.size.y * ratio_height);
            }
        }
Beispiel #3
0
        public virtual void CreateMenuItem(Canvas canvas, ButtonsInfo info, LabelInformation labelInfo, bool open)
        {
            string[] filePath = labelInfo.buttonImageFile;
            buttonImage   = new Image[filePath.Length];
            rectTransform = new RectTransform[buttonImage.Length];
            alphaAmount   = new float[buttonImage.Length];

            information = info;

            for (int i = 0; i < buttonImage.Length; i++)
            {
                GameObject buttonObject = new GameObject();
                buttonObject.name             = filePath[i];
                buttonObject.transform.parent = canvas.transform;

                buttonImage[i]   = buttonObject.AddComponent <Image> ();
                rectTransform[i] = buttonObject.GetComponent <RectTransform> ();
                if (open)
                {
                    buttonImage[i].sprite = Resources.Load(defaultPath + filePath[i], typeof(Sprite)) as Sprite;
                }
                else
                {
                    buttonImage[i].sprite = Resources.Load(defaultPath + "stage_notpen", typeof(Sprite)) as Sprite;
                }
                rectTransform[i].anchorMax = Vector2.zero;
                rectTransform[i].anchorMin = Vector2.zero;
                rectTransform[i].pivot     = new Vector2(information.pivot[0] / 2f, information.pivot[1] / 2f);

                rectTransform[i].position  = new Vector3(information.position.x * ratio_width, information.position.y * ratio_height, 0f);
                rectTransform[i].sizeDelta = new Vector2(information.size.x * ratio_width, information.size.y * ratio_height);
                buttonImage[i].color       = new Color(1, 1, 1, 0f);
            }
        }
Beispiel #4
0
        public override void CreateMenuItem(Canvas canvas, ButtonsInfo info)
        {
            string[] filePath = JsonMapper.ToObject <string[]> (Json["filePath"].ToJson());
            buttonSprites = new Sprite[filePath.Length];
            for (int i = 0; i < filePath.Length; i++)
            {
                buttonSprites[i] = Resources.Load(defaultPath + filePath[i], typeof(Sprite)) as Sprite;
            }
            buttonImage = new Image[1];

            information = info;

            for (int i = 0; i < buttonImage.Length; i++)
            {
                GameObject buttonObject = new GameObject();
                buttonObject.name             = filePath[i];
                buttonObject.transform.parent = canvas.transform;

                buttonImage[i]        = buttonObject.AddComponent <Image> ();
                buttonImage[i].sprite = buttonSprites[0];
                buttonImage[i].rectTransform.anchorMax = Vector2.zero;
                buttonImage[i].rectTransform.anchorMin = Vector2.zero;
                buttonImage[i].rectTransform.pivot     = new Vector2(information.pivot[0] / 2f, information.pivot[1] / 2f);

                buttonImage[i].rectTransform.position  = new Vector3(information.position.x * ratio_width, information.position.y * ratio_height, 0f);
                buttonImage[i].rectTransform.sizeDelta = new Vector2(information.size.x * ratio_width, information.size.y * ratio_height);
            }

            id = (int)Json["ID"];
        }
Beispiel #5
0
        public void CreateVariableItem(Canvas canvas, String[] files)
        {
            sprites = new Sprite[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                sprites[i] = Resources.Load(defaultPath + files[i], typeof(Sprite)) as Sprite;
            }

            buttonImage   = new Image[1];
            rectTransform = new RectTransform[buttonImage.Length];
            alphaAmount   = new float[buttonImage.Length];

            information          = new ButtonsInfo();
            information.position = new Vector2((float)((int)Json["position_x"]), (float)((int)Json["position_y"]));
            information.size     = new Vector2((float)((int)Json["width"]), (float)((int)Json["height"]));
            information.alpha    = JsonMapper.ToObject <float[]> (Json["alpha"].ToJson());

            GameObject buttonObject = new GameObject();

            buttonObject.name             = files[0];
            buttonObject.transform.parent = canvas.transform;

            buttonImage[0]             = buttonObject.AddComponent <Image> ();
            rectTransform[0]           = buttonObject.GetComponent <RectTransform> ();
            buttonImage[0].sprite      = sprites[0];
            rectTransform[0].anchorMax = Vector2.zero;
            rectTransform[0].anchorMin = Vector2.zero;
            rectTransform[0].pivot     = Vector2.zero;

            rectTransform[0].position  = new Vector3(information.position.x * ratio_width, information.position.y * ratio_height, 0f);
            rectTransform[0].sizeDelta = new Vector2(information.size.x * ratio_width, information.size.y * ratio_height);
            buttonImage[0].color       = new Color(1, 1, 1, 0f);
        }
Beispiel #6
0
        public override void CreateMenuItem(Canvas canvas)
        {
            string[] filePath = JsonMapper.ToObject <string[]> (Json["filePath"].ToJson());
            buttonImage = new Image[filePath.Length];

            information          = new ButtonsInfo();
            information.position = new Vector2((float)((int)Json["position_x"]), (float)((int)Json["position_y"]));
            information.size     = new Vector2((float)((int)Json["width"]), (float)((int)Json["height"]));
            information.pivot    = JsonMapper.ToObject <float[]> (Json["pivot"].ToJson());

            for (int i = 0; i < buttonImage.Length; i++)
            {
                GameObject buttonObject = new GameObject();
                buttonObject.name             = filePath[i];
                buttonObject.transform.parent = canvas.transform;

                buttonImage[i]        = buttonObject.AddComponent <Image> ();
                buttonImage[i].sprite = Resources.Load(defaultPath + filePath[i], typeof(Sprite)) as Sprite;
                buttonImage[i].rectTransform.anchorMax = Vector2.zero;
                buttonImage[i].rectTransform.anchorMin = Vector2.zero;
                buttonImage[i].rectTransform.pivot     = new Vector2(information.pivot[0] / 2f, information.pivot[1] / 2f);

                buttonImage[i].rectTransform.position  = new Vector3(information.position.x * ratio_width, information.position.y * ratio_height, 0f);
                buttonImage[i].rectTransform.sizeDelta = new Vector2(information.size.x * ratio_width, information.size.y * ratio_height);

                buttonImage[i].type = Image.Type.Filled;
                string method = (string)Json["fillMethod"];

                switch (method)
                {
                case    "Horizontal":
                    buttonImage[i].fillMethod = Image.FillMethod.Horizontal;
                    break;

                case    "Vertical":
                    buttonImage[i].fillMethod = Image.FillMethod.Vertical;
                    break;

                case    "Radial360":
                    buttonImage[i].fillMethod = Image.FillMethod.Radial360;
                    break;

                case    "Radial180":
                    buttonImage[i].fillMethod = Image.FillMethod.Radial180;
                    break;

                case    "Radial90":
                    buttonImage[i].fillMethod = Image.FillMethod.Radial90;
                    break;
                }

                buttonImage[i].fillOrigin = (int)Json["fillOrigin"];
                buttonImage[i].fillAmount = 0;
            }
        }
Beispiel #7
0
        public void SetButtonsInfo(ButtonsInfo targetInf)
        {
            for (int i = 0; i < buttonImage.Length; i++)
            {
                buttonImage[i].rectTransform.position  = new Vector3(targetInf.position.x, targetInf.position.y, 0f);
                buttonImage[i].rectTransform.sizeDelta = targetInf.size;
                buttonImage[i].color = new Color(buttonImage[i].color.r, buttonImage[i].color.g, buttonImage[i].color.b, targetInf.alpha[i]);
            }

            information = targetInf;
        }
Beispiel #8
0
        public virtual void StartAnimation(ButtonsInfo targetInfo, float time)
        {
            moveAmount = (targetInfo.position - information.position) / time;
            moveAmount = new Vector2(moveAmount.x * ratio_width, moveAmount.y * ratio_height);
            sizeAmount = (targetInfo.size - information.size) / time;
            sizeAmount = new Vector2(sizeAmount.x * ratio_width, sizeAmount.y * ratio_height);

            for (int i = 0; i < alphaAmount.Length; i++)
            {
                alphaAmount[i] = (targetInfo.alpha[i] - buttonImage[i].color.a) / time;
            }

            information = targetInfo;
        }
Beispiel #9
0
        public override void CreateBackGround()
        {
            counter = 30;

            TextAsset jsonAsset = Resources.Load("Data/StageSelectUIData", typeof(TextAsset)) as TextAsset;
            JsonData  jsonData  = JsonMapper.ToObject(jsonAsset.text);

            cursor      = new Cursor();
            cursor.Json = jsonData["cursor"];
            cursor.CreateMenuItem(canvas);
            cursor.StartAnimation(new float[1] {
                1
            }, (float)counter);
            labelList.Add(cursor);

            explanatoryText = new ChangeLabel();
            //explanatoryText.Json = jsonData["explanatoryText"];
            labelList.Add(explanatoryText);

            string[] files = new string[dataManager.stageData.Length];
            for (int i = 0; i < files.Length; i++)
            {
                if (dataManager.stageData[i].open)
                {
                    files[i] = dataManager.stageData[i].labelInfo.stageImageFile;
                }
                else
                {
                    files[i] = "stage_silhouette";
                }
            }
            Image img = canvas.gameObject.transform.Find("Image").GetComponent <Image> ();

            explanatoryText.CreateVariableItem(img, files);

            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);
            }

            JsonData data = jsonData["buttonInfo"];

            buttonsInfo       = new ButtonsInfo[dataManager.stageData.Length];
            cursor.max_number = buttonsInfo.Length;
            cursor.select     = 2;

            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());
            }

            buttonsInfo[2].size  = new Vector2((int)data["select_width"], (int)data["select_height"]);
            buttonsInfo[2].alpha = JsonMapper.ToObject <float[]> (data["select_alpha"].ToJson());
            buttonsInfo[0].alpha = new float[2] {
                0, 0
            };
            for (int i = 5; i < buttonsInfo.Length; i++)
            {
                buttonsInfo[i].alpha = new float[2] {
                    0, 0
                };
            }

            for (int i = 0; i < 2; i++)
            {
                AnimationButton button = new AnimationButton();
                buttonList.Add(button);
                button.SetID(dataManager.stageData.Length - i - 1);
                button.CreateMenuItem(canvas, buttonsInfo[i], dataManager.stageData[dataManager.stageData.Length - i - 1].labelInfo,
                                      dataManager.stageData[dataManager.stageData.Length - i - 1].open);
                button.StartAnimation(buttonsInfo[i], (float)counter);
                button.order = i;
            }


            for (int i = 0; i < dataManager.stageData.Length - 2; i++)
            {
                AnimationButton button = new AnimationButton();
                buttonList.Add(button);
                button.SetID(i);
                button.CreateMenuItem(canvas, buttonsInfo[i + 2], dataManager.stageData[i].labelInfo,
                                      dataManager.stageData[i].open);
                button.StartAnimation(buttonsInfo[i + 2], (float)counter);
                button.order = i + 2;
            }

            explanatoryText.ChangeSprite(buttonList[cursor.select].id);
        }
Beispiel #10
0
 public override void CreateMenuItem(Canvas canvas, ButtonsInfo info)
 {
     base.CreateMenuItem(canvas, info);
     id = (int)Json["ID"];
 }
Beispiel #11
0
        public override void CreateMenuItem(Canvas canvas)
        {
            imageList   = new List <Image> ();
            nameSprites = new Sprite[characters.Length];

            for (int i = 0; i < characters.Length; i++)
            {
                nameSprites[i] = Resources.Load(defaultPath + characters[i].labelInfo.buttonImageFile[0], typeof(Sprite)) as Sprite;
            }

            buttonImage   = new Image[1];
            rectTransform = new RectTransform[buttonImage.Length];
            alphaAmount   = new float[buttonImage.Length];

            information = new ButtonsInfo();
            float[] array = JsonMapper.ToObject <float[]> (Json["position"].ToJson());
            information.position = new Vector2(array[0], array[1]);

            array             = JsonMapper.ToObject <float[]> (Json["size"].ToJson());
            information.size  = new Vector2(array[0], array[1]);
            information.alpha = JsonMapper.ToObject <float[]> (Json["alpha"].ToJson());

            GameObject buttonObject = new GameObject();

            buttonObject.name             = (string)Json["filePath"];
            buttonObject.transform.parent = canvas.transform;

            buttonImage[0]             = buttonObject.AddComponent <Image> ();
            rectTransform[0]           = buttonObject.GetComponent <RectTransform> ();
            buttonImage[0].sprite      = Resources.Load(defaultPath + (string)Json["filePath"], typeof(Sprite)) as Sprite;
            rectTransform[0].anchorMax = Vector2.zero;
            rectTransform[0].anchorMin = Vector2.zero;
            rectTransform[0].pivot     = Vector2.zero;

            rectTransform[0].position  = new Vector3(information.position.x * ratio_width, information.position.y * ratio_height, 0f);
            rectTransform[0].sizeDelta = new Vector2(information.size.x * ratio_width, information.size.y * ratio_height);
            buttonImage[0].color       = new Color(1, 1, 1, 0f);

            imageList.Add(buttonImage [0]);

            GameObject obj = new GameObject();

            obj.name             = "name";
            obj.transform.parent = buttonImage[0].gameObject.transform;

            nameImage        = obj.AddComponent <Image> ();
            nameImage.sprite = nameSprites[0];
            RectTransform rectTran = nameImage.GetComponent <RectTransform> ();

            rectTran.anchorMax = Vector2.zero;
            rectTran.anchorMin = Vector2.zero;
            rectTran.pivot     = Vector2.zero;

            imageList.Add(nameImage);

            float[] pos = JsonMapper.ToObject <float[]> (Json["name_position"].ToJson());
            rectTran.position = new Vector3(rectTransform[0].position.x + pos[0] * ratio_width, rectTransform[0].position.y + pos[1] * ratio_height, 0f);
            float[] size = JsonMapper.ToObject <float[]> (Json["name_size"].ToJson());
            rectTran.sizeDelta = new Vector2(size[0] * ratio_width, size[1] * ratio_height);
            nameImage.color    = new Color(1, 1, 1, 0f);

            GameObject temp = Resources.Load("Prefabs/Text_outline", typeof(GameObject)) as GameObject;

            obj = MonoBehaviour.Instantiate(temp) as GameObject;
            obj.transform.SetParent(buttonImage[0].gameObject.transform);
            obj.name = "level";

            level          = obj.GetComponent <Text> ();
            level.text     = characters[0].status.level.ToString();
            level.fontSize = (int)(((float)(int)Json["font_size"]) * ratio_width);

            pos  = JsonMapper.ToObject <float[]> (Json["font_position"].ToJson());
            size = JsonMapper.ToObject <float[]> (Json["font_color"].ToJson());

            level.rectTransform.position = new Vector3(rectTransform[0].position.x + pos[0] * ratio_width, rectTransform[0].position.y + pos[1] * ratio_height, 0f);
            level.color = new Color(size[0] / 255f, size[1] / 255f, size[2] / 255f, 0f);

            float[] charaStatus = new float[3] {
                characters [0].status.hp,
                characters [0].status.attack,
                characters [0].status.defense
            };

            statusImage = new Image[3];
            for (int i = 0; i < statusImage.Length; i++)
            {
                GameObject gaugeObject = new GameObject();
                gaugeObject.name             = "gauge00" + i.ToString();
                gaugeObject.transform.parent = buttonImage[0].gameObject.transform;

                statusImage[i]        = gaugeObject.AddComponent <Image> ();
                statusImage[i].sprite = Resources.Load(defaultPath + (string)Json["gauge_name"], typeof(Sprite)) as Sprite;

                rectTran           = gaugeObject.GetComponent <RectTransform> ();
                rectTran.anchorMax = Vector2.zero;
                rectTran.anchorMin = Vector2.zero;
                rectTran.pivot     = Vector2.zero;

                pos  = JsonMapper.ToObject <float[]> (Json["gauge_position"].ToJson());
                size = JsonMapper.ToObject <float[]> (Json["gauge_size"].ToJson());
                float[] dis = JsonMapper.ToObject <float[]> (Json["distance"].ToJson());

                rectTran.position  = new Vector3(rectTransform[0].position.x + pos[0] * ratio_width, rectTransform[0].position.y + pos[1] * ratio_height, 0f);
                rectTran.position += new Vector3(i * dis[0] * ratio_width, i * dis[1] * ratio_height, 0f);
                rectTran.sizeDelta = new Vector2(size[0] * ratio_width, size[1] * ratio_height);

                statusImage[i].type       = Image.Type.Filled;
                statusImage[i].fillMethod = Image.FillMethod.Horizontal;
                statusImage[i].fillAmount = charaStatus[i] / 999f;

                statusImage[i].color = new Color(1, 1, 1, 0f);

                imageList.Add(statusImage[i]);
            }
        }
Beispiel #12
0
        public override void CreateBackGround()
        {
            counter = 30;

            TextAsset jsonAsset = Resources.Load("Data/TitleUIData", typeof(TextAsset)) as TextAsset;
            JsonData  jsonData  = JsonMapper.ToObject(jsonAsset.text);

            cursor      = new Cursor();
            cursor.Json = jsonData["cursor"];
            cursor.CreateMenuItem(canvas);
            cursor.StartAnimation(new float[1] {
                1
            }, (float)counter);
            labelList.Add(cursor);

            explanatoryText      = new ChangeLabel();
            explanatoryText.Json = jsonData["explanatoryText"];
            explanatoryText.CreateMenuItem(canvas);
            explanatoryText.StartAnimation(new float[1] {
                1
            }, (float)counter);
            labelList.Add(explanatoryText);

            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);
            }

            JsonData data = jsonData["buttonInfo"];

            jsonArray = JsonMapper.ToObject <JsonData[]> (jsonData["buttons"].ToJson());

            buttonsInfo       = new ButtonsInfo[jsonArray.Length + 1];
            cursor.max_number = buttonsInfo.Length;
            cursor.select     = 2;

            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());
            }

            buttonsInfo[2].size  = new Vector2((int)data["select_width"], (int)data["select_height"]);
            buttonsInfo[2].alpha = JsonMapper.ToObject <float[]> (data["select_alpha"].ToJson());
            buttonsInfo[0].alpha = new float[2] {
                0, 0
            };
            buttonsInfo[buttonsInfo.Length - 1].alpha = new float[2] {
                0, 0
            };

            for (int i = 0; i < 2; i++)
            {
                AnimationButton button = new AnimationButton();
                button.Json = jsonArray[jsonArray.Length - 1 - i];
                buttonList.Add(button);
                button.CreateMenuItem(canvas, buttonsInfo[i]);
                button.StartAnimation(buttonsInfo[i], (float)counter);
                button.order = i;
            }

            for (int i = 0; i < jsonArray.Length - 1; i++)
            {
                AnimationButton button = new AnimationButton();
                button.Json = jsonArray[i];
                buttonList.Add(button);
                button.CreateMenuItem(canvas, buttonsInfo[i + 2]);
                button.StartAnimation(buttonsInfo[i + 2], (float)counter);
                button.order = i + 2;
            }

            explanatoryText.ChangeSprite(buttonList[cursor.select].id);
        }