コード例 #1
0
        public void Initialize(Camera camera, FDCreature creature, ShowType showType, Action <int> callback)
        {
            this.gameObject.name = "CreatureDialog";

            canvas.worldCamera = camera;
            this.camera        = camera;

            this.creature   = creature;
            this.showType   = showType;
            this.onCallback = callback;

            containerBase = this.transform.Find("Canvas/ContainerBase");
            Clickable clickable = containerBase.GetComponent <Clickable>();

            clickable.Initialize(() => { this.OnClicked(); });

            creatureDetailBase = this.transform.Find("Canvas/CreatureDetail");
            clickable          = creatureDetailBase.gameObject.GetComponent <Clickable>();
            clickable.Initialize(() => { this.OnCancelled(); });
            datoBase    = this.transform.Find("Canvas/DatoBase");
            datoControl = GameObjectExtension.CreateFromPrefab <DatoControl>("Prefabs/DatoControl");
            datoControl.Initialize(datoBase, creature.Definition.AnimationId, new Vector2(0, 0));
            //// datoControl.transform.localPosition = new Vector3(0, 0, 0);

            RenderDetails();

            if (IsItemDialog)
            {
                RenderItemsContainer();
            }
            else
            {
                RenderMagicsContainer();
            }
        }
コード例 #2
0
        protected void IntialText(GameObject textObj, Transform subDialog, Vector3 position, Vector3 scale, Action action = null)
        {
            textObj.transform.SetParent(subDialog);
            textObj.layer = 5; //UI
            textObj.transform.localPosition = position;
            textObj.transform.localScale    = scale;

            TextMeshProUGUI container = textObj.GetComponent <TextMeshProUGUI>();
            //// container.bounds.size = new Vector3(50, 5, 1);

            RectTransform container2 = textObj.GetComponent <RectTransform>();

            //// container2.

            // container = 120;

            if (action != null)
            {
                BoxCollider collider = textObj.AddComponent <BoxCollider>();

                //float scaleFactor = 1.8f;
                //collider.size = new Vector3((float)(renderer.bounds.size.x / scaleFactor), 1, (float)(renderer.bounds.size.y / scaleFactor));
                collider.size = new Vector3(2f, 1, 2f);

                Clickable clickable = textObj.AddComponent <Clickable>();
                clickable.Initialize(() => { action(); });
            }
        }
コード例 #3
0
        protected GameObject AddControl(string resourceName, Transform subDialog, Vector3 position, Vector3 scale, Action action = null)
        {
            GameObject prefab  = Resources.Load <GameObject>(resourceName);
            GameObject control = GameObject.Instantiate(prefab);

            control.transform.parent = subDialog;
            control.layer            = 5; //UI

            GameObject defaultObject = control.transform.Find(@"default").gameObject;

            defaultObject.layer             = 5;
            control.transform.localPosition = position;
            control.transform.localScale    = scale;
            control.transform.localRotation = Quaternion.Euler(0, 0, 0);

            Renderer renderer = defaultObject.GetComponent <Renderer>();

            if (action != null)
            {
                BoxCollider collider = control.AddComponent <BoxCollider>();

                //float scaleFactor = 1.8f;
                //collider.size = new Vector3((float)(renderer.bounds.size.x / scaleFactor), 1, (float)(renderer.bounds.size.y / scaleFactor));
                collider.size = new Vector3(2f, 1, 2f);

                Clickable clickable = control.AddComponent <Clickable>();
                clickable.Initialize(() => { action(); });
            }

            return(control);
        }
コード例 #4
0
        public void Initialize(Camera camera, int animationId, string message, Action <int> callback)
        {
            this.gameObject.name = "PromptDialog";

            canvas.worldCamera   = camera;
            this.onClickCallback = callback;


            GameObject messageBoxBase = this.transform.Find("Canvas/MessageBase").gameObject;

            messageBoxBase.transform.localPosition = new Vector2(0, -150);
            Clickable clickable = messageBoxBase.AddComponent <Clickable>();

            clickable.Initialize(() => { this.OnClicked(); });

            localizedMessage = message;

            localizedMessage = localizedMessage.Replace("#", "\r\n");
            datoControl      = GameObjectExtension.CreateFromPrefab <DatoControl>("Prefabs/DatoControl");
            datoControl.Initialize(messageBoxBase.transform, animationId, new Vector2(-230, -150), true);

            textObj = FontAssets.ComposeTextMeshObject(localizedMessage);


            Transform textAnchor = this.transform.Find("Canvas/TextAnchor");

            textObj.transform.parent        = textAnchor;
            textObj.transform.localPosition = new Vector3(0, 0, 0);
            textObj.transform.localScale    = new Vector3(5, 5, 1);
            textObj.gameObject.layer        = 5;
            // textObj.fontSize = 20;

            displayLength = 4;
            textObj.text  = localizedMessage.Substring(0, 4);
        }
コード例 #5
0
        public void Initialize(Canvas canvas, int magicId, Action onClicked = null)
        {
            this.transform.parent = canvas.transform;
            this.indicator        = this.transform.Find("SelectionIndicator");
            SetSelected(false);

            // canvas.worldCamera = camera;
            // this.canvas = canvas;

            this.magic = DefinitionStore.Instance.GetMagicDefinition(magicId);
            if (this.magic == null)
            {
                throw new ArgumentException("Cannot find magic definition with ID=" + magicId);
            }

            if (onClicked != null)
            {
                Clickable clickable = indicator.GetComponent <Clickable>();
                clickable.Initialize(onClicked);
            }

            // Name
            string      name = LocalizedStrings.GetMagicName(magicId);
            TextMeshPro text = RenderText(name, "Name", FontAssets.FontSizeType.Normal);

            text.transform.localScale = new Vector3(7, 7, 7);

            // Description
            string      description     = GetMagicDescription(this.magic);
            TextMeshPro descriptionText = RenderText(description, "Description", FontAssets.FontSizeType.Normal);

            descriptionText.transform.localScale = new Vector3(5, 5, 5);
        }
コード例 #6
0
        public void Initialize(Canvas canvas, int itemId, bool isEquiped = false, Action onClicked = null)
        {
            this.transform.parent = canvas.transform;
            this.indicator        = this.transform.Find("SelectionIndicator");
            SetSelected(false);

            // canvas.worldCamera = camera;
            // this.canvas = canvas;

            this.item = DefinitionStore.Instance.GetItemDefinition(itemId);
            if (this.item == null)
            {
                throw new ArgumentException("Cannot find item definition with ID=" + itemId);
            }

            this.isEquiped = isEquiped;

            if (onClicked != null)
            {
                Clickable clickable = indicator.GetComponent <Clickable>();
                clickable.Initialize(onClicked);
            }

            // Icon
            Transform iconObject = this.transform.Find("Icon");
            Image     iconImage  = iconObject.GetComponent <Image>();

            string iconKey = string.Empty;

            if (this.item is AttackItemDefinition)
            {
                iconKey = "Attack";
            }
            else if (this.item is DefendItemDefinition)
            {
                iconKey = "Defend";
            }
            else
            {
                iconKey = "Usable";
            }

            int    equiped  = isEquiped ? 1 : 0;
            string iconName = string.Format(@"OthersLegacy/Item{0}Icon_{1}", iconKey, equiped);

            iconImage.sprite = LoadSprite(iconName, 24, 20);

            // Name
            string      name = LocalizedStrings.GetItemName(itemId);
            TextMeshPro text = RenderText(name, "Name", FontAssets.FontSizeType.Normal);

            text.transform.localScale = new Vector3(7, 7, 7);

            // Description
            string      description     = GetItemDescription(this.item);
            TextMeshPro descriptionText = RenderText(description, "Description", FontAssets.FontSizeType.Normal);

            descriptionText.transform.localScale = new Vector3(5, 5, 5);
        }
コード例 #7
0
        public void Initialize(Camera camera, Vector2 popupPosition, int animationId, string message, Action <int> callback, int forChapterId = 0)
        {
            this.gameObject.name = "MessageDialog";

            canvas.worldCamera   = camera;
            this.onClickCallback = callback;

            if (animationId > 500)
            {
                dialogPosition = MessageDialogPosition.UP;
            }

            messageBoxBase = this.transform.Find("Canvas/MessageBase").gameObject;
            messageBoxBase.transform.localPosition = GetBasePosition(dialogPosition);
            Clickable clickable = messageBoxBase.GetComponent <Clickable>();

            clickable.Initialize(() => { this.OnClicked(); });

            PopUp popUp = messageBoxBase.GetComponent <PopUp>();

            popUp.Initialize(popupPosition);

            localizedMessage = message;

            localizedMessage = localizedMessage.Replace("#", "\r\n");
            datoControl      = GameObjectExtension.CreateFromPrefab <DatoControl>("Prefabs/DatoControl");
            datoControl.Initialize(messageBoxBase.transform, animationId, GetDatoPosition(dialogPosition), (dialogPosition == MessageDialogPosition.DOWN));

            if (forChapterId > 0)
            {
                textObj = FontAssets.ComposeTextMeshObjectForChapter(forChapterId, localizedMessage);
            }
            else
            {
                textObj = FontAssets.ComposeTextMeshObject(localizedMessage);
            }

            Transform textAnchor = this.transform.Find("Canvas/MessageBase/TextAnchor");

            textAnchor.localPosition = GetTextPosition(dialogPosition);

            textObj.transform.parent = textAnchor;
            //textObj.transform.localPosition = new Vector2(190, -50);
            textObj.transform.localPosition = new Vector3(0, 0, 0);
            textObj.transform.localScale    = new Vector3(5, 5, 1);
            textObj.gameObject.layer        = 5;
            // textObj.fontSize = 20;

            displayLength = 1;
            textObj.text  = localizedMessage.Substring(0, 1);
        }