public bool SetDesireType() { for (int index = 0; index < this.PriorityList.Count; ++index) { DesireType _desireType = this.PriorityTable[this.PriorityList[index]]; if (this.CheckDesireParamFilled(_desireType)) { if (this.CurrentDesire == _desireType) { return(false); } this.CurrentDesire = _desireType; Func <DesireType, bool> desireFilledEvent = this.DesireFilledEvent; bool?nullable = desireFilledEvent != null ? new bool?(desireFilledEvent(_desireType)) : new bool?(); if ((!nullable.HasValue ? 0 : (nullable.Value ? 1 : 0)) != 0) { this.CheckCandidateDesire(); return(true); } this.CurrentDesire = DesireType.None; this.SetParam(_desireType, 0.0f); this.CheckCandidateDesire(); return(false); } } return(false); }
public float GetParam(DesireType _desireType) { float num = 0.0f; this.ParamTable.TryGetValue(_desireType, out num); return(num); }
private void initializeAncDesires() { List <DesireType> desireTypes = Desire.GetRandomAncDesireTypes(numAncDesires); for (int i = 0; i < desireTypes.Count; i++) { DesireType type = desireTypes[i]; switch (type) { case DesireType.chill: chillDesireIdx = i; break; case DesireType.music: musicDesireIdx = i; break; case DesireType.nature: natureDesireIdx = i; break; case DesireType.science: scienceDesireIdx = i; break; case DesireType.exercise: exerciseDesireIdx = i; break; case DesireType.creative: creativeDesireIdx = i; break; case DesireType.community: communityDesireIdx = i; break; case DesireType.education: educationDesireIdx = i; break; case DesireType.spirituality: spiritualityDesireIdx = i; break; } ancDesires[i] = new Desire(type, 1); } }
public bool CheckDesireParamFilled(DesireType _desireType) { float num = 0.0f; Tuple <float, float> tuple; return(this.BorderTable.TryGetValue(_desireType, out tuple) && this.ParamTable.TryGetValue(_desireType, out num) && (double)tuple.Item2 <= (double)num); }
public void CheckCandidateDesire() { DesireType candidateDesire = this.CandidateDesire; this.CandidateDesire = DesireType.None; for (int index = 0; index < this.PriorityList.Count; ++index) { DesireType key = this.PriorityTable[this.PriorityList[index]]; float num; Tuple <float, float> tuple; if (this.ParamTable.TryGetValue(key, out num) && this.BorderTable.TryGetValue(key, out tuple) && (double)tuple.Item1 <= (double)num) { this.CandidateDesire = key; break; } } if (this.CandidateDesire == candidateDesire) { return; } Func <DesireType, bool> candidateDesireEvent = this.ChangedCandidateDesireEvent; if (candidateDesireEvent == null) { return; } int num1 = candidateDesireEvent(this.CandidateDesire) ? 1 : 0; }
/// <summary> /// Gets a list of the RoomObjects that will affect the current desireType /// </summary> /// <param name="desireType">The desire type that needs addressing</param> /// <returns>A list of RoomObjects</returns> private List <RoomObject> getRoomObjectsToTarget(DesireType desireType) { List <RoomObject> objs = RoomObject.GetRoomObjectsForDesireType(desireType); //TODO filter RoomObjects as appropriate return(objs); }
public Desire(DesireType _type, float _incSpeed) { value = 0; type = _type; name = type.ToString(); incSpeed = _incSpeed; incSpeedMult = 0.1f; }
public Desire() { value = 0; type = DesireType.none; name = type.ToString(); incSpeed = 1; incSpeedMult = 0.1f; }
// Constructor public Desire(DesireType desireType, Transform desireDest, float danger, float confidence, float priority) { this.desireType = desireType; this.desireDest = desireDest; this.danger = danger; this.confidence = confidence; this.desireValue = (confidence - danger) + priority; }
public DesireBaseData(DesireBase input) { desireValue = input.desireValue; tickAmount = input.tickAmount; tickAmountMult = input.tickAmountMult; tickBetween = input.tickBetween; desireName = input.desireName; }
// Constructor public Intention(Desire desire) { this.desire = desire; this.type = desire.DesireType; this.intentionValue = desire.DesireValue; this.intentionDest = desire.DesireDest; }
public List <Structure> FindStructureByDesire(DesireType type, Traveler t) // 전달받은 stat의 종족, 부, 소지골드, 직업에따라 최적의 건물 반환. { return(new List <Structure> ((from s in structures where s.resolveType == type && s.GetWaitSeconds() < 120.0f && t.stat.gold > s.charge orderby s.preference.GetPrefSum(t.stat.race, t.stat.wealth, t.stat.job) descending select s).ToArray())); //기존 preferences 최대값 150.0f //이용 요금 고려 //욕구 타입과 대기 시간 고려 //순서는 종족, 부, 직업 고려 //거리? }
public DesireBase(DesireBaseData input) { _desireName = input.desireName; desireValue = input.desireValue; tickAmount = input.tickAmount; tickAmountMult = input.tickAmountMult; tickBetween = input.tickBetween; //tickBetweenWait = new WaitForSeconds(tickBetween); }
public void Clear() { this.Active = false; DesireType desireType = DesireType.None; this.CandidateDesire = desireType; this.CurrentDesire = desireType; this.ClearTable(); }
public void ReduceDesireParameter(bool _success, DesireType _changeDesire) { List <AnimalState> animalStateList; if (!this.desireController.TargetStateTable.TryGetValue(_changeDesire, out animalStateList) || !animalStateList.Contains(this.CurrentState)) { return; } this.desireController.ReduceParameter(_success, _changeDesire); }
public DesireBase(DesireType name, float initDesireValue, float initTickAmount, float initTickMult, float initTickBetween, Traveler _owner) { _desireName = name; desireValue = initDesireValue; tickAmount = initTickAmount; tickAmountMult = initTickMult; tickBetween = initTickBetween; tickBetweenWait = new WaitForSeconds(tickBetween); owner = _owner; }
public void ReduceParameter(bool _success, DesireType _changeDesire) { AnimalTypes animalType = this.AnimalType; Dictionary <bool, Dictionary <DesireType, ChangeParamState> > dictionary; if (this.ResultTable.TryGetValue(_changeDesire, out dictionary)) { foreach (KeyValuePair <bool, Dictionary <DesireType, ChangeParamState> > keyValuePair1 in dictionary) { bool key1 = keyValuePair1.Key; if (_success == key1) { foreach (KeyValuePair <DesireType, ChangeParamState> keyValuePair2 in keyValuePair1.Value) { DesireType key2 = keyValuePair2.Key; ChangeParamState changeParamState = keyValuePair2.Value; if (this.ParamTable.ContainsKey(key2)) { float num1 = this.ParamTable[key2]; float randomValue = changeParamState.RandomValue; float num2; switch (changeParamState.changeType) { case ChangeType.Add: num2 = num1 + randomValue; break; case ChangeType.Sub: num2 = num1 - randomValue; break; case ChangeType.Cng: num2 = randomValue; break; default: continue; } Tuple <float, float> tuple; this.ParamTable[key2] = !this.BorderTable.TryGetValue(key2, out tuple) ? Mathf.Max(num2, 0.0f) : Mathf.Clamp(num2, 0.0f, tuple.Item2); } } } } } else { this.ParamTable[_changeDesire] = 0.0f; } if (this.CurrentDesire == _changeDesire) { this.CurrentDesire = DesireType.None; } this.CheckCandidateDesire(); }
public bool SetParam(DesireType _desireType, float _value) { if (!this.ParamTable.ContainsKey(_desireType)) { return(false); } Tuple <float, float> tuple; this.ParamTable[_desireType] = !this.BorderTable.TryGetValue(_desireType, out tuple) ? Mathf.Max(_value, 0.0f) : Mathf.Clamp(_value, 0.0f, tuple.Item2); this.SetDesireType(); this.CheckCandidateDesire(); return(true); }
//Tick은 DesireBase에 Tick으로 Traveler에서 호출. #endregion public DesireType GetHighestDesire() { //thirsty, hungry, sleep, tour, fun, convenience, equipment, health.... float maxVal = 0.0f; DesireType max = DesireType.Base; foreach (KeyValuePair <DesireType, DesireBase> kvp in desireDict) { if (maxVal <= kvp.Value.desireValue) { maxVal = kvp.Value.desireValue; max = kvp.Key; } } return(max); }
public bool CanDesireBeAddressed(DesireType desireType) { //TODO more intelligently loop through rooms, i.e. only rooms that could possibly contain the desire/object type List <RoomObjectType> objTypes = RoomObject.GetObjectsImpactingDesireType(desireType); for (int i = 0; i < allRooms.Count; i++) { for (int j = 0; j < allRooms[i].Count; j++) { for (int k = 0; k < objTypes.Count; k++) { if (allRooms[i][j].ContainsObjectOfRoomObjectType(objTypes[k])) { return(true); } } } } return(false); }
private DesireType getDesireTypeToAddress() { LinkedList <Desire> desiresSorted = getDesireSortedList(); LinkedListNode <Desire> desireNode = desiresSorted.First; while (desireNode != null) { DesireType type = desireNode.Value.GetDesireType(); List <RoomObject> objsToTarget = getRoomObjectsToTarget(type); if (objsToTarget.Count > 0) { return(type); } else { Debug.Log("Could not address desire: " + type.ToString()); desireNode = desireNode.Next; } } return(DesireType.none); }
/// <summary> /// Based on the next DesireType, selects a RoomObject that will address that Desire /// </summary> /// <param name="selectNewDesire">True if you want to select a new desire type to address. /// False to use last desire type</param> private void startMakeNextPath(bool selectNewDesire = true) { //call this first to start clean up old path info before making new one clearPathfindingData(); //Get next desire type to address if (selectNewDesire || nextDesireType == DesireType.none) { nextDesireType = getDesireTypeToAddress(); } //Get objects that can address this desire type objectsToTarget = getRoomObjectsToTarget(nextDesireType); //Get the rooms that house those objects List <Room> roomsToTarget = RoomObject.GetRoomsOfRoomObjects(objectsToTarget); Room currentRoom = roomMan.GetRoomWithPoint(Controls.GetPosAsVector3Int(transform)); //If we are already in one of the rooms with those objects, remove them from the room list, //and add the object to the object list List <RoomObject> objectsToTargetInCurrentRoom = new List <RoomObject>(); if (currentRoom != null && roomsToTarget.Contains(currentRoom)) { roomsToTarget.Remove(currentRoom); foreach (RoomObject obj in objectsToTarget) { if (obj.GetRoom() == currentRoom) { objectsToTargetInCurrentRoom.Add(obj); } } } //Create paths to other rooms and to the objects in the current room pathMan.GetPathsToRoomsAndObjects(this, roomsToTarget, objectsToTargetInCurrentRoom); pathState = PathState.WaitingForPath; }
protected override bool DesireFilledEvent(DesireType _desireType) { List <AnimalState> source; if (!this.desireController.TargetStateTable.TryGetValue(_desireType, out source) || ((IReadOnlyList <AnimalState>)source).IsNullOrEmpty <AnimalState>()) { return(false); } this.MissingActionPoint(); AnimalState _nextState = source.Rand <AnimalState>(); switch (_nextState) { case AnimalState.LovelyIdle: case AnimalState.LovelyFollow: return(false); default: this.SetState(_nextState, (Action)null); return(true); } }
private Desire GetDesire(DesireType type) { switch (type) { case DesireType.bathe: return(bathe); case DesireType.bathroom: return(bathroom); case DesireType.drink: return(drink); case DesireType.health: return(health); case DesireType.eat: return(eat); } int idx = -1; switch (type) { case DesireType.chill: idx = chillDesireIdx; break; case DesireType.music: idx = musicDesireIdx; break; case DesireType.community: idx = communityDesireIdx; break; case DesireType.nature: idx = natureDesireIdx; break; case DesireType.exercise: idx = exerciseDesireIdx; break; case DesireType.creative: idx = creativeDesireIdx; break; case DesireType.science: idx = scienceDesireIdx; break; case DesireType.education: idx = educationDesireIdx; break; case DesireType.spirituality: idx = spiritualityDesireIdx; break; } return(idx > -1 ? ancDesires[idx] : null); }
public Desire(DesireType type, int growthRate) { m_currentDemand = 0; m_desireType = type; }
public DesireHungry(DesireType name, float initDesireValue, float initTickAmount, float initTickMult, float initTickBetween, Traveler _owner) : base(name, initDesireValue, initTickAmount, initTickMult, initTickBetween, _owner) { }
public Desire GetDesire_Debug(DesireType desire) { Debug.Assert(desire != DesireType.COUNT); return(_desires[(int)desire]); }
public float GetAbsoluteDesireValue(DesireType desire) { return(_desires[(int)desire].Value); }
public void ResetDesire(DesireType desire) { _desires[(int)desire].Reset(); }
// JSON 파일에서 건물 정보 읽어서 structure에 저장. public void SetStructureDataFromJSON(Structure structure, string category, int num) { DesireType tempType = DesireType.Base; int tempResolveAmount = 0; switch (tempStructureCategory) { case "Drink": tempType = DesireType.Thirsty; tempResolveAmount = structureJson[tempStructureCategory][tempStructureNumber]["desire"]["thirsty"].AsInt; break; case "Food": tempType = DesireType.Hungry; tempResolveAmount = structureJson[tempStructureCategory][tempStructureNumber]["desire"]["hungry"].AsInt; break; case "Lodge": tempType = DesireType.Sleep; tempResolveAmount = structureJson[tempStructureCategory][tempStructureNumber]["desire"]["sleepy"].AsInt; break; case "Equipment": tempType = DesireType.Equipment; tempResolveAmount = structureJson[tempStructureCategory][tempStructureNumber]["desire"]["equipment"].AsInt; break; case "Tour": tempType = DesireType.Tour; tempResolveAmount = structureJson[tempStructureCategory][tempStructureNumber]["desire"]["tour"].AsInt; break; case "Convenience": tempType = DesireType.Convenience; tempResolveAmount = structureJson[tempStructureCategory][tempStructureNumber]["desire"]["convenience"].AsInt; break; case "Fun": tempType = DesireType.Fun; tempResolveAmount = structureJson[tempStructureCategory][tempStructureNumber]["desire"]["fun"].AsInt; break; case "Santuary": tempType = DesireType.Health; tempResolveAmount = structureJson[tempStructureCategory][tempStructureNumber]["desire"]["health"].AsInt; break; case "Rescue": tempType = DesireType.Rescue; break; } structure.name = structureJson[tempStructureCategory][tempStructureNumber]["name"]; structure.type = structureJson[tempStructureCategory][tempStructureNumber]["type"]; structure.capacity = structureJson[tempStructureCategory][tempStructureNumber]["capacity"].AsInt; structure.duration = structureJson[tempStructureCategory][tempStructureNumber]["duration"].AsInt; structure.charge = structureJson[tempStructureCategory][tempStructureNumber]["charge"].AsInt; structure.resolveType = tempType; structure.resolveAmount = tempResolveAmount; // 저장용. structure.structureCategory = tempStructureCategory; structure.structureNumber = tempStructureNumber; //preference structure.preference.SetPrefAdventurer(structureJson[tempStructureCategory][tempStructureNumber]["preference"]["adventurer"].AsFloat); structure.preference.SetPrefTourist(structureJson[tempStructureCategory][tempStructureNumber]["preference"]["tourist"].AsFloat); structure.preference.SetPrefHuman(structureJson[tempStructureCategory][tempStructureNumber]["preference"]["human"].AsFloat); structure.preference.SetPrefElf(structureJson[tempStructureCategory][tempStructureNumber]["preference"]["elf"].AsFloat); structure.preference.SetPrefDwarf(structureJson[tempStructureCategory][tempStructureNumber]["preference"]["dwarf"].AsFloat); structure.preference.SetPrefOrc(structureJson[tempStructureCategory][tempStructureNumber]["preference"]["orc"].AsFloat); structure.preference.SetPrefDog(structureJson[tempStructureCategory][tempStructureNumber]["preference"]["cat"].AsFloat); structure.preference.SetPrefUpperclass(structureJson[tempStructureCategory][tempStructureNumber]["preference"]["upperclass"].AsFloat); structure.preference.SetPrefMiddleclass(structureJson[tempStructureCategory][tempStructureNumber]["preference"]["middleclass"].AsFloat); structure.preference.SetPrefLowerclass(structureJson[tempStructureCategory][tempStructureNumber]["preference"]["lowerclass"].AsFloat); //desire structure.genre = structureJson[tempStructureCategory][tempStructureNumber]["genre"]; structure.expenses = structureJson[tempStructureCategory][tempStructureNumber]["expenses"].AsInt; int x = structureJson[tempStructureCategory][tempStructureNumber]["sitewidth"].AsInt; structure.extentWidth = x; int y = structureJson[tempStructureCategory][tempStructureNumber]["sitelheight"].AsInt; structure.extentHeight = y; structure.extent = new int[x, y]; //Debug.Log(x + " , " + y); for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { structure.extent[j, i] = structureJson[tempStructureCategory][tempStructureNumber]["site"][j + (i * x)].AsInt; } } }
protected virtual bool ChangedCandidateDesire(DesireType _desireType) { return(!this.desireController.HasCurrentDesire); }