예제 #1
0
 public static SacrificeResult[] RandomBoons(int howMany, int tier, int luck)
 {
     SacrificeResultFactory[] factories = Utilities.RandomSubset <SacrificeResultFactory>(sRandomizedBoons, howMany);
     SacrificeResult[]        results   = new SacrificeResult[factories.Length];
     for (int i = 0; i < factories.Length; ++i)
     {
         results[i] = factories[i].Make(tier, luck);
     }
     return(results);
 }
예제 #2
0
    public int AddFleetingDemand(int tier, SacrificeResult satisfiedResult, SacrificeResult ignoredResult, float time, string msg)
    {
        GodDemand demand = new GodDemand(
            DemandGenerator.ScaledDemand(tier, true),
            satisfiedResult,
            ignoredResult
            );

        demand.mTimeLeft = time;
        mDemands.Add(demand);

        if (msg != null)
        {
            Utilities.LogEvent(msg + demand.GetShortDescription(), 2f, false);
        }

        return(demand.mId);
    }
예제 #3
0
    void Update()
    {
        if (m_IsPaused || m_IsShowingTutorial)
        {
            return;
        }

        m_CurrentMonthTimeRemaining -= Time.deltaTime;
        if (m_CurrentMonthTimeRemaining <= 0)
        {
            if (m_CurrentMonth == 11)
            {
                m_CurrentYear++;
            }

            m_CurrentMonth = (m_CurrentMonth + 1) % 12;
            m_TotalMonths++;
            m_ResourceListView.UpdateDate(m_CurrentMonth, m_CurrentYear); // TODO: WE NEED YEARS!!!!
            m_CurrentMonthTimeRemaining = SecondsPerMonth;

            if (StatsManagerObj.Villagers.Count <= 0)
            {
                SoundManager.GetComponent <AudioSource>().volume = 0;
                Instantiate(GameOver, Canvas).GetComponent <GameOverView>();
                m_WindowsOpen++;
            }
        }

        if (m_CurrentMonth == m_NextArrival)
        {
            m_WindowsOpen++;

            Villager[] arrivals = GenerateVillagers();

            RecruitMenuView recruitView = Instantiate(RecruitMenu, Canvas).GetComponent <RecruitMenuView>();
            recruitView.SetRecruitCount((int)m_VillagerLimit - (int)StatsManagerObj.Villagers.Count);
            recruitView.AddVillagerViews(arrivals);
            recruitView.OnRecruit        += StatsManagerObj.Recruit;
            recruitView.OnRecruitFulfill += () => { CalculateNextArrival();
                                                    CalculateLimits();
                                                    CalculateSacrificePeriod();
                                                    UpdateResourceView();
                                                    m_WindowsOpen--; };
            return;
        }

        if (m_CurrentMonth == m_NextSacrifice)
        {
            m_WindowsOpen++;

            SacrificeMenuView sacrificeView = Instantiate(SacrificeMenu, Canvas).GetComponent <SacrificeMenuView>();

            // Only send the first 8 villagers (UI limitation).
            for (int i = 0; i < Mathf.Min(StatsManagerObj.Villagers.Count, 8); i++)
            {
                sacrificeView.AddVillagerView(StatsManagerObj.Villagers[i], i);
            }

            sacrificeView.SetSacrificeCount((int)m_MaxSacrifices);
            sacrificeView.OnSacrifice        += StatsManagerObj.Sacrifice;
            sacrificeView.OnSacrificeFulfill += () => {
                m_NextSacrifice = (m_CurrentMonth + m_SacrificePeriod) % 12;
                m_WindowsOpen--;
                SacrificeResult sacrificeResult = CalculateSacrificeOutcome(sacrificeView.GetSacrificeCountLeft());
                StatsManagerObj.ApplyModifier(sacrificeResult.Modifiers);
                CalculateSacrificePeriod();
                CalculateLimits();
                UpdateResourceView();
                SacrificeResultView resultView = Instantiate(SacrificeResult, Canvas).GetComponent <SacrificeResultView>();
                m_WindowsOpen++;
                resultView.Initialize(sacrificeResult.Title, sacrificeResult.Icon, sacrificeResult.Text);
                resultView.OnWindowClose += () => m_WindowsOpen--;
            };
        }
    }