private bool NeedToAvoid(Animal other) { if (other == target) { return(false); } if (other.type == target.type) { return(target.loneWolf); } Vector3 toOther = other.GetPosition() - target.GetPosition(); if (Mathf.Abs(toOther.x) < intimidationRange && Mathf.Abs(toOther.z) < intimidationRange) { // how afraid are we of them? // If we are more afraid of them then we love them, we need to avoid them in this case. AnimalRelationship relationship = AnimalRelationships.Instance.GetOpinionOf(target.type, other.type); if (relationship.fear > relationship.love) { return(true); } else { return(false); } } else { // far enough away that we dont need to avoid them. return(false); } }
public ActionResult _MotherAdd(int id) { // Load Female Animals ViewData["FemaleParents"] = commonRep.GetFemaleAnimalsDropDown(id); AnimalRelationship ins = new AnimalRelationship(id); return(PartialView(ins)); }
private void CacheHatedTypes() { hatedTypes.Clear(); foreach (AnimalTypes type in (AnimalTypes[])System.Enum.GetValues(typeof(AnimalTypes))) { AnimalRelationship relationship = AnimalRelationships.Instance.GetOpinionOf(target.type, type); hatedTypes.Add(type, relationship.hate); } }
public JsonResult AddBirthScenario(int FemaleId, int MaleId, int ChildId, int TubeId, int BirthTypeId, int Success, int CompanyId, int UserKey, DateTime ModifiedDate) { //...Check if Tube was used if (TubeId != 0) { //...Tube was used, save history record InseminationHistory insem = new InseminationHistory(); insem.AnimalId = FemaleId; insem.TubeId = TubeId; insem.CompanyId = CompanyId; insem.ModifiedBy = UserKey; insem.ModifiedDate = ModifiedDate.AddDays(-274); insem = aiRep.InsertInseminationHistorySim(insem); if (insem.HistoryId == 0) { return(Json(insem.HistoryId, JsonRequestBehavior.AllowGet)); } } //...Insert Birth History BirthHistory birth = new BirthHistory(); birth.BirthTypeId = BirthTypeId; birth.ChildId = ChildId; birth.CompanyId = CompanyId; birth.FemaleParentId = FemaleId; birth.MaleParentId = MaleId; birth.ModifiedBy = UserKey; birth.Success = (Success == 1) ? true : false; birth.TubeId = TubeId; birth.ModifiedDate = ModifiedDate; birth = aiRep.InsertBirthHistorySim(birth); if ((birth.HistoryId != 0) && (birth.ChildId != 0)) { AnimalRelationship father = new AnimalRelationship(); father.ParentAnimalId = birth.MaleParentId; father.ChildAnimalId = birth.ChildId; father.ModiefiedDate = ModifiedDate; father.ModifiedBy = UserKey; father = aniRep.InsertAnimalRelationshipSim(father); AnimalRelationship mother = new AnimalRelationship(); mother.ParentAnimalId = birth.FemaleParentId; mother.ChildAnimalId = birth.ChildId; mother.ModiefiedDate = ModifiedDate; mother.ModifiedBy = UserKey; mother = aniRep.InsertAnimalRelationshipSim(mother); } return(Json(birth.HistoryId, JsonRequestBehavior.AllowGet)); }
public void AnimalWasKilled(Animal killer, Animal victim) { AnimalRelationship relationship = AnimalRelationships.Instance.GetOpinionOf(victim.type, killer.type); // increase how much we fear the thing which just killed us. relationship.fear += 0.02f; // Increase the hatred of the killed by those who love us. for (int i = 0; i < relationships.Length; i++) { if (relationships[i].target == victim.type) { if (relationships[i].love > 0) { GetOpinionOf(relationships[i].source, killer.type).hate += 0.05f * relationships[i].love; } } } }
public JsonResult _InsertBirthHistory(BirthHistory ins) { ins = aiRep.InsertBirthHistory(ins); if ((ins.HistoryId != 0) && (ins.ChildId != 0)) { AnimalRelationship father = new AnimalRelationship(); father.ParentAnimalId = ins.MaleParentId; father.ChildAnimalId = ins.ChildId; father = animalRep.InsertAnimalRelationship(father); AnimalRelationship mother = new AnimalRelationship(); mother.ParentAnimalId = ins.FemaleParentId; mother.ChildAnimalId = ins.ChildId; mother = animalRep.InsertAnimalRelationship(mother); } return(Json(new GridModel(commonRep.GetBirthHistories()))); }
public ActionResult _AddParent(AnimalRelationship ins) { ins = animalRep.InsertAnimalRelationship(ins); return(RedirectToAction("Tag", new { id = ins.ChildAnimalId })); }
private bool IsAnimalDangerous(Animal animal) { AnimalRelationship relationship = AnimalRelationships.Instance.GetOpinionOf(target.type, animal.type); return(relationship.fear > 0f); }