// Update is called once per frame void Update() { if (mNumFleetingDemands < maxFleetingDemands) { mFleetingDemandTimer -= GameState.GameDeltaTime; if (mFleetingDemandTimer <= 0) { int tier = Mathf.FloorToInt(GameState.GameTimeElapsed / 120); SacrificeDemand demand = DemandGenerator.ScaledDemand(tier); SacrificeResult satisfied = null; SacrificeResult ignored = null; float negativeChance = 0.8f - GameState.Favour * 0.1f; float specialChance = 0.0f + GameState.Favour * 0.05f; float roll = Random.value; if (roll <= negativeChance) { ignored = BoonLibrary.RandomTemporaryCurse(); } else if (roll - negativeChance <= specialChance) { satisfied = BoonLibrary.RandomBoon(tier, GameState.Favour); } else { satisfied = BoonLibrary.RandomTemporaryBoon(tier, GameState.Favour); } GodDemand d = new GodDemand(demand, satisfied, ignored); d.mTimeLeft = 30; mDemands.Add(d); //mFleetingDemands.Add(new FleetingDemand(d, 30)); mFleetingDemandTimer = Random.Range(fleetingDemandTimer - (fleetingDemandTimer / 2), fleetingDemandTimer + (fleetingDemandTimer / 2)); } } for (int i = mDemands.Count - 1; i >= 0; --i) { GodDemand d = mDemands[i]; if (d.mTimeLeft == -1) { // fleeting demands are tacked on to the end, so once we hit a non-fleeting we're done break; } if (d.mTimeLeft > 0) { d.mTimeLeft -= GameState.GameDeltaTime; if (d.mTimeLeft <= 0) { if (d.mIgnoredResult != null) { d.mIgnoredResult.DoEffect(); } mDemands.RemoveAt(i); } } } }
public GameObject GetUiDemand(GodDemand demand) { if (mUiDemandMap.ContainsKey(demand)) { return(mUiDemandMap.GetValue(demand)); } return(null); }
private void InitializeUIDemand(GameObject uiDemand) { GodDemand demand = mUiDemandMap.GetKey(uiDemand); string groupName = "Permanent"; if (demand.GroupId != -1) { groupName = "Featured"; } else if (demand.IsTemporary) { groupName = "Fleeting"; } uiDemand.transform.SetParent(transform.Find("Center (H)/DemandGroups/V/" + groupName + "/Viewport/Content (G)"), false); }
public List <GodDemand> GenerateInitialDemands() { SacrificeDemand victoryDemand = new SacrificeDemand(); Criterion profC = new Criterion(); profC.mMinLevel = 1; profC.mAttributes.Add(PersonAttribute.WARRIOR); profC.mCount = 1; victoryDemand.mCriteria.Add(profC); GodDemand victory = new GodDemand(victoryDemand, new VictoryResult(), null); return(new List <GodDemand>() { victory }); }
// Called immediately after a person is successfully dropped on a demand slot public void MaybeSacrifice(GameObject uiDemandObject) { GodDemand demand = mUiDemandMap.GetKey(uiDemandObject); if (demand.IsSatisfied()) { List <Person> peopleToSacrifice = demand.GetAssociatedPeople().ConvertAll(obj => mUiPeopleMap.GetKey(obj)); Debug.Log("Sacrificing " + peopleToSacrifice.Count + " people."); if (mGod != null) { string sacrificedNames = Utilities.ConcatStrings(peopleToSacrifice.ConvertAll(person => person.Name)); LogEvent("You sacrifice " + sacrificedNames + " to " + mGod.Name, 1f); mGod.MakeSacrifice(demand, peopleToSacrifice); } } }
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); }
public List <GodDemand> GenerateInitialDemands() { // Renewable demands List <GodDemand> result = new List <GodDemand>(); foreach (SacrificeResult sr in BoonLibrary.sGuaranteedRenewableBoons) { GodDemand renewableDemand = new GodDemand( DemandGenerator.ScaledDemand(0), sr, null ); renewableDemand.mIsRenewable = true; result.Add(renewableDemand); } // A group of random demands result.AddRange(GenerateDemandGroup(3)); // The victory demand SacrificeDemand victoryDemand = new SacrificeDemand(); int numToChoose = 1; int requiredLevel = 7; int requiredCount = 3; if (Random.value < 0.5) { numToChoose = 3; requiredLevel = 6; requiredCount = 1; } PersonAttribute[] allProfessions = PersonAttributeType.PROFESSION.GetAllValues(); PersonAttribute[] randomProfessions = Utilities.RandomSubset <PersonAttribute>(allProfessions, numToChoose); foreach (PersonAttribute profession in randomProfessions) { Criterion profC = new Criterion(); profC.mMinLevel = requiredLevel; profC.mAttributes.Add(profession); profC.mCount = requiredCount; victoryDemand.mCriteria.Add(profC); } result.Add(new GodDemand(victoryDemand, new VictoryResult(), null)); return(result); }
// Generate a group of demands that will all be removed when any one of them is purchased. private List <GodDemand> GenerateDemandGroup(int groupSize) { List <GodDemand> result = new List <GodDemand>(); // 3 groups at each tier, starting with tier 0. int groupId = mNextDemandGroupId++; int tier = Mathf.FloorToInt(groupId / 3f); SacrificeResultFactory[] boons = BoonLibrary.RandomBoonFactories(groupSize); foreach (SacrificeResultFactory boonFactory in boons) { GodDemand demand = new GodDemand( DemandGenerator.ScaledDemand(tier), boonFactory.Make(tier, GameState.Favour), null ); demand.GroupId = groupId; result.Add(demand); } return(result); }
public List <GodDemand> DemandWasRemoved(GodDemand oldDemand) { return(new List <GodDemand>()); }
public List <SacrificeResult> MakeSacrifice(GodDemand demand, List <Person> people) { List <SacrificeResult> results = new List <SacrificeResult>(); int demandId = demand.mId; if (demandId < 0 || !demand.mDemand.CheckSatisfaction(people)) { Debug.Log("WARNING: Trying to sacrifice but some requirements not met"); return(results); } // Sacrifice the people foreach (Person p in people) { Debug.Log("goodbye " + p.Name); } PersonManager personMgr = Utilities.GetPersonManager(); personMgr.RemovePeople(people); // Apply results after sacrificing people if (demand.mSatisfiedResult != null) { results.Add(demand.mSatisfiedResult); } if (demand.mSatisfiedResult != null || demand.mIgnoredResult != null) { Utilities.LogEvent("YES, THIS SACRIFICE PLEASES ME", 2f, true); } else { Utilities.LogEvent("THIS POINTLESS SACRIFICE PLEASES ME", 2f, true); } foreach (SacrificeResult r in results) { r.DoEffect(); } // If a renewable demand was successful and did something, create a new result of the same type // This is relevant if the text or any internal variables changed. if (demand.mIsRenewable && results.Count > 0) { demand.mNumBuys++; demand.mDemand = DemandGenerator.ScaledDemand(demand.mNumBuys); // TODO: find a way to generalize this for renewable demands with arguments // var resultType = demand.mSatisfiedResult.GetType(); // demand.mSatisfiedResult = (SacrificeResult)System.Activator.CreateInstance(resultType); // HACK: Assume XPBuff XpBuff currentBoon = (XpBuff)demand.mSatisfiedResult; demand.mSatisfiedResult = new XpBuff(currentBoon.mProfession); } // Remove the demand. (Scenario is null if the result was VICTORY) if (!demand.mIsRenewable && GameState.Scenario != null) { if (demand.GroupId != -1) { int groupSize = RemoveDemandGroup(demand.GroupId); mDemands.AddRange(GameState.Scenario.DemandGroupWasRemoved(groupSize)); } else { RemoveDemand(demandId); mDemands.AddRange(GameState.Scenario.DemandWasRemoved(demand)); } } if (GameState.HasBoon(BoonType.SACRIFICE_BONUS_XP)) { List <Person> underleveled = personMgr.People.FindAll(x => x.Level < GameState.GetLevelCap(x.GetAttribute(PersonAttributeType.PROFESSION))); if (underleveled != null && underleveled.Count > 0) { int xpBonus = GameState.GetBoonValue(BoonType.SACRIFICE_BONUS_XP); Person p = Utilities.RandomSelection <Person>(underleveled.ToArray()); Utilities.LogEvent(p.Name + " got " + xpBonus + " bonus xp from the sacrifice"); p.AddXp(xpBonus); } } if (GameState.HasBoon(BoonType.SACRIFICE_BONUS_HEALING)) { List <Person> needHealing = personMgr.People.FindAll(x => x.Health < x.MaxHealth); if (needHealing != null && needHealing.Count > 0) { float heal = GameState.GetBoonValue(BoonType.SACRIFICE_BONUS_HEALING); Person p = Utilities.RandomSelection <Person>(needHealing.ToArray()); Utilities.LogEvent("The sacrifice restored " + heal + " lifeforce to " + p.Name); p.Heal(heal); } } if (GameState.HasBoon(BoonType.SACRIFICE_BONUS_FOOD)) { // not sure how to do this one yet. would have to be timed to make sense? } return(results); }