Exemplo n.º 1
0
    /// <summary>
    /// Deselect all minion and hide info panels
    /// </summary>
    public void DeselectMinion()
    {
        if (selectedEntity == null)
        {
            return;
        }

        selectedEntity.Stats.OnStatChanged -= currentInfoPanel.UpdateInfo;

        currentInfoPanel.GameObject.SetActive(false);
        selectedEntity = null;
    }
Exemplo n.º 2
0
    /// <summary>
    /// Select the give minion and show the info panel for that minion
    /// </summary>
    public void SelectMinion(IHasInfoPanel entity)
    {
        //Get rid of old minion callbacks
        if (selectedEntity != null)
        {
            selectedEntity.Stats.OnStatChanged -= currentInfoPanel.UpdateInfo;
        }

        //Destroy old panel
        Destroy(currentInfoPanel?.GameObject);

        //Create new info panel
        currentInfoPanel = Instantiate(prefabDictionary[entity.GetType()], infoPanelParent).GetComponent <IInfoPanel>();

        //Set new callback
        selectedEntity = entity;
        selectedEntity.Stats.OnStatChanged += currentInfoPanel.UpdateInfo;
        currentInfoPanel.UpdateInfo(selectedEntity.Stats);

        //Set position and show
        currentInfoPanel.GameObject.SetActive(true);
    }