示例#1
0
    void UpdateInventory(Actor a)
    {
        for (int i = 0; i < _categories[2].transform.Find("list").childCount; i++)
        {
            Destroy(_categories[2].transform.Find("list").GetChild(i).gameObject);
        }

        for (int i = 0; i < a.data.inventorySize; i++)
        {
            Item       item = a.data.GetItem(i);
            GameObject g    = Instantiate(_inventoryItem, _categories[2].transform.Find("list"));

            g.transform.Find("header").GetComponent <Text>().text = item == null ?  "Empty" : item.NameToString();

            if (a.data.GetItem(i) != null)
            {
                g.GetComponent <GenericPointerHandler>().Initialize(
                    () => Tooltip.Open(item.ToTooltip()),
                    null,
                    null,
                    null,
                    () => Tooltip.Close());
            }
            else
            {
                g.GetComponent <GenericPointerHandler>().Initialize(
                    null,
                    null,
                    null,
                    null,
                    null);
            }
        }
    }
示例#2
0
    void UpdateAvailableTargets(ActionContext context)
    {
        ClearAvailableTargets();

        for (int i = 0; i < context.actors.Count; i++)
        {
            Actor      a = context.actors[i];
            GameObject g = Instantiate(_targetItem, _targets);

            g.GetComponent <GenericPointerHandler>().Initialize(
                () => {
                GlobalEvents.Raise(GlobalEvent.JumpCameraTo, a.tile.position);
                Player.selectedActor.transform.rotation = Quaternion.LookRotation((a.tile.position - Player.selectedActor.transform.position).normalized, Vector3.up);

                context.actors.Clear();
                context.actors.Add(a);

                UpdateInfo(a);
                Tooltip.Open(a.name);
            },
                null,
                null,
                null,
                () => {
                Tooltip.Close();
            });
        }

        //autofocus on first target
        GlobalEvents.Raise(GlobalEvent.JumpCameraTo, context.actors[0].tile.position);
        Player.selectedActor.transform.rotation = Quaternion.LookRotation((context.actors[0].tile.position - Player.selectedActor.transform.position).normalized, Vector3.up);
        UpdateInfo(context.actors[0]);
    }
示例#3
0
    void Start()
    {
        _next.GetComponent <GenericPointerHandler>().Initialize(
            () => Tooltip.Open("Next party member."),
            () =>
        {
            _dataIndex++;

            if (_dataIndex > Player.characters.Length - 1)
            {
                _dataIndex = 0;
            }

            SelectActorData(Player.characters[_dataIndex]);
            Tooltip.Close();
        },
            null,
            null,
            () => Tooltip.Close());
        _previous.GetComponent <GenericPointerHandler>().Initialize(
            () => Tooltip.Open("Previous party member."),
            () =>
        {
            _dataIndex--;

            if (_dataIndex < 0)
            {
                _dataIndex = Player.characters.Length - 1;
            }

            SelectActorData(Player.characters[_dataIndex]);
            Tooltip.Close();
        },
            null,
            null,
            () => Tooltip.Close());
        _toSelection.GetComponent <GenericPointerHandler>().Initialize(
            () => Tooltip.Open("Select party members before you embark on your quest."),
            () =>
        {
            SelectionUIManager.getInstance.gameObject.SetActive(true);

            this.gameObject.SetActive(false);
            Tooltip.Close();

            HubCameraManager.getInstance.GoTo(HubCameraMode.Selection);
        },
            null,
            null,
            () => Tooltip.Close());

        SelectActorData(Player.characters[_dataIndex]);
        HubCameraManager.getInstance.GoTo(HubCameraMode.Customization);
    }
 public void HideTooltip()
 {
     try
     {
         Tooltip.Close();
     }
     catch (System.Exception e)
     {
         Logger.Log(Logger.Level.ERROR, "[Controller] Error while closing tooltip: " + e.ToString());
     }
 }
示例#5
0
    void Toggle()
    {
        for (int i = 0; i < _tabs.Length; i++)
        {
            _tabs[i].tab.SetActive(_tabs[i] == this ? !_tabs[i].tab.activeSelf : false);
        }

        if (!tab.activeSelf)
        {
            Tooltip.Close();
        }

        UIAudioManager.Play(_toggleSound);
    }
示例#6
0
    void CreateItemAction(Item item, Action action, Transform parent, int index)
    {
        GameObject g = Instantiate(_actionItem, parent);

        g.transform.Find("icon").GetComponent <Image>().sprite = action.icon;
        g.transform.Find("index").GetComponent <Text>().text   = index.ToString();

        g.GetComponent <GenericPointerHandler>().Initialize(
            () => Tooltip.Open(action.header + " (" + item.NameToString() + ")\n\n" + action.GetDescription(Player.selectedActor, item)),
            () => OnActionClicked(action, item),
            null,
            null,
            () => Tooltip.Close());

        g.GetComponent <GenericPointerHandler>().SetInteractable(action.Validate(Player.selectedActor, item));
    }
示例#7
0
    void UpdateEquipment()
    {
        for (int i = 0; i < _categories[0].transform.Find("list").childCount; i++)
        {
            Destroy(_categories[0].transform.Find("list").GetChild(i).gameObject);
        }
        for (int i = 0; i < _categories[1].transform.Find("list").childCount; i++)
        {
            Destroy(_categories[1].transform.Find("list").GetChild(i).gameObject);
        }

        for (int i = 0; i < Enum.GetNames(typeof(EquipSlot)).Length; i++)
        {
            Equipable  e = _data.GetEquipment((EquipSlot)i);
            GameObject g = Instantiate(_equipmentItem, i > (int)EquipSlot.LeftHandItem ? _categories[1].transform.Find("list") : _categories[0].transform.Find("list"));

            if (e == null)
            {
                g.transform.Find("name").GetComponent <Text>().text = "Empty (" + ((EquipSlot)i).ToString() + ")";
                g.GetComponent <GenericPointerHandler>().Initialize(
                    null,
                    null,
                    null,
                    null,
                    null);
            }
            else
            {
                g.transform.Find("name").GetComponent <Text>().text = e.NameToString();
                g.GetComponent <GenericPointerHandler>().Initialize(
                    () => Tooltip.Open(e.ToTooltip()),
                    () => {
                    _data.Unequip(e.slot);
                    Player.storage.Add(e);

                    Tooltip.Close();
                    UpdateEquipment();
                    UpdateStorage();
                },
                    null,
                    null,
                    () => Tooltip.Close());
            }
        }
    }
示例#8
0
    void UpdateEquipment(Actor a)
    {
        for (int i = 0; i < Enum.GetNames(typeof(EquipSlot)).Length; i++)
        {
            EquipSlot slot = (EquipSlot)i;
            Equipable e    = a.data.GetEquipment((EquipSlot)i);

            if (e == null)
            {
                _equipmentItems[(int)slot].transform.Find("header").GetComponent <Text>().text = "Empty (" + slot.ToString() + ")";
                _equipmentItems[(int)slot].GetComponent <GenericPointerHandler>().Initialize(
                    null,
                    null,
                    null,
                    null,
                    null);
            }
            else
            {
                bool isEquipped = a.data.GetEquipment(e.slot) == e;

                _equipmentItems[(int)e.slot].transform.Find("header").GetComponent <Text>().text = isEquipped ? e.NameToString() : "Empty (" + e.slot.ToString() + ")";

                if (isEquipped)
                {
                    _equipmentItems[(int)e.slot].GetComponent <GenericPointerHandler>().Initialize(
                        () => Tooltip.Open(e.ToTooltip()),
                        null,
                        null,
                        null,
                        () => Tooltip.Close());
                }
                else
                {
                    _equipmentItems[(int)e.slot].GetComponent <GenericPointerHandler>().Initialize(
                        null,
                        null,
                        null,
                        null,
                        null);
                }
            }
        }
    }
示例#9
0
    void UpdateStorage()
    {
        for (int i = 0; i < _storageList.childCount; i++)
        {
            Destroy(_storageList.GetChild(i).gameObject);
        }

        for (int i = 0; i < Player.storage.Count; i++)
        {
            Item       item = Player.storage[i];
            GameObject g    = Instantiate(_equipmentItem, _storageList);

            g.transform.Find("name").GetComponent <Text>().text = item.NameToString();
            g.GetComponent <GenericPointerHandler>().Initialize(
                () => Tooltip.Open(item.ToTooltip()),
                () => {
                if (item is Equipable e)
                {
                    if (_data.GetEquipment(e.slot) != null)
                    {
                        Player.storage.Add(_data.GetEquipment(e.slot));

                        _data.Unequip(e.slot);
                    }

                    _data.SetEquipment(e);
                }

                Player.storage.Remove(item);
                Tooltip.Close();
                UpdateStorage();
                UpdateEquipment();
            },
                null,
                () => {
                Player.storage.Remove(item);
                Tooltip.Close();
                UpdateStorage();
            },
                () => Tooltip.Close());
        }
    }
示例#10
0
    void Start()
    {
        for (int i = 0; i < Enum.GetNames(typeof(MapType)).Length; i++)
        {
            MapType m = (MapType)i;

            GameObject b = Instantiate(_prefab, _root);

            b.transform.Find("index").gameObject.SetActive(false);

            b.transform.Find("icon").GetComponent <Image>().sprite = _icons[i];
            b.transform.Find("icon").GetComponent <Image>().color  = Map.GetColor(m);

            b.GetComponent <GenericPointerHandler>().Initialize(
                () => Tooltip.Open("Click to toggle visualization of " + Map.StringFormatted(m)),
                () => GlobalEvents.Raise(GlobalEvent.SetGridMap, m),
                null,
                null,
                () => Tooltip.Close());
        }
    }
示例#11
0
    void CreateSpellItem(Action action, int index)
    {
        GameObject g = Instantiate(_prefab, _list);

        //yuck
        g.transform.Find("background").Find("icon").GetComponent <Image>().sprite = action.icon;
        g.transform.Find("borders").GetComponent <Image>().color = Color.blue;
        g.transform.Find("index").GetComponent <Text>().text     = index.ToString();

        g.GetComponent <GenericPointerHandler>().Initialize(
            () => Tooltip.Open(action.ToString()),
            () =>
        {
            if (action.Validate(Player.selectedActor, null))
            {
                action.Activate(Player.selectedActor, null);
            }
        },
            null,
            null,
            () => Tooltip.Close());

        //g.GetComponent<GenericPointerHandler>().SetInteractable(action.Validate(Player.actor, null));
    }
示例#12
0
    void InitializeStats()
    {
        _lists = new Transform[] { _offensiveList, _defensiveList, _miscList, _attributeList, _vitalList };

        for (int i = 0; i < _lists.Length; i++)
        {
            int a = i;

            _lists[i].parent.Find("subHeader").GetComponent <GenericPointerHandler>().Initialize(
                null,
                () => ToggleList(_lists[a], _lists[a].parent.Find("subHeader/toggle").GetComponent <RectTransform>()),
                null,
                null,
                null);
        }

        _statItems      = new GameObject[Enum.GetNames(typeof(StatType)).Length];
        _attributeItems = new GameObject[Enum.GetNames(typeof(AttributeType)).Length];
        _vitalItems     = new GameObject[Enum.GetNames(typeof(VitalType)).Length];

        for (int i = 0; i < _attributeItems.Length; i++)
        {
            int a = i;

            _attributeItems[a] = CreateValueHeaderItem(
                ((AttributeType)a).ToString(),
                Player.selectedActor.data.GetAttribute((AttributeType)a).value.ToString(),
                Attribute.ToColor((AttributeType)a),
                _attributeList,
                () => Tooltip.Open(Player.selectedActor.data.GetAttribute((AttributeType)a).GetTooltip()),
                null,
                null,
                null,
                () => Tooltip.Close());

            _attributeItems[a].transform.Find("levelup").GetComponent <GenericPointerHandler>().Initialize(
                null,
                null,
                null,
                null,
                null);
            _attributeItems[a].transform.Find("levelup").gameObject.SetActive(false);
        }
        for (int i = 0; i < _vitalItems.Length; i++)
        {
            int a = i;

            _vitalItems[a] = CreateValueHeaderItem(
                ((VitalType)i).ToString(),
                Player.selectedActor.data.GetVital((VitalType)i).current + " / " + Player.selectedActor.data.GetVital((VitalType)i).GetMax(),
                Vital.ToColor((VitalType)i),
                _vitalList,
                () => Tooltip.Open(Player.selectedActor.data.GetVital((VitalType)a).ToTooltip()),
                null,
                null,
                null,
                () => Tooltip.Close());
        }
        for (int i = 0; i < Enum.GetNames(typeof(StatType)).Length; i++)
        {
            Stat s = Player.selectedActor.data.GetStat((StatType)i);

            _statItems[i] = CreateValueHeaderItem(
                s.GetHeader(),
                s.GetValueFormatted(),
                s.category == StatCategory.Offensive ? Color.red : (s.category == StatCategory.Defensive ? Color.blue : Color.yellow),
                s.category == StatCategory.Offensive ? _offensiveList : (s.category == StatCategory.Defensive ? _defensiveList : _miscList),
                () => Tooltip.Open(s.ToTooltip()),
                null,
                null,
                null,
                () => Tooltip.Close());
        }
    }
 public void HideTooltip()
 {
     Tooltip.Close();
 }
示例#14
0
    void Awake()
    {
        getInstance = this;
        getInstance.gameObject.SetActive(false);

        _models         = new DisplayModelController[Player.party.Length];
        _troopListItems = new GameObject[Player.party.Length];

        _characters.SetActive(false);

        for (int i = 0; i < Player.party.Length; i++)
        {
            int a = i;

            _models[i] = Instantiate(_displayModel, _spawnPoints[i].position, _spawnPoints[i].rotation, _spawnPoints[i]).GetComponent <DisplayModelController>();
            _models[i].gameObject.SetActive(false);

            _troopListItems[i] = Instantiate(_troopListItem, _troopList);
            _troopListItems[i].transform.Find("name").GetComponent <Text>().text = "EMPTY TROOP SLOT";
            _troopListItems[i].GetComponent <GenericPointerHandler>().Initialize(
                null,
                () => OpenCharacterList(a),
                null,
                () => UpdateModel(null, a),
                null);
        }

        _toCustomization.GetComponent <GenericPointerHandler>().Initialize(
            () => Tooltip.Open("To customization!"),
            () =>
        {
            DisplayUIManager.getInstance.gameObject.SetActive(true);
            this.gameObject.SetActive(false);
            Tooltip.Close();

            HubCameraManager.getInstance.GoTo(HubCameraMode.Customization);
        },
            null,
            null,
            () => Tooltip.Close());
        _autofill.GetComponent <GenericPointerHandler>().Initialize(
            () => Tooltip.Open("Autofill any open slots with available characters."),
            () =>
        {
            for (int i = 0; i < Player.party.Length; i++)
            {
                if (Player.party[i] == null && Player.characters.Any(c => Player.party.IndexOf(c) == -1))
                {
                    UpdateModel(Player.characters.First(c => Player.party.IndexOf(c) == -1), i);
                }
            }

            Tooltip.Close();
        },
            null,
            null,
            () => Tooltip.Close());
        _embark.GetComponent <GenericPointerHandler>().Initialize(
            () => Tooltip.Open("Embark on your quest!"),
            () => {
            GlobalEvents.Raise(GlobalEvent.OpenLoadingScreen);
            SceneManager.LoadScene("Map");
        },
            null,
            null,
            () => Tooltip.Close());
    }