Ejemplo n.º 1
0
        private void PossiblyAddParseCommandOutputToDialog(Dialog.DialogOption option)
        {
            if (Print_commandOutput.Length == 0)
            {
                return;
            }
            string     str = Print_commandOutput.ToString();
            ListItemUi li  = listUi.AddItem(option, str, null, prefab_textUi);

            Print_commandOutput.Clear();
        }
Ejemplo n.º 2
0
    public ListItemUi AddItem(GameObject itemObject)
    {
        if (pickupParticle == null)
        {
            pickupParticle = Global.Get <ParticleSystems>().Get("circdir");
        }
        if (pickupParticle != null)
        {
            pickupParticle.transform.position = itemObject.transform.position;
            pickupParticle.transform.LookAt(transform);
            pickupParticle.Emit(10);
        }
        items.Add(itemObject);
        itemObject.SetActive(false);
        itemObject.transform.SetParent(transform);
        if (inventoryUi == null)
        {
            return(null);
        }
        InventoryItem item = itemObject.GetComponent <InventoryItem>();
        string        name = item != null ? item.itemName : null;

        if (string.IsNullOrEmpty(name))
        {
            name = itemObject.name;
        }
        return(inventoryUi.AddItem(itemObject, name, () => {
            RemoveItem(itemObject);
            inventoryUi.RemoveItem(itemObject);
        }));
    }
Ejemplo n.º 3
0
    public ListItemUi AddDialogOption(Dialog.DialogOption option, bool scrollAllTheWayDown)
    {
        if (!initialized)
        {
            Init();
        }
        ListItemUi li = null;

        do
        {
            Dialog.Text t = option as Dialog.Text;
            if (t != null)
            {
                li = listUi.AddItem(option, scriptedVariableScope.Format(t.text), null, prefab_textUi);
                break;
            }
            Dialog.Choice c = option as Dialog.Choice;
            if (c != null)
            {
                li = listUi.AddItem(option, scriptedVariableScope.Format(c.text), () => ParseCommand(c.command), prefab_buttonUi);
                currentChoices.Add(li);
                break;
            }
            Dialog.Command cmd = option as Dialog.Command;
            if (cmd != null)
            {
                ParseCommand(cmd.command);
                break;
            }
        }while (false);
        if (li != null)
        {
            li.text.alignment = option.anchorText;
        }
        if (scrollAllTheWayDown && !goingToScrollAllTheWayDown)
        {
            goingToScrollAllTheWayDown = true;
            // we want scroll all the way down, and can't control when the UI updates enough to realize it can scroll
            NonStandard.Clock.setTimeout(() => {
                goingToScrollAllTheWayDown = false; scrollRect.verticalNormalizedPosition = 0;
            }, 100);
            // 100ms (1/10th of a second) is not bad for UI lag, and should be enough time for the UI to update itself
        }
        return(li);
    }
Ejemplo n.º 4
0
        public ListItemUi AddItem(GameObject itemObject)
        {
            if (items == null)
            {
                items = new List <GameObject>();
            }
            if (inventoryUi != null)
            {
                ListItemUi result = inventoryUi.GetListItemUi(itemObject); if (result != null)
                {
                    return(result);
                }
            }
            items.Add(itemObject);
            InventoryItem item = itemObject.GetComponent <InventoryItem>();

            if (item != null)
            {
                item.AddToInventory(this);
            }
            itemObject.SetActive(false);
            Vector3 playerLoc     = Global.GetComponent <Character.CharacterProxy>().transform.position;
            Vector3 localPosition = itemObject.transform.position - playerLoc;

            itemObject.transform.SetParent(transform);
            itemObject.transform.localPosition = localPosition;
            //Show.Log("POS IN" + localPosition);
            string name = item != null ? item.itemName : null;

            if (string.IsNullOrEmpty(name))
            {
                name = itemObject.name;
            }
            onAddItem.Invoke(itemObject);
            if (inventoryUi == null)
            {
                return(null);
            }
            return(inventoryUi.AddItem(itemObject, name, () => {
                RemoveItem(itemObject);
            }));
        }
Ejemplo n.º 5
0
    public ListItemUi AddMember(GameObject memberObject)
    {
        //Show.Log("adding member " + memberObject);
        if (members == null)
        {
            members = new List <GameObject>();
        }
        // make sure this character adds to the communal inventory! (assuming there is one)
        TeamMember teamMember = memberObject.GetComponent <TeamMember>();

        if (teamMember == null)
        {
            teamMember = memberObject.AddComponent <TeamMember>();
        }
        // add them to the roster
        if (members.IndexOf(memberObject) < 0)
        {
            members.Add(memberObject);
            teamMember.onJoinTeam?.Invoke(this);
            CharacterRoot cr = memberObject.GetComponent <CharacterRoot>();
            if (cr)
            {
                EventBind.IfNotAlready(cr.activateFunction, this, ActivateTeamMember);
            }
        }
        if (members.Count > 1)
        {
            if (prev)
            {
                prev.gameObject.SetActive(true);
            }
            if (next)
            {
                next.gameObject.SetActive(true);
            }
            if (team)
            {
                team.gameObject.SetActive(true);
            }
        }
        if (rosterUi != null)
        {
            ListItemUi result = rosterUi.GetListItemUi(memberObject);
            if (result != null)
            {
                //Show.Log("already ui");
                return(result);
            }
        }
        string name = teamMember != null ? teamMember.name : null;

        if (string.IsNullOrEmpty(name))
        {
            name = memberObject.name;
        }

        Interact3dItem i3i = teamMember.GetComponent <Interact3dItem>();
        //void ActivateTeamMember() {
        //	CharacterControlManager ccm = Global.Get<CharacterControlManager>();
        //	ccm.SetCharacter(memberObject);
        //	i3i.showing = false;
        //}
        Action activateMember = () => ActivateTeamMember(memberObject);

        if (i3i != null)
        {
            i3i.OnInteract             = activateMember;
            i3i.Text                   = "switch";
            i3i.internalState.alwaysOn = true;
        }
        if (rosterUi == null)
        {
            Show.Log("missing roster UI");
            return(null);
        }
        return(rosterUi.AddItem(memberObject, name, activateMember));
    }