Esempio n. 1
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);
        }
Esempio n. 2
0
        void AddMagicsToContainer(GameObject container)
        {
            float zOrder = 2f;

            float intervalX = -8f;
            float intervalY = 1.7f;

            float startX = 9.0f;
            float startY = -2.55f;

            float xOffsetName = -0.5f;
            float xOffsetCost = -4f;

            Vector3 scale = new Vector3(0.35f, 0.35f, 1);

            for (int i = 0; i < creature.Data.Magics.Count; i++)
            {
                int             magicId = creature.Data.Magics[i];
                MagicDefinition magic   = DefinitionStore.Instance.GetMagicDefinition(magicId);

                if (magic == null)
                {
                    continue;
                }

                int x = i / 4;
                int y = i % 4;

                float baseX = startX + intervalX * x;
                float baseY = startY + intervalY * y;

                // Name
                int    val  = i;
                string name = LocalizedStrings.GetMagicName(magicId);
                AddText(name, container.transform, new Vector3(baseX + xOffsetName, zOrder, baseY), scale,
                        () => { this.OnSelectClicked(val); });

                // Cost
                AddText("-MP " + StringUtils.Digit3(magic.MpCost), container.transform, new Vector3(baseX + xOffsetCost, zOrder, baseY), scale);
            }
        }