public void Run() { Fox aFox = new Fox(AnimalGender.female); Mouse aMouse = new Mouse(AnimalGender.male); Rabbit aRabbit = new Rabbit(AnimalGender.male); Tiger aTiger = new Tiger(AnimalGender.female); AnimalBaseIoC anotherFox = new AnimalBaseIoC( AnimalKind.fox, AnimalGender.female, () => { return(TheWorld.NearBy(AnimalKind.rabbit) || TheWorld.NearBy(AnimalKind.mouse)); }, () => { return(TheWorld.NearBy(AnimalKind.tiger)); } ); List <AnimalBase> animals = new List <AnimalBase> { aFox, aMouse, aRabbit, aTiger }; foreach (AnimalBase anAnimal in animals) { anAnimal.Live(PreAct, PostAct); Console.WriteLine(); } }
public void CheckFox(string name) { actionStack.Push($"Changed to {name} at {DateTime.Now}"); if (foxes.Read(name).Name == null) { foxes.Create(new Fox { Name = name }); foxDatabase.Add(new Fox() { Name = name }); currentFox = new Fox() { Tricks = new List <string>(), Drink = "Water", Food = "Chicken", Picture = "Default Fox", FoodAmount = 10, DrinkAmount = 12, LastFeed = DateTime.Now, LastDrink = DateTime.Now }; currentFox = foxes.Read(name); } else { currentFox = foxDatabase.Where(x => x.Name == name).ToList()[0]; currentFox = foxes.Read(name); } }
public IActionResult Information(string name) { myFox = new Fox("", "Grapes", "Soda"); myFox.Name = name; foxes.Add(myFox); return(View(foxes)); }
void Start() { clickSound = Deer.GetComponent <AudioSource>(); bgMusic = GetComponent <AudioSource>(); int randomnum = Random.Range(0, 5); for (int i = 0; i < randomnum; i++) { randomPos(x); } check2 = 0; check = 0; time = 0; BeariniPost = Bear.transform.position; FoxiniPost = Fox.transform.position; FroginiPost = Frog.transform.position; MiceiniPost = Mice.transform.position; CatiniPost = Cat.transform.position; KanciliniPost = Kancil.transform.position; CowiniPost = Cow.transform.position; DeeriniPost = Deer.transform.position; Cat.SetActive(false); Cow.SetActive(false); Kancil.SetActive(false); Bear.SetActive(false); Fox.SetActive(false); Frog.SetActive(false); Mice.SetActive(false); buttonnext1.SetActive(false); }
private static void Main(string[] args) { var fox = new Fox { Name = "Fox", Age = 1, }; var bird = new Bird { Name = "Bird", Age = 2, }; IZooManager zooManager = new ZooManager(); zooManager.Animals.Add(fox); zooManager.Animals.Add(bird); fox.Say(); bird.Fly(); zooManager.Show(); ICanInteract canInteract = new ZooManager(); canInteract.YouCanInteractWithIt(); Console.ReadKey(); }
private void PrepareAllGamePart() { PictureBox[] pictures = { picture1, picture2, picture3, picture4 }; foxes = new Fox[pictures.Length]; for (int index = 0; index < foxes.Length; index++) { foxes[index] = new Fox(); foxes[index].Name = "Fox No: " + (index + 1); foxes[index].FoxPictureBox = pictures[index]; foxes[index].TrackLength = 690; } TextBox[] texts = { text1, text2, text3 }; RadioButton[] radioButtons = { radio1, radio2, radio3 }; punters = new Punter[texts.Length]; for (int index = 0; index < punters.Length; index++) { punters[index] = Factory.GetPunter(index + 1); punters[index].PunterRadioButton = radioButtons[index]; punters[index].PunterRadioButton.Text = punters[index].Name; punters[index].PunterTextBox = texts[index]; punters[index].Amount = 50; } npFoxNo.Minimum = 1; npFoxNo.Maximum = foxes.Length; npFoxNo.Value = 1; }
public IActionResult CreateFox(string name) { var fox = new Fox(name); foxServices.AddFoxToList(fox); return(RedirectToAction("information", "home", new { name = name })); }
public void ShouldReturnHealthInAnimalLevel() { Fox fox = new Fox(); var result = fox.Health(); Assert.Equal(100, result); }
public void Enter(Fox fox) { _fox = fox; _fox.sleepyFX.Play(); _fox.isSleepState = true; _fox._navMeshAgent.speed = 0; }
public float calc_Fox_Runge_Kutta(float f, float r, float ts) { Rabbit rab = new Rabbit(); Fox fx = new Fox(); float k1 = 0; float k2 = 0; float k3 = 0; float k4 = 0; float n1 = 0; float n2 = 0; float n3 = 0; k1 = fx.fox_model(f, r); //f(y) n1 = rab.rabbit_model(r, f); float tmp = f + (ts / 2) * k1; float tmp2 = r + (ts / 2) * n1; k2 = fx.fox_model((tmp), tmp2); //f(y+(h/2)k1) n2 = rab.rabbit_model(tmp2, tmp); tmp = f + (ts / 2) * k2; tmp2 = r + (ts / 2) * n2; k3 = fx.fox_model((tmp), tmp2); //f(y+(h/2)k2) n3 = rab.rabbit_model(tmp2, tmp); tmp = f + ts * k3; tmp2 = r + (ts / 2) * n3; k4 = fx.fox_model((tmp), tmp2); //f(y+ hk3) f = f + ts * (k1 + 2 * k2 + 2 * k3 + k4) / 6; //y + h*(k1 + 2 * k2 + 2 * k3 + k4)/6 return f; }
public void UpdateSubtitleIdHash() { if (!string.IsNullOrEmpty(SubtitleId)) { SubtitleIdHash = Fox.GetStrCode32(SubtitleId); } }
public void AddFoxFromData(FoxData foxData) { GameObject foxToCreate = Instantiate(pfabFox, foxSpawnLocation.position, Quaternion.identity); Fox fox = foxToCreate.GetComponent <Fox>(); string foxType = foxData.foxType; FoxCollectionLog foxLog = FoxCollection.instance.GetFoxFromCollection(foxType); print(foxData); //assign values to the fox based on the data object created fox.foxName = foxData.foxName; fox.averageNapApart = foxData.napFrequency; fox.averageNapTime = foxData.napTime; fox.fullnessDecay = foxData.fullnessDecay; fox.fullness = foxData.fullness; fox.moveSpeed = foxData.moveSpeed; Transform foxModel = Instantiate(foxLog.foxMesh, foxToCreate.transform.position, foxToCreate.transform.rotation); foxToCreate.GetComponent <Fox>().foxModel = foxModel; //parent to the collision object in fox' foxModel.transform.SetParent(foxToCreate.GetComponent <Fox>().foxTransform); foxToCreate.name = foxData.foxName; print("Creating fox from sava data: " + fox.foxName); foxList.Add(foxToCreate); NameGenerator.instance.RemoveName(fox.foxName); //TODO remove fox name from the main list }
public void UpdateKey() { if (!string.IsNullOrEmpty(LangId)) { Key = Fox.GetStrCode32(LangId); } }
public void ShouldReturnEnergyInIHunt() { Fox fox = new Fox(); var result = fox.Energy; Assert.Equal(50, result); }
public void ShouldReturnWeaponInIHunt() { Fox fox = new Fox(); var result = fox.Weapon(); Assert.Equal("teeth and claws", result); }
public IActionResult AddTrickTo(string name, int newtrick) { Fox fox = foxes.SelectFox(name); fox.LearnTrick(newtrick); return(RedirectToAction("Index", new { Name = fox.Name })); }
public void ShouldReturnEatInCarnivoreLevel() { Fox fox = new Fox(); var result = fox.Eat(); Assert.Equal("I eat meat", result); }
public void AddFox(string name) { Fox newFox = new Fox { Name = name, Food = "pizza", Drink = "lemonade" }; foxList.Add(newFox); }
private void Awake() { foxCharacter = GetComponent <Fox>(); modelMesh = GetComponentInChildren <MeshRenderer>(); movementController = GetComponentInChildren <Movement>(); detectorFood = GetComponentInChildren <ObjectDetection>(); boxCollider = GetComponentInChildren <BoxCollider>(); }
public IActionResult trickUpdate(string trick, string name) { Fox currentfox = FoxContainer.FoxList.First(x => x.Name == name); currentfox.TrickList.Add(trick); currentfox.PossibleTricks.Remove(trick); return(Redirect($"/main/{name}")); }
public IActionResult ChangeNutrition(string name, string food, string drink) { Fox fox = foxes.SelectFox(name); fox.Food = food; fox.Drink = drink; return(RedirectToAction("Index", new { Name = name })); }
public IActionResult NutritionUpdate(string food, string drink, string name) { Fox currentfox = FoxContainer.FoxList.First(x => x.Name == name); currentfox.Food = food; currentfox.Drink = drink; return(Redirect($"/main/{name}")); }
public IActionResult Index(string name) { object nameObj = name.Clone(); Fox fox = new Fox(name); foxClubExample.AddFox(fox); return(View(nameObj)); }
public IActionResult TrickCenter(string trick, string name) { Fox currentFox = foxListService.GetFoxByName(name); currentFox.ListOfTricks.Add(trick); //return RedirectToAction("Index", currentFox); return(RedirectToAction("Index", new { name = name })); }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
public IActionResult Information() { var fox = new Fox() { Name = "Mr. Fox", Food = Food.Pizza, Drink = Drink.Lemonade }; return(View(fox)); }
public static void Main(string[] args) { while (true) { var line = Console.ReadLine(); Console.WriteLine("Next occurence: "); var result = new Fox(line, DateTime.Now).First(); Console.WriteLine(result); } }
void Start() { endCollider = end.GetComponent <Collider2D> (); fox = Instantiate <Fox> (foxPrefab, start.offScreenTransform.position, Quaternion.identity); foxCollider = fox.GetComponent <Collider2D> (); Dog[] dogArray = FindObjectsOfType <Dog> (); dogs = new List <Dog> (dogArray); Invoke("ShowExit", startDelay); }
public IActionResult Index(string name) { if (foxservice.IsLogged(name)) { Fox fox = foxservice.FindFoxByName(name); return(View(fox)); } else { return(RedirectToAction("login")); } }
public IActionResult NutritionStore(string food, string drink, string name) { //string name = Request.Query["name"]; Fox currentFox = foxListService.GetFoxByName(name); currentFox.Food = food; currentFox.Drink = drink; //return RedirectToAction("Index", currentFox); return(RedirectToAction("Index", new { name = name })); }
//probably can't just take the object, access through type //public FoxCollectionLog foxLog; public FoxData(GameObject foxObject) { Fox fox = foxObject.GetComponent <Fox>(); foxName = fox.foxName; foxType = fox.foxType; moveSpeed = fox.moveSpeed; napTime = fox.averageNapTime; napFrequency = fox.averageNapApart; fullness = fox.fullness; fullnessDecay = fox.fullnessDecay; }
public void CanCoexist_WhenCharacterAreFoxAndGoose_ReturnsReason() { // Arrange var goose = new Goose(); var fox = new Fox(); // Act var result = fox.CanCoexist(goose); // Assert Assert.Equal("Fox will eat the goose", result); }
public float calc_Rabbit_Runge_Kutta(float r, float f, float ts) { Rabbit rab = new Rabbit(); Fox fx = new Fox(); float k1 = 0; float k2 = 0; float k3 = 0; float k4 = 0; float m1 = 0; float m2 = 0; float m3 = 0; //k1 = rproxy.pop_inc(r, f); //f(y) k1 = rab.rabbit_model(r, f); m1 = fx.fox_model(f, r); float tmp = r + (ts / 2) * k1; float tmp2 = f + (ts / 2) * m1; //k2 = rproxy.pop_inc((tmp), f); //f(y+(h/2)k1) k2 = rab.rabbit_model((tmp), tmp2); m2 = fx.fox_model((tmp2), tmp); tmp = r + (ts / 2) * k2; tmp2 = f + (ts / 2) * m2; //k3 = rproxy.pop_inc((tmp), f); //f(y+(h/2)k2) k3 = rab.rabbit_model((tmp), tmp2); m3 = fx.fox_model((tmp2), tmp); tmp = r + ts * k3; tmp2 = f + ts * m3; //k4 = rproxy.pop_inc((tmp), f); //f(y+ hk3) k4 = rab.rabbit_model((tmp), tmp2); //y + h*(k1 + 2 * k2 + 2 * k3 + k4)/6 r = r + ts * (k1 + 2 * k2 + 2 * k3 + k4) / 6; return r; }
public double[,] rabbit_fox_horizontal_diff_ts(float r, float r_ts, float f, float f_ts, int yr, string r_integ_method, string f_integ_method) { int ts_factor = 10; //time step factor, to define numer of loops in unit of time, e.g. if ts=0.1 then we will have 10 loops in each unit of time float ts; if (r_ts > f_ts) ts = f_ts; else if (r_ts > f_ts) ts = r_ts; else ts = r_ts; if (ts >= 0.1) { ts_factor = 10; } else if (ts >= 0.009) //>=0.01 { ts_factor = 100; } else if (ts >= 0.0009) //>=0.001 ts_factor = 1000; //ts_factor = 1000; Rabbit rab = new Rabbit(); Fox fx_m = new Fox(); RungeKutta rk = new RungeKutta(); //the system will loop for each time step //int lp = Convert.ToInt32(Math.Truncate(yr / 0.1)); //total number of loop due to the defined year int lp = yr * ts_factor; lp = lp + 1; // r_result = new double[lp]; //array for rab //f_result = new double[lp]; //array for fox double[,] result = new double[lp, 2]; double[] t = new double[3]; t[1] = Convert.ToDouble(r_ts.ToString("#.####")); //time step of rabbit t[2] = Convert.ToDouble(f_ts.ToString("#.####")); //time step of fox int temp_r_ts = Convert.ToInt16(r_ts * ts_factor); int temp_f_ts = Convert.ToInt16(f_ts * ts_factor); float rx = r; float ry = f; float fx = r; float fy = f; for (int i = 1; i < lp; i++) { int m = i % temp_r_ts; //m for maintaining result of % operation if (m == 0 && i > 0) //check if the current time step is valid to run rabit model { if (r_integ_method == "Runge-Kutta") // Runge-Kutta integration of rabbit model { rx = rk.calc_Rabbit_Runge_Kutta(rx, ry, r_ts); } else rx = rx + rab.rabbit_model(rx, ry) * r_ts; //rx = rx + rabbit_with_diff_func(rx, ry) * r_ts; r = rx; } int n = i % temp_f_ts; if (n == 0 && i > 0) //check if the current time step is valid to run fox model { if (m == 0) fx = r; if (f_integ_method == "Runge-Kutta") // for Runge-Kutta integration of fox model { fy = rk.calc_Fox_Runge_Kutta(fy, fx, f_ts); } else fy = fy + fx_m.fox_model(fy, fx) * f_ts; //fy = fy + fox_with_diff_func(fy, fx) * f_ts; f = fy; fx = r; } if (m == 0) //if the time step meets ts of rabbit then copy value of f ry = f; //r_result[i] = r; // Convert.ToDouble(r.ToString("#.##")); result[i,0] = r; if (f >= 0) //f_result[i] = f; result[i, 1] = f; else //if fox pop <0 set it to 0 { f = 0; //f_result[i] = 0; result[i, 1] = 0; } if (result[i, 0] < 0) // (r_result[i] < 0) { //r_result[i] = 0;//if rab pop<0 then set the pop value to 0 and quit //f_result[i] = 0; result[i, 0] = 0;//if rab pop<0 then set the pop value to 0 and quit result[i, 1] = 0; break; } } return result; }
public double[,] rabbit_fox_horizontal_same_ts(float r, float f, int yr, float ts, string r_integ_method, string f_integ_method) { int ts_factor = 10; //time step factor, to define numer of loops in unit of time, e.g. if ts=0.1 then we will have 10 loops in each unit of time if (ts >= 0.1) { ts_factor = 10; } else if (ts >= 0.009) //>=0.01 { ts_factor = 100; } else if (ts >= 0.0009) //>=0.001 ts_factor = 1000; //ts_factor = 1000; Rabbit rab = new Rabbit(); Fox fx = new Fox(); RungeKutta rk = new RungeKutta(); //the system will loop according to the defined time step //int lp = Convert.ToInt16(Math.Truncate(yr / ts)); //total number of loop due to the defined time step //int lp = Convert.ToInt32(Math.Truncate(yr / 0.1)); //10 timestep in 1 year int lp = yr * ts_factor; lp = lp + 2; double[,] result = new double[lp, 2]; float fr = r; //rabbit population for fox model for (int i = 1; i < lp; i++) { //if (i % (Convert.ToInt16(Math.Truncate(ts * 10))) == 0) if (i % (Convert.ToInt16(ts * ts_factor)) == 0) { //run rabbit model if (r_integ_method == "Runge-Kutta") // for Runge-Kutta integration of rabbit { r = rk.calc_Rabbit_Runge_Kutta(r, f, ts); } else //for euler integration r = r + rab.rabbit_model(r, f) * ts; // r = r + rabbit_with_diff_func(r, f) * ts; //rabbit with px/(q+x) function than bx //run fox model if (f_integ_method == "Runge-Kutta") // for Runge-Kutta integration of fox model { f = rk.calc_Fox_Runge_Kutta(f, fr, ts); } else f = f + fx.fox_model(f, fr) * ts; //f = f + fox_with_diff_func(f, fr) * ts; //fox with px/(q+x) function than bx fr = r; //update current rabbit population for fox model if (r < 0) result[i, 0] = 0; else result[i, 0] = r; //Convert.ToDouble(r.ToString("#.##")); if (f < 0) result[i, 1] = 0; else result[i, 1] = f; // Convert.ToDouble(f.ToString("#.##")); if (result[i, 0] < 0) //(result[i, 0] < 1) { result[i, 0] = 0; //if pop<0 then set the pop value to 0 result[i, 1] = 0; break; } } else { if (r < 0) //(result[i, 0] < 1) { result[i, 0] = 0; //if pop<0 then set the pop value to 0 result[i, 1] = 0; break; } else { result[i, 0] = r; result[i, 1] = f; } } } return result; }