/// <summary> /// Open item after research. /// Could be changed by children /// Here: setting production as tools wherever it used /// </summary> public override void OpenItem() { foreach (var eff in m_effects) { var products = Productions.GetProductions(eff.Value.m_name); foreach (GameAbstractItem prod in products) { if (prod.m_isItOpen > 0) { GameMaterial mat = (GameMaterial)prod; bool hasItTheSame = false; foreach (var effect in mat.m_tools) { hasItTheSame |= (effect.m_toolLink.m_name == m_name && effect.m_name == eff.Value.m_name); } if (hasItTheSame) { continue; } else { ItemsEffect neff = new ItemsEffect(eff.Value); neff.m_production = mat; mat.m_tools.Add(neff); ArrowScript asc = ArrowScript.NewArrowScript(neff.m_toolLink.m_thisObject, mat.m_thisObject); asc.m_isItTool = true; mat.m_thisObject.m_toolsTo.Add(asc); m_thisObject.m_toolsFrom.Add(asc); } } } } base.OpenItem(); }
/// <summary> /// Open item at startup. /// Here: getting buildings for living and happy tools for furver using /// Could be called only in Start/Load game /// </summary> public override void OpenItem() { for (int i = 0; i < 30; i++) { m_starved.Enqueue(-m_people.PeopleNumber); } m_isItIterable = false; m_tools = new List <ItemsEffect>(); m_dependencyCount = new DependencyCount[1]; m_dependencyCount[0] = new DependencyCount(); m_dependencyCount[0].m_dependency = new List <AbstractObject>(); foreach (var food in Productions.GetProductions("food")) { m_dependencyCount[0].m_dependency.Add(food as GameMaterial); } foreach (var building in Productions.GetTools("living")) { m_livingPlaces.Add(new ItemsEffect(building)); } m_livingPlaces.Sort((ItemsEffect pair1, ItemsEffect pair2) => { Buildings bld1 = pair1.m_toolLink as Buildings; Buildings bld2 = pair2.m_toolLink as Buildings; return((int)(bld1.m_happyEffect.m_value - bld2.m_happyEffect.m_value)); }); Productions.AddProduction(this, "happy"); m_people = Camera.main.GetComponent <People>(); while (m_people.GetWorker()) { ((GameMaterial)(m_dependencyCount[0].m_dependency[0])).m_workers++; } }