Exemplo n.º 1
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);
    }