예제 #1
0
    public void SelectIcon(PawnIcon icon)
    {
        selectedIcons.Add(icon);
        PawnIconStandard iconStandard = (PawnIconStandard)icon;

        iconStandard.highlight.gameObject.SetActive(true);
    }
예제 #2
0
    public void DeselectIcon(PawnIcon icon)
    {
        selectedIcons.Remove(icon);
        PawnIconStandard iconStandard = (PawnIconStandard)icon;

        iconStandard.highlight.gameObject.SetActive(false);
    }
예제 #3
0
    private IEnumerator InitRoutine(List <Pawn> acquiredPawns)
    {
        int j = 0;                                    // track the pawnIcons list position

        for (int i = 0; i < acquiredPawns.Count; i++) // iterate through the master list of pawns (may contain holes)
        {
            Pawn pawn = acquiredPawns[i];
            if (pawn != null)
            {
                if (j >= pawnIcons.Count)                   // if we need more pawn icons, add new ones to the list
                {
                    AddNewPawnIcon(pawn);
                }
                else
                {
                    PawnIconStandard pawnIcon = pawnIcons[j].GetComponent <PawnIconStandard>();
                    pawnIcon.Init(pawn);
                    pawnIcon.onClick = (iconData) =>
                    {
                        infoPanel.gameObject.SetActive(true);
                        infoPanel.Init(iconData.pawnData);
                    };
                }
                j++;
            }
        }
        yield return(null);             // Wait one frame to avoid any strange glitches

        StartCoroutine(AnimateIn(acquiredPawns.Count));
    }
예제 #4
0
 void OnEnable()
 {
     // Clicking on a pawn in the pawnSelectionView brings up the highlight menu
     pawnSelectionView.Refresh();
     foreach (PawnIcon pawnIcon in pawnSelectionView.pawnIcons)
     {
         PawnIconStandard icon = (PawnIconStandard)pawnIcon;
         icon.onClick = (iconData) =>
         {
             highlightMenu.SetActive(false);                         // Disable then enable so the animation plays
             highlightedIcon = iconData;
             highlightMenu.SetActive(true);
             highlightMenu.transform.SetParent(iconData.transform, false);
         };
     }
 }
예제 #5
0
    private void AddNewPawnIcon(Pawn pawn)
    {
        GameObject o = Instantiate(pawnIconPrefab);

        o.transform.SetParent(content, false);
        o.SetActive(false);
        PawnIconStandard pawnIcon = o.GetComponent <PawnIconStandard>();

        pawnIcon.Init(pawn);
        pawnIcon.onClick = (iconData) =>
        {
            infoPanel.gameObject.SetActive(true);
            infoPanel.Init(iconData.pawnData);
        };
        pawnIcons.Add(o);
    }
예제 #6
0
    public void Init()
    {
        print("Initializing HeroSelectMenu!");
        selectedPawnIcon.onClick = (PawnIconStandard iconData) => {
            pawnInfoPanel.gameObject.SetActive(true);
            pawnInfoPanel.Init(iconData.pawnData);
        };
        foreach (PawnIcon pawnIcon in pawnSelectionView.pawnIcons)
        {
            PawnIconStandard pawnIconStandard = (PawnIconStandard)pawnIcon;
            pawnIconStandard.onClick = (PawnIconStandard iconData) => {
                // If this is not the selected pawnIcon
                if (selectedPawnIcon.pawnData != iconData.pawnData)
                {
                    // Select this pawnIcon and deselect previous pawn icon (if it exists)
                    if (highlightedPawnIcon != null)
                    {
                        highlightedPawnIcon.highlight.SetActive(false);
                    }
                    highlightedPawnIcon = iconData;
                    highlightedPawnIcon.highlight.SetActive(true);

                    selectedPawnIcon.Init(iconData.pawnData);
                    // Set gameobject to false then true so animation plays
                    selectedPawnIcon.gameObject.SetActive(false);
                    selectedPawnIcon.gameObject.SetActive(true);
                    GameManager.instance.selectedPawn = pawnIcon.pawnData;
                }
                else
                {
                    // Deselect this pawnIcon
                    highlightedPawnIcon.highlight.SetActive(false);
                    highlightedPawnIcon = null;

                    selectedPawnIcon.pawnData = null;
                    selectedPawnIcon.gameObject.SetActive(false);
                    GameManager.instance.selectedPawn = null;
                }
            };
        }
    }
예제 #7
0
 void OnEnable()
 {
     // Clicking on a pawn in the pawnSelectionView brings up the highlight menu
     pawnSelectionView.Refresh();
     foreach (PawnIcon pawnIcon in pawnSelectionView.pawnIcons)
     {
         DeselectIcon(pawnIcon);
         PawnIconStandard icon = (PawnIconStandard)pawnIcon;
         icon.onClick = (iconData) =>
         {
             if (selectedIcons.Contains(iconData))
             {
                 DeselectIcon(iconData);
             }
             else
             {
                 SelectIcon(iconData);
             }
         };
     }
 }