static void Main(string[] args) { Bird myBird = new Bird(); myBird.Tweet(); Doggy myDog = new Doggy(); myDog.Woof(); }
static void Main(string[] args) { Bird myBird = new Bird(); myBird.Tweet(); Doggy myDog = new Doggy(); myDog.Woof(); }
public void OnTriggerEnter2D(Collider2D collision) { Doggy dog = collision.gameObject.GetComponent <Doggy>(); if (dog != null) { dog.TableUnder = this; } }
static void Main(string[] args) { Human human = ... // create an instance of Human, supply name and age Doggy doggy = ... // create an instance of Doggy, supply name and age Console.WriteLine("As a Human, {0} would be {1}", doggy.Name, DogToHumanConversion(doggy.Age)); Console.WriteLine("As a Dog, {0} would be {1}", human.Name, HumanToDogConversion(human.Age)); Console.ReadLine(); }
static void Main(string[] args) { Doggy dog = new Doggy("Max", 3); Human human = new Human("Leonardo", 23); Console.WriteLine("As a Human, {0} would be {1}", DogToHuman(dog).Name, DogToHuman(dog).Age); Console.WriteLine("As a Dog, {0} would be {1}", HumanToDog(human).Name, HumanToDog(human).Age); Console.ReadLine(); }
public void OnCollisionEnter2D(Collision2D collision) { Doggy dog = collision.gameObject.GetComponent <Doggy>(); if (dog != null) { if (OccupiedChairCount == this.Chairs.Length) { this.ResponsibleWaiter.DetectDogAt(dog.transform.position); } } }
public void OnTriggerStay2D(Collider2D collision) { Doggy dog = collision.gameObject.GetComponent <Doggy>(); if (dog != null) { if (OccupiedChairCount == this.Chairs.Length) { dog.transform.position = GetStandingPosition(); this.ResponsibleWaiter.DetectDogAt(GetStandingPosition()); } } }
/* * private void OnCollisionEnter(Collision collision) * { * print("HIT"); * if (this.CarriedOrder.Status == FoodOrder.OrderStatus.TransitFood) * { * float rand = Mathf.Pow(Random.value, 1 / this.CarriedOrder.Size * 3); * if (rand > 0.5) * { * Object toCreate = poptart; * if (rand > 0.75) * { * if (rand < .9) * { * toCreate = eggs; * } * else if (rand < .98) * toCreate = bacon; * else * toCreate = steak; * } * Instantiate(toCreate, this.transform.position, this.transform.rotation); * * } * } * } */ void OnTriggerStay2D(Collider2D other) { Doggy dog = other.gameObject.GetComponent <Doggy>(); if (dog != null) { float angleFromDetection = Mathf.Abs(Mathf.DeltaAngle(DirectionFrom(other.transform.position), this.LookingDirection)); if (angleFromDetection < DetectionAngle) { if (!dog.IsUnderTable()) { DetectDogAt(other.transform.position); } else if (this.DogSearchTime - this.ChaseCoolDown < 0.1F * this.DogSearchTime) { //Check Table } if (this.currentTask == WaiterTask.ChaseDog && Vector3.Distance(dog.transform.position, this.transform.position) < this.GrabRange) { control.GameOver(); } } } }
public static void Main(string[] args) { Console.WriteLine("----------- Strategy Pattern ------------"); var husky = new Husky(); husky.Bark(); husky.Run(); husky.SetBarkBehavior(new BarkElectronical()); husky.Bark(); Console.WriteLine("----------- Singleton ------------"); var bankValues1 = BankValues.GetInstance(); var bankValues2 = BankValues.GetInstance(); Console.WriteLine(bankValues1 == bankValues2 ? "Oh yes, I am the same instance" : "Nope, I am another BankValue instance."); Console.WriteLine("----------- Factory Method ------------"); var shop = new SoftwareShop().GetProgram(OfficeProg.Powerpoint); Console.WriteLine("----------- Facade ------------"); var officeTask = new OfficeFacade(); officeTask.PrintDocument(); Console.WriteLine("----------- State ------------"); var lumpi = new Doggy(); lumpi.Play(); lumpi.Anger(); lumpi.GiveMeal(); lumpi.Stroke(); lumpi.LeaveAlone(); Console.WriteLine("----------- DI with Autofac ------------"); var container = ContainerConfig.Configure(); using (var scope = container.BeginLifetimeScope()) { var app = scope.Resolve <IApplication>(); app.Run(); } Console.WriteLine("----------- Repository ------------"); ArticleRepository artRepo = new ArticleRepository(); List <Article> artList = artRepo.ReadAll(); Console.WriteLine($"Found {artList.Count} articles in the List"); artRepo.Create(new Article { }); var artLatest = artRepo.ReadLatest(); Console.WriteLine($"Title: {artLatest.Title}, ID: {artLatest.Id}"); artList = artRepo.ReadAll(); Console.WriteLine($"Found {artList.Count} articles in the List"); artRepo.Update(new Article { }); Console.WriteLine($"FOUND: {artRepo.ReadById(1).Title}"); artRepo.Delete(new Article { }); artList = artRepo.ReadAll(); Console.WriteLine($"Found {artList.Count} articles in the List"); }
public static Human DogToHuman(Doggy dog) { return(new Human(dog.Name, (dog.Age * 7))); }
void DoDogStuff(Doggy d) { Image1.src = d.Image; }