private void BuilderIdleState() { goal = FindUnfinishedBuilding(); if (goal != null) { currState = personState.Moving; agent.destination = goal.transform.position; agent.isStopped = false; } }
private void WorkerIdleState() { goal = FindClosestResource("Gather", null); if (goal != null) { currState = personState.Moving; agent.destination = goal.transform.position; agent.isStopped = false; } }
private void BuilderBuildingState() { ObjectController ObjCont = null; if (goal != null) { ObjCont = goal.GetComponent <ObjectController>(); } if (myInventory.num <= 0 && ObjCont.NeedStone()) { currState = personState.MovingItem; goal = null; // need to figure out how to request and retreive various stuff } }
private void BuilderMovingState() { if (goal == null) { agent.isStopped = true; currState = personState.Idle; } else if (agent.remainingDistance <= workDistance) { currState = personState.Building; } else if (agent.isStopped == true) { agent.isStopped = false; } }
private void BuilderMovingItemState() { if (goal == null) { goal = FindClosestLocation("Stockpile"); if (goal != null) { agent.destination = goal.transform.position; agent.isStopped = false; } else { print("no stockpiles"); goal = null; currState = personState.Idle; } } else if (agent.remainingDistance <= workDistance) { agent.isStopped = true; if (myInventory.num <= 0) { goal = null; myInventory.itemType = null; currState = personState.Idle; } else { myInventory.num = goal.GetComponent <StockpileBehavior>().TakeItem(myInventory.num, myInventory.itemType.name); } // this ain't gonna work, need to link to which resource is ID'd by building state if (myInventory.num > 0) { currState = personState.Idle; } else { goal = null; } } }
private void WorkerMovingItemState() { if (goal == null) { goal = FindClosestStockpile(myInventory.itemType); if (goal != null) { agent.destination = goal.transform.position; agent.isStopped = false; } else { print("no stockpiles"); goal = null; currState = personState.Idle; } } else if (agent.remainingDistance <= workDistance) { agent.isStopped = true; if (myInventory.num <= 0) { goal = null; myInventory.itemType = null; currState = personState.Idle; } else { myInventory.num = goal.GetComponent <StockpileBehavior>().DepositItem(myInventory.num, myInventory.itemType); } if (myInventory.num > 0) { goal = null; } else { myInventory.itemType = null; } } }
private void processEnshadowment() { evidence += shadow * map.param.person_evidencePerShadow; if (evidence > 1) { evidence = 1; } if (state == personState.lightbringer) { shadow = 0; return; } foreach (Person p in society.people) { if (p == this) { continue; } if (p.shadow == 0) { continue; } //Can't inherit if they don't have any, skip to save CPU if (p.shadow <= shadow) { continue; } if (p.prestige < prestige) { continue; } /* * double basePrestige = 100; * if (society.getSovereign() != null) { basePrestige = society.getSovereign().prestige; } * if (basePrestige < 10) { basePrestige = 10; } * double multFromPrestige = p.prestige / basePrestige; * if (multFromPrestige < 0) { multFromPrestige = 0; } * if (multFromPrestige > 1) { multFromPrestige = 1; } */ double likingMult = Math.Max(0, this.getRelation(p).getLiking()) / 100; double shadowDelta = p.shadow * likingMult * map.param.person_shadowContagionMult; //You get enshadowed by people you like/trust this.shadow = Math.Min(p.shadow, shadow + shadowDelta); //Don't exceed your donor's shadow if (this.shadow > 1) { this.shadow = 1; } } if (society.isDarkEmpire) { //if (society.getSovereign() != null && society.getSovereign().shadow > shadow) //{ shadow += Eleven.random.NextDouble() * map.param.ability_avrgDarkEmpireShadowPerTurn; //} if (shadow > 1) { shadow = 1; } } if (state == personState.normal && shadow == 1) { this.state = personState.broken; map.turnMessages.Add(new MsgEvent(this.getFullName() + " has been fully enshadowed, their soul can no longer resist the dark", MsgEvent.LEVEL_GREEN, true, getLocation().hex)); if (!map.hasBrokenSoul) { AchievementManager.unlockAchievement(SteamManager.achievement_key.BROKEN_SOUL); map.hasBrokenSoul = true; } } //If you've not broken yet, decay the shadow away if (state != personState.broken && state != personState.enthralled) { shadow -= map.param.person_shadowDecayPerTurn; if (shadow < 0) { shadow = 0; } } if (state == personState.broken || state == personState.enthralled) { if (this.title_land != null) { this.title_land.settlement.infiltration = 1; } } }
private void WorkerWorkingState() { ResourceController resource = null; if (goal != null) { resource = goal.GetComponent <ResourceController>(); } if (resource == null) { print("can't gather not a resource"); goal = FindClosestResource("Gather", myInventory.itemType); currState = personState.Moving; if (goal == null) { currState = personState.MovingItem; } else { agent.destination = goal.transform.position; } } else { if (myInventory.num == maxInventorySpace) { goal = null; resource.SetOwner(null); currState = personState.MovingItem; } else if (resource.CurrentOwner() == gameObject.name) { timeWorked += (resource.GetWorkTime() * Time.deltaTime); if (timeWorked >= resource.GetWorkTime()) { if (myInventory.itemType == null) { myInventory.itemType = resource.GetResourceType(); } myInventory.num += resource.TakeResource(pickupAmount); timeWorked = 0.0f; } } else if (resource.CurrentOwner() == null) { resource.SetOwner(gameObject.name); } else if ((goal == null || resource.CurrentOwner() != gameObject.name) && myInventory.num < maxInventorySpace) { goal = FindClosestResource("Gather", myInventory.itemType); currState = personState.Moving; if (goal == null) { currState = personState.MovingItem; } else { agent.destination = goal.transform.position; } } else { currState = personState.Idle; goal = null; print("something dun messed up"); } } }
private void processEnshadowment() { evidence += shadow * map.param.person_evidencePerShadow; if (evidence > 1) { evidence = 1; } if (state != personState.broken && state != personState.enthralled) { shadow -= map.param.person_shadowDecayPerTurn; if (shadow < 0) { shadow = 0; } } foreach (Person p in society.people) { if (p == this) { continue; } if (p.shadow == 0) { continue; } //Can't inherit if they don't have any, skip to save CPU if (p.shadow <= shadow) { continue; } if (p.prestige < prestige) { continue; } /* * double basePrestige = 100; * if (society.getSovreign() != null) { basePrestige = society.getSovreign().prestige; } * if (basePrestige < 10) { basePrestige = 10; } * double multFromPrestige = p.prestige / basePrestige; * if (multFromPrestige < 0) { multFromPrestige = 0; } * if (multFromPrestige > 1) { multFromPrestige = 1; } */ double likingMult = Math.Max(0, this.getRelation(p).getLiking(this, p)) / 100; double shadowDelta = p.shadow * likingMult * map.param.person_shadowContagionMult; //You get enshadowed by people you like/trust this.shadow = Math.Min(p.shadow, shadow + shadowDelta); //Don't exceed your donor's shadow if (this.shadow > 1) { this.shadow = 1; } } if (society.isDarkEmpire) { if (society.getSovreign() != null && society.getSovreign().shadow > shadow) { shadow += map.param.ability_darkEmpireShadowPerTurn; } if (shadow > 1) { shadow = 1; } } if (state == personState.normal && shadow == 1) { this.state = personState.broken; map.addMessage(new MsgEvent(this.getFullName() + " has been fully enshadowed, their soul can no longer resist the dark", MsgEvent.LEVEL_GREEN, true)); } }