/// <summary> /// Remove item from cart /// </summary> /// <param name="animal">Item to remove</param> public void removeItem(Animal animal) { items.Remove(animal); // UPDATE cartTotal cartTotal -= animal.price; }
public void CreateAnimal(string s, int ag) { Animal a = new Animal (); a.name = s; int ran = Random.Range (0, 2); if (ran == 0) { a.gender = GenderTypes.Male; } else { a.gender = GenderTypes.Female; } a.age = ag; float ragd = Random.Range(1.2f,3f); ragd = Mathf.Pow(ragd,3f); a.ageOfDeath = (int)ragd; if (a.ageOfDeath < a.age) { a.ageOfDeath += a.age; } Debug.Log ("AGE "+ag+" "+a.ageOfDeath); animals.Add (a); FamilyResources.instance.UpdateAmountOfAnimals (); }
private static void CalculateEveryAnimalAverageAge(Animal[] animals) { int frogYears = 0, frogs = 0; int tomcatYears = 0, tomcats = 0; int kittenYears = 0, kittens = 0; int dogYears = 0, dogs = 0; foreach (Animal animal in animals) { switch (animal.GetType().ToString()) { case "Kitten": kittenYears += animal.Age; kittens++; break; case "Frog": frogYears += animal.Age; frogs++; break; case "Tomkat": tomcatYears += animal.Age; tomcats++; break; case "Dog": dogYears += animal.Age; dogs++; break; default: break; } } Console.WriteLine("Dogs average age is {0}", (decimal)dogYears / dogs); Console.WriteLine("Kittens average age is {0}", (decimal)kittenYears / kittens); Console.WriteLine("Tomcats average age is {0}", (decimal)tomcatYears / tomcats); Console.WriteLine("Frogs average age is {0}", (decimal)frogYears / frogs); }
static void Main() { Animal[] animals = new Animal[] { new Tomcat("Pesho", 2), new Kitten("Mimi", 4), new Dog("Sharo", 3, Sex.Male), new Frog("Kermit", 5, Sex.Male) }; Cat[] cats = new Cat[] { new Kitten("Mimi", 2), new Tomcat("Gosho", 6) }; Console.WriteLine("# Animals"); foreach (Animal animal in animals) Console.WriteLine(animal); Console.WriteLine("# Produce sound"); foreach (ISound animal in animals) Console.WriteLine(animal.ProduceSound()); Console.WriteLine("# Average"); Console.WriteLine(animals.Average(animal => animal.Age)); Console.WriteLine(cats.Average(cat => cat.Age)); }
static void Main(string[] args) { WriteHeader("Jedan objekat, klasika"); var myCat = new Animal("Garfield"); myCat.Walk("Cat"); myCat.Talk("Cat"); WriteHeader("Više objekata"); var animals = new List<KeyValuePair<string, Animal>> { new KeyValuePair<string, Animal>("Cat", new Animal("Garfield")), new KeyValuePair<string, Animal>("Dog", new Animal("Locko")), new KeyValuePair<string, Animal>("Dog", new Animal("Pajko")) }; foreach (var animal in animals) { animal.Value.Walk(animal.Key); animal.Value.Talk(animal.Key); } Console.Read(); }
public AdministrationForm() { InitializeComponent(); administration = new Administration(); currentlySelected = null; }
public void can_get_animals_using_explicit_relationship_between_animal_and_enclosure() { using (var sandbox = new LocalDb()) { Runner.MigrateToLatest(sandbox.ConnectionString); using (var context = new ZooDbContext(sandbox.ConnectionString)) { var enclosure = new Enclosure() { Id = 1, Name = "Kenya", Location = "Africa", Environment = "Sahara" }; var animal = new Animal() { Name = "Nala", Species = "Lion", EnclosureId = 1 }; context.Animals.Add(animal); context.Enclosures.Add(enclosure); context.SaveChanges(); var controller = new HomeController() { Database = context }; var result = controller.Index() as ViewResult; var model = result == null ? new IndexViewModel() : result.Model as IndexViewModel; Assert.Equal(1, model.Animals.Count()); Assert.Equal("Nala", model.Animals.First().AnimalName); } } }
static void loopThroughAnimals(Animal[] AnimalArray) { for (int i = 0; i < AnimalArray.Length; i++) { AnimalArray[i].SaySomething(); } }
public static IDictionary<string, decimal> GetAverageAge(Animal[] animals) { return animals.GroupBy(x => x.GetType()).ToDictionary( x => x.Key.Name, x => x.Average(y => y.Age) ); }
static void Main(string[] args) { Animal[] animals = new Animal[8] { new Dog("Sharo", 12, Gender.Male), new Frog("Froggy", 1, Gender.Female), new Kitten("Kitty", 3), new Kitten("Katya", 4), new Tomcat("Gosho", 5), new Tomcat("Assen", 2), new Frog("Hopper", 2, Gender.Female), new Dog("Murdzho", 17, Gender.Male), }; var dogsAverageAge = animals.Where(x => x is Dog).Average(x => x.Age); Console.WriteLine("The average age of all dogs is: {0}", dogsAverageAge); var frogsAverageAge = animals.Where(x => x is Frog).Average(x => x.Age); Console.WriteLine("The average age of all frogs is: {0}", frogsAverageAge); var kittensAverageAge = animals.Where(x => x is Kitten).Average(x => x.Age); Console.WriteLine("The average age of all kittens is: {0}", kittensAverageAge); var tomcatsAverageAge = animals.Where(x => x is Tomcat).Average(x => x.Age); Console.WriteLine("The average age of all tomcats is: {0}", tomcatsAverageAge); }
public QuestionsViewModel(Animal animal) { AnimalFeature = animal.Feature; AnimalId = animal.Id; AnimalName = animal.Name; Step = 1; }
static void Main(string[] args) { // 10) Create an arary of Animal objects and object of Animals // print animals with foreach operator for object of Animals Animal[] animal = new Animal[5]; animal[0] = new Animal("Dog", 30); animal[1] = new Animal("Cat", 7); animal[2] = new Animal("Cow", 1200); animal[3] = new Animal("Tiger", 500); animal[4] = new Animal("Lion", 600); Animals zoo = new Animals(animal); Console.WriteLine("Animals:"); print(zoo); // 11) Invoke 3 types of sorting // and print results with foreach operator for array of Animal objects Console.WriteLine(new string('*', 30)); Console.WriteLine("Sorting by genus:" ); Array.Sort(animal); print(zoo); Console.WriteLine(new string('*', 30)); Console.WriteLine("Sorting by weigh ascending:"); Array.Sort(animal, Animal.SortWeightAscending); print(zoo); Console.WriteLine(new string('*', 30)); Console.WriteLine("Sorting by genus descending:"); Array.Sort(animal, Animal.SortGenusDescending); print(zoo); Console.ReadLine(); }
public bool CheckMatch(Animal animal) { int x = animal.Index; // animal's row int y = Block[x].IndexOf(animal.gameObject); // animal's column for (int i = 0; i < 8; i++) { Animal first = ((GameObject)Block[x][i]).GetComponent<Animal>(); Animal second = ((GameObject)Block[x][i + 1]).GetComponent<Animal>(); Animal third = ((GameObject)Block[x][i + 2]).GetComponent<Animal>(); if (first.ClipName == second.ClipName && second.ClipName == third.ClipName) { if (first == animal || second == animal || third == animal) return true; } } for (int i = 0; i < 4; i++) { Animal first = ((GameObject)Block[i][y]).GetComponent<Animal>(); Animal second = ((GameObject)Block[i + 1][y]).GetComponent<Animal>(); Animal third = ((GameObject)Block[i + 2][y]).GetComponent<Animal>(); if (first.ClipName == second.ClipName && second.ClipName == third.ClipName) { if (first == animal || second == animal || third == animal) return true; } } return false; }
public static void Property2() { var duck = new Animal() { Name = "Donal" }; var property = duck.GetType().GetProperty("Name"); var value = (string)property.GetValue(duck,null); Console.WriteLine("Valor property WTIF:" + value); }
/// <summary> /// Add item to cart /// </summary> /// <param name="animal">Item to add</param> public void addItem(Animal animal) { items.Add(animal); // UPDATE cartTotal cartTotal += animal.price; }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["AnimalID"] != null) { if (Session["User"] == null) { Response.Redirect("~/Account/Login?ReturnUrl=Animal/Animal?AnimalID=" + Request.QueryString["AnimalID"].ToString()); } WebsiteUser Op = (WebsiteUser)Session["User"]; if (Animal.Exists(Convert.ToUInt32(Request.QueryString["AnimalID"].ToString()))) { Page.Title = "Animal - " + Animal.Id2Name(Convert.ToUInt32(Request.QueryString["AnimalID"].ToString())); Animal Animalito = new Animal(Convert.ToUInt32(Request.QueryString["AnimalID"].ToString())); if (Animal.isValidOwner(Op, Convert.ToUInt32(Request.QueryString["AnimalID"].ToString()))) { if (!IsPostBack) LoadFields(Animalito); } else Response.Redirect("~/Animal/"); } else { Response.Redirect("~/Animal/"); } } else Response.Redirect("~/Animal/"); }
public async static Task<String> GetPictureAsync(Animal animal) { try { Xamarin.Insights.Track("GetPicture", new Dictionary<string, string> { {"animal", animal.ToString()} }); if(animal == Animal.Random) { var next = random.Next(0, 100); if(next < 35) animal = Animal.Cat; else if(next < 70) animal = Animal.Dog; else animal = Animal.Otter; } var url = string.Empty; switch (animal) { case Animal.Cat: url = CatUrl; break; case Animal.Dog: url = DogUrl; break; default: url = OtterUrl; break; } var client = new HttpClient(new ModernHttpClient.NativeMessageHandler()); if (client.DefaultRequestHeaders.CacheControl == null) client.DefaultRequestHeaders.CacheControl = new CacheControlHeaderValue(); client.DefaultRequestHeaders.CacheControl.NoCache = true; client.DefaultRequestHeaders.IfModifiedSince = DateTime.UtcNow; client.DefaultRequestHeaders.CacheControl.NoStore = true; client.Timeout = new TimeSpan(0, 0, 10); var imageUrl = await client.GetStringAsync(url); if (!string.IsNullOrWhiteSpace(imageUrl) && imageUrl.EndsWith("\n")) imageUrl = imageUrl.TrimEnd('\n'); return imageUrl; } catch (Exception ex) { return string.Empty; } }
void UseIsOperator(Animal a) { if (a is Mammal) { Mammal m = (Mammal)a; m.Eat(); } }
public static void Property() { var horse = new Animal() { Name = "Ed"}; var type = horse.GetType(); var property = type.GetProperty("Name"); var value = property.GetValue(horse, null); Console.WriteLine("Nome do Animal é :{0}", value); }
public void can_make_nested_property() { var animal = new Animal(); var property = PropertyFactory.Create(typeof(Animal), "Color.Red"); Assert.DoesNotThrow(() => Assert.Equal(animal.Color.Red, property.Get(animal))); Assert.DoesNotThrow(() => property.Set(animal, 20)); Assert.Equal(20, animal.Color.Red); }
// Methods public int TryEatAnimal(Animal animal) { if (animal != null && animal.Size <= this.Size) { return animal.GetMeatFromKillQuantity(); } return 0; }
// Method public int TryEatAnimal(Animal animal) { if (animal != null && (animal.Size <= this.Size || animal.State == AnimalState.Sleeping)) { return animal.GetMeatFromKillQuantity(); } return 0; }
protected void LoadFields(Animal obj) { Nome.Text = obj.Name; Raca.Text = obj.Race; Especie.Text = obj.Species; Idade.Text = Convert.ToString(obj.Age); Peso.Text = Convert.ToString(obj.Weight); Temperatura.Text = Convert.ToString(obj.Temperature); }
public double GetAverage(Animal[] animals) { double sumAge = 0; foreach (var item in animals) { sumAge += item.Age; } return sumAge / animals.Length; }
// CalcAvAge public static float AverageAge(Animal[] animals) { float sumOfAges = 0; foreach (var animal in animals) { sumOfAges += animal.Age; } return sumOfAges / animals.Length; }
public static double AvarageAge(Animal[] animals) { double sum = 0; foreach (var a in animals) { sum += a.Age; } return sum/animals.Length; }
public int TryEatAnimal(Animal animal) { if (animal != null && (animal.Size <= BoarDefaultSize)) { return animal.GetMeatFromKillQuantity(); } return 0; }
public static void Method() { var horse = new Animal(); var type = horse.GetType(); var method = type.GetMethod("Speak"); object[] arguments = new object[1] { "test" }; var value = (string)method.Invoke(horse, arguments); Console.WriteLine("Retorno do método Speak: {0}", value); }
public int TryEatAnimal(Animal animal) { if (this.Size >= animal.Size || animal.State == AnimalState.Sleeping ||) { return animal.GetMeatFromKillQuantity(); } return 0; }
public void should_allow_set_when_property_is_writeable() { var property = PropertyFactory.Create(typeof(Animal), "Name"); var animal = new Animal { Name = "before" }; Assert.True(property.CanWrite); Assert.DoesNotThrow(() => property.Set(animal, "after")); Assert.Equal("after", animal.Name); }
private void InitKeyboardSetup() { var keymapper = defaultInputSetup.Mapper.GetInputBindProvider <KeyInputBindProvider>(); #region Movement keymapper.Map(new KeyTrigger("Move left", Keys.A, Keys.Left), (triggered, args) => { MotionEngine.GoalVelocityX = VelocityFunc(args, -speed); }); keymapper.Map(new KeyTrigger("Move right", Keys.D, Keys.Right), (triggered, args) => { MotionEngine.GoalVelocityX = VelocityFunc(args, speed); }); keymapper.Map(new KeyTrigger("Move up", Keys.W, Keys.Up), (triggered, args) => { MotionEngine.GoalVelocityY = VelocityFunc(args, -speed); if (Equals(Animator.CurrentAnimation, Animator.GetAnimation("walk_up"))) { return; } Animator.ChangeAnimation("walk_up"); Animator.FlipX = false; Animator.FlipY = false; }); keymapper.Map(new KeyTrigger("Move down", Keys.S, Keys.Down), (triggered, args) => { MotionEngine.GoalVelocityY = VelocityFunc(args, speed); if (Equals(Animator.CurrentAnimation, Animator.GetAnimation("walk_down"))) { return; } Animator.ChangeAnimation("walk_down"); Animator.FlipX = false; Animator.FlipY = false; }); keymapper.Map(new KeyTrigger("Flip left", Keys.A, Keys.Left), (triggered, args) => { // joudutaan flippaan Animator.FlipX = true; if (Equals(Animator.CurrentAnimation, Animator.GetAnimation("walk_right"))) { return; } Animator.ChangeAnimation("walk_right"); }, InputState.Pressed | InputState.Down); keymapper.Map(new KeyTrigger("Flip right", Keys.D, Keys.Right), (triggered, args) => { Animator.FlipX = false; if (Equals(Animator.CurrentAnimation, Animator.GetAnimation("walk_right"))) { return; } Animator.ChangeAnimation("walk_right"); }, InputState.Pressed | InputState.Down); #endregion keymapper.Map(new KeyTrigger("Interact", Keys.Space), (triggered, args) => { TryInteract(args); }); keymapper.Map(new KeyTrigger("Next day", Keys.F1), (triggered, args) => { if (args.State == InputState.Pressed) { CalendarSystem calendar = game.Components.First( c => c is CalendarSystem) as CalendarSystem; calendar.SkipDay(23, 45); } }); keymapper.Map(new KeyTrigger("Previous tool", Keys.Q), (triggered, args) => { Inventory.PreviousTool(); }, InputState.Released); keymapper.Map(new KeyTrigger("Next tool", Keys.E), (triggered, args) => { Inventory.NextTool(); }, InputState.Released); keymapper.Map(new KeyTrigger("Spawn dog", Keys.F2), (triggered, args) => { if (args.State == InputState.Pressed) { AnimalDataset dataset = (game.Components.First( c => c is RepositoryManager) as RepositoryManager).GetDataSet <AnimalDataset>(p => p.Type == "Dog"); Animal dog = new Animal(game, dataset); dog.Position = position; world.WorldObjects.AddGameObject(dog); } }); keymapper.Map(new KeyTrigger("Spawn cow", Keys.F3), (triggered, args) => { if (args.State == InputState.Pressed) { AnimalDataset dataset = game.Components.GetGameComponent <RepositoryManager>() .GetDataSet <AnimalDataset>(d => d.Type == "Cow"); Animal cow = new Animal(game, dataset); cow.Position = position; world.WorldObjects.AddGameObject(cow); } }); keymapper.Map(new KeyTrigger("Power tool", Keys.Z), PowerUpTool, InputState.Pressed | InputState.Down); keymapper.Map(new KeyTrigger("Interact with tool", Keys.Z), InteractWithTool, InputState.Released); }
public FoundAnimalResponse(Animal animal) { Animal = animal; }
/// <summary> /// Adds an animal to the zoo. /// </summary> /// <param name="animal">The animal to add.</param> public void AddAnimal(Animal animal) { this.animals.Add(animal); }
public async Task <IActionResult> Put(string name, [FromBody] Animal animal) { return(Ok(_animalsService.UpdateAnimelCatlog(animal))); }
public bool isReactive(Animal me, Animal you, ref Vector2 dir, float dist) { return((you.AnimalType == AnimalType.Fish) && (dist < me.AnimalSpec.DetectionDistance)); }
public AnimalAlreadyAdded(Animal animal) { Animal = animal; }
public void Put(int id, [FromBody] Animal animal) { animal.AnimalId = id; _db.Entry(animal).State = EntityState.Modified; _db.SaveChanges(); }
public void UpdateAnimal(Animal animal) { _unitOfWork.AnimalRepository.Update(animal); _unitOfWork.SaveChanges(); }
/// <remarks/> public void sendAsync(Animal args0) { this.sendAsync(args0, null); }
private Animal animal; // композиция public LadyWithAnAnimal(Animal animal) { this.animal = animal; }
public ActionResult Create(Animal model) { return(View(new Animal())); }
public IHttpActionResult InsertAnimal(Animal animals) { return(Json(new AnimalDAO().InsertAnimal(animals))); }
void OnEnable() { animal = (Animal)target; }
public Elk(Animal parent, Vector3 pos, bool corpse = false) : base(parent, pos, species, corpse) { }
public AnimalAdded(Animal animal) { Animal = animal; }
public IHttpActionResult DeleteAnimals(Animal animals) { return(Json(new AnimalDAO().DeleteAnimals(animals))); }
/// <remarks/> public System.IAsyncResult Beginsend(Animal args0, System.AsyncCallback callback, object asyncState) { return(this.BeginInvoke("send", new object[] { args0 }, callback, asyncState)); }
public IActionResult Edit(int id) { Animal animal = dataManager.Animals.GetAnimalById(id); return(View(animal)); }
public void Post([FromBody] Animal animal) { _db.Animals.Add(animal); _db.SaveChanges(); }
static void ActOnAnimal(Animal a) { Console.WriteLine(a.NumberOfLegs); }
public AnimalsShould() { cow = new Animal(); labrador = new Dog(); }
public Feed(Animal host) { m_host = host; m_name = "Feed"; }
public ActionResult Create(Animal animal) { _db.Animals.Add(animal); _db.SaveChanges(); return(RedirectToAction("Index")); }
// Update is called once per frame void Update() { float vertical = Input.GetAxisRaw("Vertical"); float horizontal = Input.GetAxisRaw("Horizontal"); animator.SetFloat("vertical", vertical); animator.SetFloat("horizontal", horizontal); animator.SetBool("walking", Mathf.Abs(horizontal) > 0.01 || Mathf.Abs(vertical) > 0.01); animator.SetBool("walkingDiagonal", Mathf.Abs(horizontal) > 0.01 && Mathf.Abs(vertical) > 0.01); Vector2 walkingDirection = Vector2.right * horizontal + Vector2.up * vertical; rb.velocity = walkingDirection.normalized * walkingSpeed; bool ActionE = Input.GetKeyDown(KeyCode.E); bool ActionF = Input.GetKeyDown(KeyCode.F); if (ActionF) { if (follower == null) { Collider2D[] boxes = getLookBoxes(); foreach (var hit in boxes) { Follower f = hit.gameObject.GetComponent <Follower>(); if (f != null) { follower = f; follower.followMe(transform); break; } } } else { follower.unfollow(); follower = null; } } if (ActionE) { Collider2D[] boxes = getLookBoxes(); foreach (var hit in boxes) { BuildingAnimalController f = hit.gameObject.GetComponent <BuildingAnimalController>(); if (f != null && follower != null) { if (f.addAnimal(follower.GetComponentInParent <Animal>())) { follower.unfollow(); follower = null; break; } } if (f != null && follower == null) { Animal a = f.getFirstAnimal(); follower = a.gameObject.GetComponent <Follower>(); if (follower != null) { follower.followMe(transform); } } } } }
public object TestFromTypedToAny(Animal value) { return(value); }
public static bool Prefix(InteractableSentry __instance) { RocketPlayer ownerPlayer = new RocketPlayer(__instance.owner.ToString()); bool hasWeapon = (bool)hasWeaponField.GetValue(__instance); bool isFiring = (bool)isFiringField.GetValue(__instance); bool isAiming = (bool)isAimingField.GetValue(__instance); float lastScan = (float)lastScanField.GetValue(__instance); float lastFire = (float)lastFireField.GetValue(__instance); float fireTime = (float)fireTimeField.GetValue(__instance); float lastAim = (float)lastAimField.GetValue(__instance); ItemWeaponAsset displayAsset = displayAssetField.GetValue(__instance) as ItemWeaponAsset; Attachments attachments = attachmentsField.GetValue(__instance) as Attachments; bool interact = (bool)interactField.GetValue(__instance); var playersInRadius = (List <Player>)playersInRadiusField.GetValue(null); var zombiesInRadius = (List <Zombie>)zombiesInRadiusField.GetValue(null); var animalsInRadius = (List <Animal>)animalsInRadiusField.GetValue(null); var targetPlayer = targetPlayerField.GetValue(__instance) as Player; var targetZombie = targetZombieField.GetValue(__instance) as Zombie; var targetAnimal = targetAnimalField.GetValue(__instance) as Animal; var aimTransform = aimTransformField.GetValue(__instance) as Transform; if (__instance.isPowered) { Vector3 vector3_1 = __instance.transform.position + new Vector3(0.0f, 0.65f, 0.0f); Vector3 vector3_2; if ((double)Time.realtimeSinceStartup - (double)lastScan > 0.100000001490116) { lastScanField.SetValue(__instance, Time.realtimeSinceStartup); float a = 48f; if (hasWeapon) { a = Mathf.Min(a, ((ItemWeaponAsset)displayAsset).range); } float sqrRadius = a * a; float num = sqrRadius; Player player = (Player)null; Zombie zombie = (Zombie)null; Animal animal = (Animal)null; if (Provider.isPvP) { playersInRadius.Clear(); PlayerTool.getPlayersInRadius(vector3_1, sqrRadius, playersInRadius); for (int index = 0; index < playersInRadius.Count; ++index) { Player playersInRadiu = playersInRadius[index]; var currentRocketPlayer = new RocketPlayer(playersInRadiu.channel.owner.playerID.steamID.ToString()); if (currentRocketPlayer.HasPermission(GodPermission)) { continue; } if (!(playersInRadiu.channel.owner.playerID.steamID == __instance.owner) && !playersInRadiu.quests.isMemberOfGroup(__instance.group) && (!playersInRadiu.life.isDead && playersInRadiu.animator.gesture != EPlayerGesture.ARREST_START) && ((!playersInRadiu.movement.isSafe || !playersInRadiu.movement.isSafeInfo.noWeapons) && playersInRadiu.movement.canAddSimulationResultsToUpdates) && (!((UnityEngine.Object)player != (UnityEngine.Object)null) || playersInRadiu.animator.gesture != EPlayerGesture.SURRENDER_START) && (__instance.sentryMode != ESentryMode.FRIENDLY || (double)Time.realtimeSinceStartup - (double)playersInRadiu.equipment.lastPunching < 2.0 || playersInRadiu.equipment.isSelected && playersInRadiu.equipment.asset != null && playersInRadiu.equipment.asset.shouldFriendlySentryTargetUser)) { vector3_2 = playersInRadiu.look.aim.position - vector3_1; float sqrMagnitude = vector3_2.sqrMagnitude; if ((double)sqrMagnitude <= (double)num) { Vector3 vector3_3 = playersInRadiu.look.aim.position - vector3_1; float magnitude = vector3_3.magnitude; Vector3 vector3_4 = vector3_3 / magnitude; if (!((UnityEngine.Object)playersInRadiu != (UnityEngine.Object)targetPlayer) || (double)Vector3.Dot(vector3_4, aimTransform.forward) >= 0.5) { if ((double)magnitude > 0.025000000372529) { RaycastHit hit; PhysicsUtility.raycast(new Ray(vector3_1, vector3_4), out hit, magnitude - 0.025f, RayMasks.BLOCK_SENTRY, QueryTriggerInteraction.UseGlobal); if (!((UnityEngine.Object)hit.transform != (UnityEngine.Object)null) || !((UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform)) { PhysicsUtility.raycast(new Ray(vector3_1 + vector3_4 * (magnitude - 0.025f), -vector3_4), out hit, magnitude - 0.025f, RayMasks.DAMAGE_SERVER, QueryTriggerInteraction.UseGlobal); if ((UnityEngine.Object)hit.transform != (UnityEngine.Object)null && (UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform) { continue; } } else { continue; } } num = sqrMagnitude; player = playersInRadiu; } } } } } zombiesInRadius.Clear(); ZombieManager.getZombiesInRadius(vector3_1, sqrRadius, zombiesInRadius); for (int index = 0; index < zombiesInRadius.Count; ++index) { Zombie zombiesInRadiu = zombiesInRadius[index]; if (!zombiesInRadiu.isDead && zombiesInRadiu.isHunting) { Vector3 position = zombiesInRadiu.transform.position; switch (zombiesInRadiu.speciality) { case EZombieSpeciality.NORMAL: position += new Vector3(0.0f, 1.75f, 0.0f); break; case EZombieSpeciality.MEGA: position += new Vector3(0.0f, 2.625f, 0.0f); break; case EZombieSpeciality.CRAWLER: position += new Vector3(0.0f, 0.25f, 0.0f); break; case EZombieSpeciality.SPRINTER: position += new Vector3(0.0f, 1f, 0.0f); break; } vector3_2 = position - vector3_1; float sqrMagnitude = vector3_2.sqrMagnitude; if ((double)sqrMagnitude <= (double)num) { Vector3 vector3_3 = position - vector3_1; float magnitude = vector3_3.magnitude; Vector3 vector3_4 = vector3_3 / magnitude; if (!((UnityEngine.Object)zombiesInRadiu != (UnityEngine.Object)targetZombie) || (double)Vector3.Dot(vector3_4, aimTransform.forward) >= 0.5) { if ((double)magnitude > 0.025000000372529) { RaycastHit hit; PhysicsUtility.raycast(new Ray(vector3_1, vector3_4), out hit, magnitude - 0.025f, RayMasks.BLOCK_SENTRY, QueryTriggerInteraction.UseGlobal); if (!((UnityEngine.Object)hit.transform != (UnityEngine.Object)null) || !((UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform)) { PhysicsUtility.raycast(new Ray(vector3_1 + vector3_4 * (magnitude - 0.025f), -vector3_4), out hit, magnitude - 0.025f, RayMasks.DAMAGE_SERVER, QueryTriggerInteraction.UseGlobal); if ((UnityEngine.Object)hit.transform != (UnityEngine.Object)null && (UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform) { continue; } } else { continue; } } num = sqrMagnitude; player = (Player)null; zombie = zombiesInRadiu; } } } } animalsInRadius.Clear(); AnimalManager.getAnimalsInRadius(vector3_1, sqrRadius, animalsInRadius); for (int index = 0; index < animalsInRadius.Count; ++index) { Animal animalsInRadiu = animalsInRadius[index]; if (!animalsInRadiu.isDead) { Vector3 position = animalsInRadiu.transform.position; vector3_2 = position - vector3_1; float sqrMagnitude = vector3_2.sqrMagnitude; if ((double)sqrMagnitude <= (double)num) { Vector3 vector3_3 = position - vector3_1; float magnitude = vector3_3.magnitude; Vector3 vector3_4 = vector3_3 / magnitude; if (!((UnityEngine.Object)animalsInRadiu != (UnityEngine.Object)targetAnimal) || (double)Vector3.Dot(vector3_4, aimTransform.forward) >= 0.5) { if ((double)magnitude > 0.025000000372529) { RaycastHit hit; PhysicsUtility.raycast(new Ray(vector3_1, vector3_4), out hit, magnitude - 0.025f, RayMasks.BLOCK_SENTRY, QueryTriggerInteraction.UseGlobal); if (!((UnityEngine.Object)hit.transform != (UnityEngine.Object)null) || !((UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform)) { PhysicsUtility.raycast(new Ray(vector3_1 + vector3_4 * (magnitude - 0.025f), -vector3_4), out hit, magnitude - 0.025f, RayMasks.DAMAGE_SERVER, QueryTriggerInteraction.UseGlobal); if ((UnityEngine.Object)hit.transform != (UnityEngine.Object)null && (UnityEngine.Object)hit.transform != (UnityEngine.Object)__instance.transform) { continue; } } else { continue; } } num = sqrMagnitude; player = (Player)null; zombie = (Zombie)null; animal = animalsInRadiu; } } } } if ((UnityEngine.Object)player != (UnityEngine.Object)targetPlayer || (UnityEngine.Object)zombie != (UnityEngine.Object)targetZombie || (UnityEngine.Object)animal != (UnityEngine.Object)targetAnimal) { targetPlayerField.SetValue(__instance, player); targetZombieField.SetValue(__instance, zombie); targetAnimalField.SetValue(__instance, animal); lastFireField.SetValue(__instance, Time.realtimeSinceStartup + 0.1f); } } if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null) { switch (__instance.sentryMode) { case ESentryMode.NEUTRAL: case ESentryMode.FRIENDLY: isFiringField.SetValue(__instance, targetPlayer.animator.gesture != EPlayerGesture.SURRENDER_START); break; case ESentryMode.HOSTILE: isFiringField.SetValue(__instance, true); break; } isAimingField.SetValue(__instance, true); } else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null) { isFiringField.SetValue(__instance, true); isAimingField.SetValue(__instance, true); } else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null) { switch (__instance.sentryMode) { case ESentryMode.NEUTRAL: case ESentryMode.FRIENDLY: isFiringField.SetValue(__instance, targetAnimal.isHunting); break; case ESentryMode.HOSTILE: isFiringField.SetValue(__instance, true); break; } isAimingField.SetValue(__instance, true); } else { isFiringField.SetValue(__instance, false); isAimingField.SetValue(__instance, false); } if (isAiming && (double)Time.realtimeSinceStartup - (double)lastAim > (double)Provider.UPDATE_TIME) { lastAimField.SetValue(__instance, Time.realtimeSinceStartup); Transform transform = (Transform)null; Vector3 vector3_3 = Vector3.zero; if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null) { transform = targetPlayer.transform; vector3_3 = targetPlayer.look.aim.position; } else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null) { transform = targetZombie.transform; vector3_3 = targetZombie.transform.position; switch (targetZombie.speciality) { case EZombieSpeciality.NORMAL: vector3_3 += new Vector3(0.0f, 1.75f, 0.0f); break; case EZombieSpeciality.MEGA: vector3_3 += new Vector3(0.0f, 2.625f, 0.0f); break; case EZombieSpeciality.CRAWLER: vector3_3 += new Vector3(0.0f, 0.25f, 0.0f); break; case EZombieSpeciality.SPRINTER: vector3_3 += new Vector3(0.0f, 1f, 0.0f); break; } } else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null) { transform = targetAnimal.transform; vector3_3 = targetAnimal.transform.position + Vector3.up; } if ((UnityEngine.Object)transform != (UnityEngine.Object)null) { float yaw = Mathf.Atan2(vector3_3.x - vector3_1.x, vector3_3.z - vector3_1.z) * 57.29578f; double num = (double)vector3_3.y - (double)vector3_1.y; vector3_2 = vector3_3 - vector3_1; double magnitude = (double)vector3_2.magnitude; float pitch = Mathf.Sin((float)(num / magnitude)) * 57.29578f; BarricadeManager.sendAlertSentry(__instance.transform, yaw, pitch); } } if (isFiring && hasWeapon && (__instance.displayItem.state[10] > (byte)0 && !__instance.isOpen) && (double)Time.realtimeSinceStartup - (double)lastFire > (double)fireTime) { lastFireField.SetValue(__instance, lastFire + fireTime); if ((double)Time.realtimeSinceStartup - (double)lastFire > (double)fireTime) { lastFire = Time.realtimeSinceStartup; } float num1 = (float)__instance.displayItem.quality / 100f; if (attachments.magazineAsset == null) { return(false); } if (!ownerPlayer.HasPermission(IgnoreAmmoPermission)) { Console.WriteLine("Ammo reduction"); if ((__instance.sentryAsset.infiniteAmmo ? 1 : (((ItemGunAsset)displayAsset).infiniteAmmo ? 1 : 0)) == 0) { --__instance.displayItem.state[10]; } if (!__instance.sentryAsset.infiniteQuality && Provider.modeConfigData.Items.Has_Durability && (__instance.displayItem.quality > (byte)0 && (double)UnityEngine.Random.value < (double)((ItemWeaponAsset)displayAsset).durability)) { if ((int)__instance.displayItem.quality > (int)((ItemWeaponAsset)displayAsset).wear) { __instance.displayItem.quality -= ((ItemWeaponAsset)displayAsset).wear; } else { __instance.displayItem.quality = (byte)0; } } } if (attachments.barrelAsset == null || !attachments.barrelAsset.isSilenced || __instance.displayItem.state[16] == (byte)0) { AlertTool.alert(__instance.transform.position, 48f); } float num2 = ((ItemGunAsset)displayAsset).spreadAim * ((double)num1 < 0.5 ? (float)(1.0 + (1.0 - (double)num1 * 2.0)) : 1f); if (attachments.tacticalAsset != null && interact) { num2 *= attachments.tacticalAsset.spread; } if (attachments.gripAsset != null) { num2 *= attachments.gripAsset.spread; } if (attachments.barrelAsset != null) { num2 *= attachments.barrelAsset.spread; } if (attachments.magazineAsset != null) { num2 *= attachments.magazineAsset.spread; } if ((UnityEngine.Object)((ItemGunAsset)displayAsset).projectile == (UnityEngine.Object)null) { BarricadeManager.sendShootSentry(__instance.transform); byte pellets = attachments.magazineAsset.pellets; for (byte index1 = 0; (int)index1 < (int)pellets; ++index1) { EPlayerKill kill = EPlayerKill.NONE; uint xp = 0; float times = (float)(1.0 * ((double)num1 < 0.5 ? 0.5 + (double)num1 : 1.0)); Transform transform = (Transform)null; float num3 = 0.0f; if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null) { transform = targetPlayer.transform; } else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null) { transform = __instance.transform; } else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null) { transform = targetAnimal.transform; } if ((UnityEngine.Object)transform != (UnityEngine.Object)null) { vector3_2 = transform.position - __instance.transform.position; num3 = vector3_2.magnitude; } float num4 = (1f - num3 / ((ItemWeaponAsset)displayAsset).range) * (1f - ((ItemGunAsset)displayAsset).spreadHip) * 0.75f; if ((UnityEngine.Object)transform == (UnityEngine.Object)null || (double)UnityEngine.Random.value > (double)num4) { Vector3 forward = aimTransform.forward; forward += aimTransform.right * UnityEngine.Random.Range(-((ItemGunAsset)displayAsset).spreadHip, ((ItemGunAsset)displayAsset).spreadHip) * num2; forward += aimTransform.up * UnityEngine.Random.Range(-((ItemGunAsset)displayAsset).spreadHip, ((ItemGunAsset)displayAsset).spreadHip) * num2; forward.Normalize(); RaycastInfo raycastInfo = DamageTool.raycast(new Ray(aimTransform.position, forward), ((ItemWeaponAsset)displayAsset).range, RayMasks.DAMAGE_SERVER); if (!((UnityEngine.Object)raycastInfo.transform == (UnityEngine.Object)null)) { DamageTool.impact(raycastInfo.point, raycastInfo.normal, raycastInfo.material, (UnityEngine.Object)raycastInfo.vehicle != (UnityEngine.Object)null || raycastInfo.transform.CompareTag("Barricade") || raycastInfo.transform.CompareTag("Structure") || raycastInfo.transform.CompareTag("Resource")); if ((UnityEngine.Object)raycastInfo.vehicle != (UnityEngine.Object)null) { DamageTool.damage(raycastInfo.vehicle, false, Vector3.zero, false, ((ItemWeaponAsset)displayAsset).vehicleDamage, times, true, out kill, new CSteamID(), EDamageOrigin.Sentry); } else if ((UnityEngine.Object)raycastInfo.transform != (UnityEngine.Object)null) { if (raycastInfo.transform.CompareTag("Barricade")) { ushort result; if (ushort.TryParse(raycastInfo.transform.name, NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture, out result)) { ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, result); if (itemBarricadeAsset != null && (itemBarricadeAsset.isVulnerable || ((ItemWeaponAsset)displayAsset).isInvulnerable)) { DamageTool.damage(raycastInfo.transform, false, ((ItemWeaponAsset)displayAsset).barricadeDamage, times, out kill, new CSteamID(), EDamageOrigin.Sentry); } } } else if (raycastInfo.transform.CompareTag("Structure")) { ushort result; if (ushort.TryParse(raycastInfo.transform.name, NumberStyles.Any, (IFormatProvider)CultureInfo.InvariantCulture, out result)) { ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, result); if (itemStructureAsset != null && (itemStructureAsset.isVulnerable || ((ItemWeaponAsset)displayAsset).isInvulnerable)) { DamageTool.damage(raycastInfo.transform, false, raycastInfo.direction * Mathf.Ceil((float)attachments.magazineAsset.pellets / 2f), ((ItemWeaponAsset)displayAsset).structureDamage, times, out kill, new CSteamID(), EDamageOrigin.Sentry); } } } else if (raycastInfo.transform.CompareTag("Resource")) { byte x; byte y; ushort index2; if (ResourceManager.tryGetRegion(raycastInfo.transform, out x, out y, out index2)) { ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index2); if (resourceSpawnpoint != null && !resourceSpawnpoint.isDead && ((ItemWeaponAsset)displayAsset).hasBladeID(resourceSpawnpoint.asset.bladeID)) { DamageTool.damage(raycastInfo.transform, raycastInfo.direction * Mathf.Ceil((float)attachments.magazineAsset.pellets / 2f), ((ItemWeaponAsset)displayAsset).resourceDamage, times, 1f, out kill, out xp, new CSteamID(), EDamageOrigin.Sentry); } } } else if (raycastInfo.section < byte.MaxValue) { InteractableObjectRubble componentInParent = raycastInfo.transform.GetComponentInParent <InteractableObjectRubble>(); if ((UnityEngine.Object)componentInParent != (UnityEngine.Object)null && !componentInParent.isSectionDead(raycastInfo.section) && (componentInParent.asset.rubbleIsVulnerable || ((ItemWeaponAsset)displayAsset).isInvulnerable)) { DamageTool.damage(componentInParent.transform, raycastInfo.direction, raycastInfo.section, ((ItemWeaponAsset)displayAsset).objectDamage, times, out kill, out xp, new CSteamID(), EDamageOrigin.Sentry); } } } } } else { Vector3 point = Vector3.zero; if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null) { point = targetPlayer.look.aim.position; } else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null) { point = targetZombie.transform.position; switch (targetZombie.speciality) { case EZombieSpeciality.NORMAL: point += new Vector3(0.0f, 1.75f, 0.0f); break; case EZombieSpeciality.MEGA: point += new Vector3(0.0f, 2.625f, 0.0f); break; case EZombieSpeciality.CRAWLER: point += new Vector3(0.0f, 0.25f, 0.0f); break; case EZombieSpeciality.SPRINTER: point += new Vector3(0.0f, 1f, 0.0f); break; } } else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null) { point = targetAnimal.transform.position + Vector3.up; } DamageTool.impact(point, -aimTransform.forward, EPhysicsMaterial.FLESH_DYNAMIC, true); Vector3 direction = aimTransform.forward * Mathf.Ceil((float)attachments.magazineAsset.pellets / 2f); if ((UnityEngine.Object)targetPlayer != (UnityEngine.Object)null) { DamageTool.damage(targetPlayer, EDeathCause.SENTRY, ELimb.SPINE, __instance.owner, direction, (IDamageMultiplier)((ItemWeaponAsset)displayAsset).playerDamageMultiplier, times, true, out kill, true, ERagdollEffect.NONE); } else if ((UnityEngine.Object)targetZombie != (UnityEngine.Object)null) { IDamageMultiplier damageMultiplier = ((ItemWeaponAsset)displayAsset).zombieOrPlayerDamageMultiplier; DamageZombieParameters parameters = DamageZombieParameters.make(targetZombie, direction, damageMultiplier, ELimb.SPINE); parameters.times = times; parameters.legacyArmor = true; parameters.instigator = (object)__instance; DamageTool.damageZombie(parameters, out kill, out xp); } else if ((UnityEngine.Object)targetAnimal != (UnityEngine.Object)null) { IDamageMultiplier damageMultiplier = ((ItemWeaponAsset)displayAsset).animalOrPlayerDamageMultiplier; DamageAnimalParameters parameters = DamageAnimalParameters.make(targetAnimal, direction, damageMultiplier, ELimb.SPINE); parameters.times = times; parameters.instigator = (object)__instance; DamageTool.damageAnimal(parameters, out kill, out xp); } } } } __instance.rebuildState(); } } return(false); }
public void AnimalDoubleCkick(Animal animal) { _mainViewModel.AnimalDoubleCkick(animal); }
public override void RemoveAnimal(Animal animal) { animals.Remove(animal); }
private void Start() { agent = this.gameObject.GetComponent <NavMeshAgent>(); animal = this.gameObject.GetComponent <Animal>(); //movement = }
public void Handle(Animal a) { a.BeingHandled(); }