コード例 #1
0
        public static void AddItem(string item, string location)
        {
            if (canvas == null)
            {
                Create();
            }

            item = RandomizerMod.Instance.Settings.GetEffectiveItem(item);

            string itemName = Language.Language.Get(LogicManager.GetItemDef(item).nameKey, "UI");
            string areaName = LogicManager.ShopNames.Contains(location)
                ? location.Replace('_', ' ')
                : RandoLogger.CleanAreaName(LogicManager.GetItemDef(location).areaName);

            string msg = itemName + "\nfrom " + areaName;

            GameObject basePanel = CanvasUtil.CreateBasePanel(canvas,
                                                              new CanvasUtil.RectData(new Vector2(200, 50), Vector2.zero,
                                                                                      new Vector2(0.9f, 0.9f), new Vector2(0.9f, 0.9f)));

            string spriteKey = LogicManager.GetItemDef(item).shopSpriteKey;

            CanvasUtil.CreateImagePanel(basePanel, RandomizerMod.GetSprite(spriteKey),
                                        new CanvasUtil.RectData(new Vector2(50, 50), Vector2.zero, new Vector2(0f, 0.5f),
                                                                new Vector2(0f, 0.5f)));
            CanvasUtil.CreateTextPanel(basePanel, msg, 24, TextAnchor.MiddleLeft,
                                       new CanvasUtil.RectData(new Vector2(400, 100), Vector2.zero,
                                                               new Vector2(1.2f, 0.5f), new Vector2(1.2f, 0.5f)),
                                       CanvasUtil.GetFont("Perpetua"));

            items.Enqueue(basePanel);
            if (items.Count > MaxItems)
            {
                Object.Destroy(items.Dequeue());
            }

            UpdatePositions();
        }