예제 #1
0
    void RenewHeroList()
    {
        if (m_CurrentHeroIndex != -1 && m_AvailableHeroes != null)
        {
            HeroPool.FreeHero(m_AvailableHeroes[m_CurrentHeroIndex]);
            m_ScenarioSettings.UpdateHeroLists(PlayerIndex);
        }

        m_CurrentHeroIndex = -1;

        if (m_CurrentTownIndex == -1)
        {
            UpdateHeroSprite();
            return;
        }

        m_AvailableHeroes = HeroPool.GetFactionHeroes(PlayerIndex, m_AvailableTowns[m_CurrentTownIndex], true);

        UpdateHeroSprite();
    }
예제 #2
0
    public void UpdateHeroList()
    {
        if (m_CurrentHeroIndex != -1 && m_AvailableHeroes != null)
        {
            Hero _CurrentHero = m_AvailableHeroes[m_CurrentHeroIndex];

            HeroPool.FreeHero(_CurrentHero);

            m_AvailableHeroes = HeroPool.GetFactionHeroes(PlayerIndex, m_AvailableTowns[m_CurrentTownIndex], true);

            HeroPool.ClaimHero(_CurrentHero);

            m_CurrentHeroIndex = m_AvailableHeroes.IndexOf(_CurrentHero);
        }
        else if (m_CurrentTownIndex != -1 && m_AvailableTowns.Count > 0)
        {
            m_AvailableHeroes = HeroPool.GetFactionHeroes(PlayerIndex, m_AvailableTowns[m_CurrentTownIndex], true);
        }

        UpdateHeroSprite();
    }
예제 #3
0
    public void Initialize(int a_Index, PlayerInfo a_PlayerInfo)
    {
        PlayerIndex = a_Index;

        m_BackgroundImage.sprite = m_BackgroundSprites[a_Index];

        m_FlagButton.image.sprite = m_FlagSprites[a_Index];

        SpriteState _State = m_FlagButton.spriteState;

        _State.highlightedSprite = m_FlagHoverSprites[a_Index];
        _State.pressedSprite     = m_FlagPressedSprites[a_Index];

        m_FlagButton.spriteState = _State;

        m_FlagButton.gameObject.SetActive(a_PlayerInfo.HumanPlayable);

        if (a_PlayerInfo.HumanPlayable)
        {
            m_HumanOrCPUText.text = "Human or CPU";
            m_HumanOrCPUText.rectTransform.anchoredPosition = new Vector2
                                                              (
                m_HumanOrCPUText.rectTransform.anchoredPosition.x,
                -23
                                                              );
        }
        else
        {
            m_HumanOrCPUText.text = "CPU";
            m_HumanOrCPUText.rectTransform.anchoredPosition = new Vector2
                                                              (
                m_HumanOrCPUText.rectTransform.anchoredPosition.x,
                -22
                                                              );
        }

        m_GenerateHeroAtMainTown = a_PlayerInfo.GenerateHeroAtMainTown;
        m_IsHeroRandom           = a_PlayerInfo.IsMainHeroRandom;

        if (a_PlayerInfo.IsTownChoosable)
        {
            m_IsTownChoosable  = true;
            m_CurrentTownIndex = -1;

            m_AvailableTowns = m_Factions.Factions;
        }
        else
        {
            if (a_PlayerInfo.MainTownType != 255 && a_PlayerInfo.HasMainTown)
            {
                m_IsTownChoosable  = false;
                m_CurrentTownIndex = a_PlayerInfo.MainTownType;

                m_AvailableTowns = m_Factions.Factions;
            }
            else
            {
                m_IsTownChoosable = true;

                m_AvailableTowns = new List <Faction>();

                int _BitwiseIndex = 1;

                for (int i = 0; i < m_Factions.Factions.Count; i++)
                {
                    if ((a_PlayerInfo.AllowedTowns & _BitwiseIndex) == _BitwiseIndex)
                    {
                        m_AvailableTowns.Add(m_Factions.Factions[i]);
                    }

                    _BitwiseIndex *= 2;
                }

                if (m_AvailableTowns.Count > 1)
                {
                    m_CurrentTownIndex = -1;
                }
                else
                {
                    m_CurrentTownIndex = 0;
                }
            }
        }

        m_CustomHero = null;

        if (!m_IsHeroRandom && !m_GenerateHeroAtMainTown)
        {
            if (a_PlayerInfo.MainHeroPortrait == 255 || a_PlayerInfo.MainHeroType == 255)
            {
                m_HeroText.text    = "None";
                m_HeroImage.sprite = m_NoHeroSprite;
            }
            else
            {
                Hero _BaseHero     = m_Heroes.Heroes.First((a_Hero) => a_Hero.Hero.ID == a_PlayerInfo.MainHeroType).Hero;
                Hero _PortraitHero = m_Heroes.Heroes.First((a_Hero) => a_Hero.Hero.ID == a_PlayerInfo.MainHeroPortrait).Hero;

                m_HeroText.text    = a_PlayerInfo.MainHeroName;
                m_HeroImage.sprite = _PortraitHero.SmallPortrait;

                m_CustomHero = new Hero();

                if (a_PlayerInfo.MainHeroName != "")
                {
                    m_CustomHero.Name = a_PlayerInfo.MainHeroName;
                }
                else
                {
                    m_CustomHero.Name = _BaseHero.Name;
                }

                m_CustomHero.ID            = a_PlayerInfo.MainHeroType;
                m_CustomHero.Faction       = _BaseHero.Faction;
                m_CustomHero.SmallPortrait = _PortraitHero.SmallPortrait;
                m_CustomHero.LargePortrait = _PortraitHero.LargePortrait;

                HeroPool.ClaimHero(_BaseHero);

                // TODO: Custom Hero ID probably needs to pipe through primary/secondary abilities
            }
        }

        m_TownLeft.gameObject.SetActive(m_IsTownChoosable && m_AvailableTowns.Count > 1);
        m_TownRight.gameObject.SetActive(m_IsTownChoosable && m_AvailableTowns.Count > 1);

        m_HeroLeft.gameObject.SetActive(m_IsHeroRandom || m_GenerateHeroAtMainTown);
        m_HeroRight.gameObject.SetActive(m_IsHeroRandom || m_GenerateHeroAtMainTown);

        m_CurrentStartingBonusIndex = -1;
        m_CurrentHeroIndex          = -1;

        if (m_CurrentTownIndex != -1)
        {
            m_AvailableHeroes = HeroPool.GetFactionHeroes(PlayerIndex, m_AvailableTowns[m_CurrentTownIndex], true);
        }

        UpdateTownSprite();
        UpdateHeroSprite();
        UpdateStartingBonusSprite();
    }