public static Sprite[] GetTokenSpriteOptions(Critter critter)
    {
        Critter.locomotionType[] locomotions = critter.GetLocomotion();

        tokenSpriteOptions = PopulateTokenSpriteOptions(locomotions).ToArray();

        return tokenSpriteOptions;
    }
    public void Activate(Critter newCritter)
    {
        if (!hex)
        {
            hex = GetComponentInParent<Hex>();
            Image[] tempIcons = GetComponentsInChildren<Image>();
            List<Image> addedIcons = new List<Image>();

            for (int i = 0; i < tempIcons.Length; i += 2)
            {
                addedIcons.Add(tempIcons[i]);
            }

            icons = addedIcons.ToArray();

            locoSprites = Resources.LoadAll<Sprite>("LocomotionIcons");
        }

        critter = newCritter;

        if (critter)
        {
            if (!gameObject.activeInHierarchy)
            {
                gameObject.SetActive(true);

                Populate(hex);
            }
            else
            {
                if (locomotion.Length != critter.GetLocomotion().Length || restrictions.Length != critter.GetRestrictions().Length)
                {
                    Populate(hex);
                }
            }
        }
    }
Exemple #3
0
    //Determines Critter locomotion icons based on locomotion types.
    private void SetLocoIcons(Critter critter)
    {
        loco = critter.GetLocomotion();

        locoIcons.Clear();
        iconColors.Clear();

        Sprite[] locoSprites = Resources.LoadAll<Sprite>("LocomotionIcons");

        for(int i = 0; i < loco.Length; i++){
            Critter.locomotionType strat = loco[i];

            if(strat == Critter.locomotionType.AMPHIBIOUS){
                if(!locoIcons.Contains(locoSprites[0])){
                    locoIcons.Add(locoSprites[0]);
                    iconColors.Add(locoColors[0]);
                }
            }
            if(strat == Critter.locomotionType.AQUATIC){
                if(!locoIcons.Contains(locoSprites[1])){
                    locoIcons.Add(locoSprites[1]);
                    iconColors.Add(locoColors[1]);
                }
            }
            if(strat == Critter.locomotionType.AVIAN){
                if(!locoIcons.Contains(locoSprites[3])){
                    locoIcons.Add(locoSprites[3]);
                    iconColors.Add(locoColors[2]);
                }
            }
            if(strat == Critter.locomotionType.TERRESTRIAL){
                if(!locoIcons.Contains(locoSprites[2])){
                    locoIcons.Add(locoSprites[2]);
                    iconColors.Add(locoColors[3]);
                }
            }
        }
        locoIcons.TrimExcess();
        iconColors.TrimExcess();
    }
    //Determines Critter locomotion icons based on locomotion types.
    private void SetLocoIcons(Critter target)
    {
        Critter.locomotionType[] loco = target.GetLocomotion();

        for(int i = 0; i < loco.Length; i++){
            Critter.locomotionType strat = loco[i];

            if(strat == Critter.locomotionType.AMPHIBIOUS){
                if(!locoIcons.Contains(locoSprites[0])){
                    locoIcons.Add(locoSprites[0]);
                    iconColors.Add(locoColors[0]);
                }
            }
            if(strat == Critter.locomotionType.AQUATIC){
                if(!locoIcons.Contains(locoSprites[1])){
                    locoIcons.Add(locoSprites[1]);
                    iconColors.Add(locoColors[1]);
                }
            }
            if (strat == Critter.locomotionType.AVIAN){
                if(!locoIcons.Contains(locoSprites[3])){
                    locoIcons.Add(locoSprites[3]);
                    iconColors.Add(locoColors[2]);
                }
            }
            if (strat == Critter.locomotionType.TERRESTRIAL)
            {
                if (!locoIcons.Contains(locoSprites[2]))
                {
                    locoIcons.Add(locoSprites[2]);
                    iconColors.Add(locoColors[3]);
                }
            }
        }

        locoIcons.TrimExcess();
    }