Ejemplo n.º 1
0
    void CreateGroupItem(int index)
    {
        ShipGroup  group = CommandMapper.GetGroup(index);
        GameObject gi    = Instantiate(_groupItem, null);

        gi.transform.SetParent(_groups);

        gi.transform.Find("header").transform.Find("header").GetComponent <Text>().text = "[GROUP]: " + index;
        gi.transform.Find("header").transform.Find("header").GetComponent <GenericTooltipHandler>().Initialize(
            () => TooltipManager.getInstance.OpenTooltip("[<color=yellow>LEFT-CLICK</color>] to select.\n[<color=yellow>SCROLL-CLICK</color>] to focus.", Input.mousePosition),
            () => CommandMapper.SelectGroup(index),
            () => CameraManager.getInstance.JumpTo(CommandMapper.GetGroup(index).GetCenter(), true),
            null,
            () => TooltipManager.getInstance.CloseTooltip());
        gi.transform.Find("header").transform.Find("remove").GetComponent <GenericTooltipHandler>().Initialize(
            () => TooltipManager.getInstance.OpenTooltip("Remove group.", Input.mousePosition),
            () => CommandMapper.RemoveGroup(index),
            null,
            null,
            () => TooltipManager.getInstance.CloseTooltip());

        Transform list = gi.transform.Find("list");

        for (int i = 0; i < group.ships.Count; i++)
        {
            CreateGroupShipItem(list, group.ships[i]);
        }

        _groupItems[index] = gi;
        _groupItems[index].transform.SetSiblingIndex(index);

        UpdateGroupsVisibility();
    }