Beispiel #1
0
        internal void GiveStartingItems(PlayerCharacterMasterController player)
        {
            RoR2.Chat.AddMessage($"Giving {player.GetDisplayName()} a care package");

            const int whiteItems = 5;
            const int greenItems = 3;
            const int redItems   = 0;

            for (int i = 0; i < whiteItems; i++)
            {
                //And then finally drop it infront of the player.
                CreatePickup(player, GetRandomPickup(1));
            }

            for (int i = 0; i < greenItems; i++)
            {
                //And then finally drop it infront of the player.
                CreatePickup(player, GetRandomPickup(2));
            }

            for (int i = 0; i < redItems; i++)
            {
                //And then finally drop it infront of the player.
                CreatePickup(player, GetRandomPickup(3));
            }
        }
        public IEnumerator WatchInventory(PlayerCharacterMasterController pcmc)
        {
            yield return(new WaitUntil(() => { return pcmc.master.inventory != null; }));

            string name = pcmc.GetDisplayName() ?? pcmc.name;

            DebugChat("Configuring Player " + name + " inventory");

            On.RoR2.Language.GetString_string += (orig, self) =>
            {
                if (_languageItemPickupRegex.IsMatch(self))
                {
                    var ii = GetItemFromFriendlyName(self);
                    var ic = GetItemCalculation(ii);

                    DebugChat("Item Index: " + ii.ToString());

                    if (ic != null)
                    {
                        var results        = ic.Evaluate(pcmc.master.inventory.GetItemCount(ii));
                        var newDescription = orig(self) + Environment.NewLine + Environment.NewLine;

                        foreach (var r in results)
                        {
                            newDescription += String.Format("{0} value is {1}{2}", r.Property, StyleText(r.Result.ToString("0.##") + r.Unit, r.TextStyle), Environment.NewLine);
                        }

                        return(newDescription);
                    }
                }

                return(orig(self));
            };
        }
Beispiel #3
0
        public void Start()
        {
            BarInstances.Add(player, this);

            container = new GameObject("container");
            container.transform.SetParent(gameObject.transform);

            RectTransform containerRect = container.AddComponent <RectTransform>();

            containerRect.sizeDelta = new Vector2(300, 22);
            containerRect.anchorMin = new Vector2(0, 0);
            containerRect.anchorMax = new Vector2(1, 1);
            containerRect.pivot     = new Vector2(0, 0);
            LayoutElement containerLayout = container.AddComponent <LayoutElement>();

            containerLayout.preferredWidth  = 300;
            containerLayout.preferredHeight = 22;
            VerticalLayoutGroup containerGroup = container.AddComponent <VerticalLayoutGroup>();

            containerGroup.childControlWidth      = true;
            containerGroup.childForceExpandWidth  = false;
            containerGroup.childControlHeight     = true;
            containerGroup.childForceExpandHeight = false;

            bar = new GameObject("bar");
            bar.transform.SetParent(container.transform);
            RectTransform barRect = bar.AddComponent <RectTransform>();

            barRect.anchorMin = new Vector2(0, 0);
            barRect.anchorMax = new Vector2(1, 1);
            barRect.pivot     = new Vector2(0, 0);
            barRect.sizeDelta = new Vector2(300, 22);
            Image barImage = bar.AddComponent <Image>();

            barImage.sprite     = Resources.Load <GameObject>("Prefabs/UI/Tooltip").GetComponentInChildren <TranslucentImage>(true).sprite;
            barImage.color      = colors[new System.Random().Next(colors.Count)];
            barImage.type       = Image.Type.Sliced;
            barImage.fillCenter = true;
            LayoutElement barLayout = bar.AddComponent <LayoutElement>();

            barLayout.preferredWidth  = 300;
            barLayout.preferredHeight = 22;

            nameTextObject = new GameObject("name");
            nameTextObject.transform.SetParent(container.transform);
            RectTransform nameRect = nameTextObject.AddComponent <RectTransform>();

            nameRect.anchorMin = new Vector2(0, 0);
            nameRect.anchorMax = new Vector2(1, 1);
            nameRect.pivot     = new Vector2(0, 0.5f);
            HGTextMeshProUGUI nameMesh = nameTextObject.AddComponent <HGTextMeshProUGUI>();

            nameMesh.fontSize     = 16;
            nameMesh.color        = LocalUserManager.GetFirstLocalUser().cachedMasterController.GetDisplayName().Equals(NameText) ? Color.yellow : Color.white;
            nameMesh.outlineWidth = 0.5f;
            nameMesh.text         = player.GetDisplayName();
            nameMesh.alignment    = TMPro.TextAlignmentOptions.MidlineLeft;
            nameMesh.margin       = new Vector4(3, 0, 0, 0);
            nameTextObject.AddComponent <LayoutElement>().ignoreLayout = true;

            valueTextObject = new GameObject("value");
            valueTextObject.transform.SetParent(container.transform);
            RectTransform valueRect = valueTextObject.AddComponent <RectTransform>();

            valueRect.anchorMin = new Vector2(0, 0);
            valueRect.anchorMax = new Vector2(1, 1);
            valueRect.pivot     = new Vector2(1, 0.5f);
            HGTextMeshProUGUI valueMesh = valueTextObject.AddComponent <HGTextMeshProUGUI>();

            valueMesh.fontSize  = 16;
            valueMesh.color     = Color.white;
            valueMesh.text      = ValueText;
            valueMesh.alignment = TMPro.TextAlignmentOptions.MidlineRight;
            valueMesh.margin    = new Vector4(0, 0, 3, 0);
            valueTextObject.AddComponent <LayoutElement>().ignoreLayout = true;

            foreach (TrackingDef def in RoRecount.TrackingDefs)
            {
                BaseTrackingStat stat = container.AddComponent(def.type) as BaseTrackingStat;
                if (!trackers.ContainsKey(stat.type))
                {
                    trackers.Add(stat.type, new List <BaseTrackingStat>());
                }
                trackers[stat.type].Add(stat);
            }
        }