Exemplo n.º 1
0
 private void Awake()
 {
     instance                 = this;
     birdRigidbody2D          = GetComponent <Rigidbody2D>();
     birdRigidbody2D.bodyType = RigidbodyType2D.Static;
     state = State.WaitingToStart;
 }
Exemplo n.º 2
0
        private void NameMethod()
        {
            Animals b = new Birds(new Fly());
            Animals m = new Mammals(new Run());

            b.Run.Move();
            m.Run.Move();
        }
Exemplo n.º 3
0
        public void TestMethod13()
        {
            // Arrange
            Birds birds1 = new Birds();
            // Act
            Birds birds2 = new Birds("Неизвестный", "Неизвестный", 1, 100);

            // Assert
            Assert.AreEqual(birds1, birds2);
        }
Exemplo n.º 4
0
        public void SpawnBirds()
        {
            for (int i = Birds.Count; i <= 1000; i++)
            {
                var bird = new Bird();

                bird.MoveToWorld(GetRandomLocation(), Map.ZombieLand);
                Birds.Add(bird);
                bird.ZombieSerial = Uid;
            }
        }
Exemplo n.º 5
0
    public void SetBird(Birds bird)
    {
        TargetBird = bird;

        for (int i = 0; i < _trails.Count; i++)
        {
            Destroy(_trails[i].gameObject);
        }

        _trails.Clear();
    }
Exemplo n.º 6
0
        public PlayGameForm(Guns gun, Birds bird)
        {
            InitializeComponent();

            this.GameStatus   = GameStatus.Continue;
            this.SelectedGun  = gun;
            this.SelectedBird = bird;

            SetupCrossHair();

            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        }
Exemplo n.º 7
0
        private void Task_3()
        {
            Birds fish = new Birds("hh");  //название переменной fish? для класса Bird? серьезно? переменные должны быть понятными

            fish.Move();

            var anim = new Animals[] { new Fish("Jon"), new Birds("Don"), new Mammals("Shiki") };

            foreach (var an in anim)
            {
                an.Move();
            }
        }
Exemplo n.º 8
0
        private void OOP()
        {
            Birds fish = new Birds("hh");

            fish.Move();

            var anim = new Animals[] { new Fish("Jon"), new Birds("Don"), new Mammals("Shiki") };

            foreach (var an in anim)
            {
                an.Move();
            }
        }
Exemplo n.º 9
0
        public imgBackgroundOnGame(Guns gun, Birds bird)
        {
            // Bắt đầu load form mở đầu
            InitializeComponent();

            this.GameStatus   = GameStatus.Continue;
            this.SelectedGun  = gun;
            this.SelectedBird = bird;

            SetupCrossHair();

            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        }
        protected virtual void Restart()
        {
            Birds       = CreateBirds();
            LivingBirds = Birds.ToList();

            maxScore          = 0;
            pipes             = new List <Pipe>();
            pipeSpeed         = 5;
            nextPipeTime      = 2000;
            timeSinceLastPipe = 0;
            nextPipe          = randomPipeGenerator.GenerateNewPipe(pipeTexture.Width);
            pipes.Add(nextPipe);
        }
Exemplo n.º 11
0
        public IHttpActionResult DeleteBirds(int id)
        {
            Birds birds = db.Birds.Find(id);

            if (birds == null)
            {
                return(NotFound());
            }

            db.Birds.Remove(birds);
            db.SaveChanges();

            return(Ok(birds));
        }
Exemplo n.º 12
0
    public void ChangeBird()
    {
        TapCollider.enabled = false;

        if (_isGameEnded)
        {
            return;
        }


        Birds.RemoveAt(0);

        if (Birds.Count > 0)
        {
            SlingShoot.InitiateBirds(Birds[0]);
            _shotBird = Birds[0];
        }
    }
        protected override void Update(GameTime gameTime)
        {
            if (!LivingBirds.Any())
            {
                Restart();
            }

            foreach (var bird in LivingBirds)
            {
                bird.Update(nextPipe);
            }

            LivingBirds = Birds.Where(bird => bird.IsAlive).ToList();

            UpdatePipes(gameTime);

            base.Update(gameTime);
        }
Exemplo n.º 14
0
    void Start()
    {
        for (int i = 0; i < Birds.Count; i++)
        {
            Birds[i].OnBirdDestroyed += ChangeBird;
            Birds[i].OnBirdShot      += AssignTrail;
        }

        SlingShoot.InitiateBirds(Birds[0]);

        for (int i = 0; i < Enemies.Count; i++)
        {
            Enemies[i].OnEnemyDestroyed += CheckGameEnd;
        }

        TapCollider.enabled = false;
        _shotBird           = Birds[0];
    }
Exemplo n.º 15
0
            public static void Main()
            {
                Implement Imp    = new Implement();
                Animal    animal = new Animal();


                Carnivorous cn = new Carnivorous();
                Herbivorous hb = new Herbivorous();

                Console.WriteLine("Call function with animal obj");
                Imp.callFunction(animal);


                Console.WriteLine("Call function with Carnivorous obj");
                Imp.callFunction(cn);//Decision is take during runttime--We can pass object of Base class Animal or any of its derived class

                //We can call Behaviour method of Child class only with child class object as it is not declared with Virtual keyword
                Console.WriteLine("Call function with Herbivorous obj");

                Imp.callFunction(hb);
                Birds bird = new Birds();

                //Imp.callFunction(bird);--Not possible....We can pass only animal class object or its dervived classes
                Console.WriteLine("Calling the Behaviour method with Carnivorous class obj");
                cn.Behaviour();

                Console.ReadLine();

                //Animal animal1;

                //animal1 = new Animal();
                //animal1.FoodHabits();
                //animal.Behaviour();

                //animal1 = new Carnivorous();
                //animal1.FoodHabits();
                //animal1.Behaviour();

                //animal1= new Herbivorous();
                //animal1.FoodHabits();//Virtual method will call the corresponding method of what is beeing passed
                //animal1.Behaviour();//Normal method Always call the method of Base class only

                ////Carnivorous car = (Carnivorous)new Animal();--Error...Only parent class object can be used for instantiating child class and Viceversa is not possible
            }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            var list = new List <object>();

            pigs  a1 = new pigs("Поросяш", 12, "Свинья", "Хрюкает");
            Birds a  = new Birds("Вороныч", 4, "Ворон", "Каркает");
            cats  a2 = new cats("Убунта", 6, "Лев", "Рычит");

            list.Add(a1);
            list.Add(a);
            list.Add(a2);
            var array = list.ToArray();

            foreach (var elem in array)
            {
                Console.WriteLine(elem.ToString());
            }
            Console.Read();
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            Birds[] bird = new Birds [10];
            Random  r    = new Random();

            for (int i = 0; i < bird.Length; i++)
            {
                int rNumber = r.Next(1, 4);
                switch (rNumber)
                {
                case 1: bird[i] = new Sparrow();
                    break;

                case 2: bird[i] = new Penguin();
                    break;

                case 3: bird[i] = new Parrot();
                    break;

                case 4: bird[i] = new Ostrich();
                    break;
                }
            }
            for (int i = 0; i < bird.Length; i++)
            {
                if (bird[i] is Sparrow)
                {
                    ((Sparrow)bird[i]).Flyable();
                }
                else if (bird[i] is Penguin)
                {
                    ((Penguin)bird[i]).Flyable();
                }
                else if (bird[i] is Parrot)
                {
                    ((Parrot)bird[i]).Flyable();
                }
                else if (bird[i] is Ostrich)
                {
                    ((Ostrich)bird[i]).Flyable();
                }
            }
        }
        public JsonResult Create(Birds birds)
        {
            string message = "";

            try
            {
                if (ModelState.IsValid)
                {
                    db.Birds.Add(birds);
                    db.SaveChanges();
                    message = "Data Saved Successfully";
                }
            }
            catch (Exception)
            {
                message = "Error Occured";
            }
            return(Json(message, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 19
0
        static void Main(string[] args)
        {
            //Animal a = new Animal();
            //a.Move();
            //Mammals m = new Mammals();
            //m.Move();
            //Birds b = new Birds();
            //b.Move();

            Animal a;

            a = new Animal();
            a.Move();
            a = new Mammals();
            a.Move();
            a = new Birds();
            a.Move();
            a = new Reptiles();
            a.Move();
        }
Exemplo n.º 20
0
        protected override void Restart()
        {
            if (Birds != null)
            {
                var maxScore = Birds.Select(bird => bird.Score).Max();
                if (maxScore >= 100)
                {
                    var primeBird = Birds.First(bird => bird.Score == maxScore);
                    var weights   = aiTrainingFramework.CurrentGenWeights[primeBird.Id];
                    JsonFileWriter.SerializeWeights(weights, @"D:\VS Projects\MachineLearningGames\flappyBirdWeights.json");
                    Environment.Exit(0);
                }

                var scores = Birds.Select(bird => (bird.Id, (bird.Score + 1) * aliveTime[bird.Id])).ToList();
                Controllers = aiTrainingFramework.CreateNewControllers(scores);
            }

            aliveTime = Controllers.ToDictionary(c => c.Id, c => 0);

            base.Restart();
        }
Exemplo n.º 21
0
        public IHttpActionResult PostBirds(Birds birds)
        {
            db.Birds.Add(birds);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (BirdsExists(birds.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = birds.ID }, birds));
        }
        private void btnStartGame_Click(object sender, EventArgs e)
        {
            Guns  SelectedGun  = Guns.Shotgun;
            Birds SelectedBird = Birds.Parrot;

            if (cmbGun.SelectedItem.ToString() == "9mm Glock 17")
            {
                SelectedGun = Guns.Glock;
            }
            else if (cmbGun.SelectedItem.ToString() == "M1 Garand Single")
            {
                SelectedGun = Guns.M1Grand;
            }
            else if (cmbGun.SelectedItem.ToString() == "ShotGun")
            {
                SelectedGun = Guns.Shotgun;
            }

            if (cmbBird.SelectedItem.ToString() == "Parrot")
            {
                SelectedBird = Birds.Parrot;
            }
            else if (cmbBird.SelectedItem.ToString() == "Stork")
            {
                SelectedBird = Birds.Stork;
            }
            else if (cmbBird.SelectedItem.ToString() == "Crow")
            {
                SelectedBird = Birds.Crow;
            }

            PlayGameForm playGameForm = new PlayGameForm(SelectedGun, SelectedBird);

            this.Hide();
            playGameForm.ShowDialog();
        }
Exemplo n.º 23
0
 public void CheckForExplosions(float x, float y)
 {
     for (int i = 0; i < Birds.Count; i++)
     {
         for (int j = i + 1; j < Birds.Count; j++)
         {
             if (Birds[i].IsHit(x, y))
             {
                 Birds[i].Flag = true;
             }
         }
     }
     for (int i = Birds.Count - 1; i >= 0; i--)
     {
         if (Birds[i].Flag)
         {
             if (Birds[i].bomba == true)
             {
                 sounds[0].Play();
                 points -= 5;
             }
             else
             {
                 Random random = new Random();
                 int    ran    = random.Next(1, 5);
                 sounds[ran].Play();
                 points += 10;
             }
             Birds.RemoveAt(i);
         }
         else
         {
             sounds[7].Play();
         }
     }
 }
Exemplo n.º 24
0
        public IHttpActionResult PutBirds(int id, Birds birds)
        {
            if (id != birds.ID)
            {
                return(BadRequest());
            }

            string        procedure = "";
            int           number;
            string        connectionString = @"Data Source=DESKTOP-RDKB255\SQLEXPRESS;Initial Catalog=articles;Integrated Security=True";
            SqlConnection connection       = new SqlConnection(connectionString);

            try
            {
                string commandStr =
                    $"EXEC BirdsRating @id = '{birds.ID}'," +
                    $" @rating = '{birds.Rating}'";
                connection.Open();
                SqlCommand command = new SqlCommand(commandStr, connection);
                number = command.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                return(BadRequest(ex.Message));
            }
            finally
            {
                connection.Close();
            }
            if (number != null)
            {
                return(Ok());
            }

            return(null);
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            // Birds
            var Kookaburra = new Birds()
            {
                state   = "Queensland",
                Species = Species.Kingfisher
            };

            Kookaburra.Speak();
            Kookaburra.Fly(40);

            var Cockatoo = new Birds()
            {
                state   = "Western Australia",
                Species = Species.Parrot
            };

            Cockatoo.Speak();
            Cockatoo.Fly(100);

            Kookaburra.Fly(15);

            // Pets
            var Tabby = new Pets("Bundaberg", 12, Species.Cat);

            Tabby.Birthday();
            Tabby.Speak();

            var Mutt = new Pets("Murphy", 13, Species.Dog);

            Mutt.Birthday();
            Mutt.Speak();

            // Movies
            var HungerGames = new Movies("Hunger Games", Genre.Distopian);

            HungerGames.Watch();
            HungerGames.Rate(4.5m);

            var WeddingCrashers = new Movies("Wedding Crashers", Genre.Comdey);

            WeddingCrashers.Watch();
            WeddingCrashers.Rate(4m);

            // Books
            var MaryRoach = new Books("Bonk", Genre.Science, 280);

            MaryRoach.Read(25);
            MaryRoach.ChangeStatus();
            MaryRoach.Rate(4.8m);

            var BillBryson = new Books("Down Under", Genre.Biography, 250);

            BillBryson.Read(30);
            BillBryson.ChangeStatus();
            BillBryson.Read(23);
            BillBryson.Rate(4.1m);

            Console.ReadKey();
        }
        private void btnStartGame_Click(object sender, EventArgs e)
        {
            // Khi click vào nút start game
            Guns  SelectedGun  = Guns.Gun00;
            Birds SelectedBird = Birds.Bird01;

            #region Cài đặt súng vào game
            switch (ListGun.SelectedItem.ToString())
            {
            case "Bronze V":
                SelectedGun = Guns.Gun00;
                break;

            case "Bronze IV":
                SelectedGun = Guns.Gun01;
                break;

            case "Bronze III":
                SelectedGun = Guns.Gun02;
                break;

            case "Bronze II":
                SelectedGun = Guns.Gun03;
                break;

            case "Bronze I":
                SelectedGun = Guns.Gun04;
                break;

            case "Silver V":
                SelectedGun = Guns.Gun05;
                break;

            case "Silver IV":
                SelectedGun = Guns.Gun06;
                break;

            case "Silver III":
                SelectedGun = Guns.Gun07;
                break;

            case "Silver II":
                SelectedGun = Guns.Gun08;
                break;

            default:
                break;
            }
            #endregion

            #region Cài đặt chim vào game
            switch (ListBird.SelectedItem.ToString())
            {
            case "Bronze V":
                SelectedBird = Birds.Bird00;
                break;

            case "Bronze IV":
                SelectedBird = Birds.Bird01;
                break;

            case "Bronze III":
                SelectedBird = Birds.Bird02;
                break;

            case "Bronze II":
                SelectedBird = Birds.Bird03;
                break;

            case "Bronze I":
                SelectedBird = Birds.Bird04;
                break;

            case "Silver V":
                SelectedBird = Birds.Dragon00;
                break;

            default:
                break;
            }
            #endregion

            imgBackgroundOnGame playGameForm = new imgBackgroundOnGame(SelectedGun, SelectedBird);
            this.Hide();
            playGameForm.ShowDialog();
        }
Exemplo n.º 27
0
        public void RespawnEvent()
        {
            foreach (Mobile zombie in _ZombiesLoc1.ToList())
            {
                if (zombie != null)
                {
                    zombie.Delete();
                }
                _ZombiesLoc1.Remove(zombie);
            }
            _ZombiesLoc1.Clear();
            _ZombiesLoc1.TrimExcess();

            foreach (Mobile zombie in _ZombiesLoc2.ToList())
            {
                if (zombie != null)
                {
                    zombie.Delete();
                }
                _ZombiesLoc2.Remove(zombie);
            }
            _ZombiesLoc2.Clear();
            _ZombiesLoc2.TrimExcess();

            foreach (Mobile zombie in _ZombiesLoc3.ToList())
            {
                if (zombie != null)
                {
                    zombie.Delete();
                }
                _ZombiesLoc3.Remove(zombie);
            }
            _ZombiesLoc3.Clear();
            _ZombiesLoc3.TrimExcess();

            foreach (Mobile zombie in _ZombiesLoc4.ToList())
            {
                if (zombie != null)
                {
                    zombie.Delete();
                }
                _ZombiesLoc4.Remove(zombie);
            }
            _ZombiesLoc4.Clear();
            _ZombiesLoc4.TrimExcess();

            foreach (Mobile daemon in Daemons.ToList())
            {
                if (daemon != null)
                {
                    daemon.Delete();
                }
                Daemons.Remove(daemon);
            }
            Daemons.Clear();
            Daemons.TrimExcess();

            foreach (Mobile bird in Birds.ToList())
            {
                if (bird != null)
                {
                    bird.Delete();
                }
                Birds.Remove(bird);
            }
            Birds.Clear();
            Birds.TrimExcess();

            foreach (Mobile dk in GoreFiends.ToList())
            {
                if (dk != null)
                {
                    dk.Delete();
                }
                GoreFiends.Remove(dk);
            }
            GoreFiends.Clear();
            GoreFiends.TrimExcess();

            foreach (Mobile fey in FeyWarriors.ToList())
            {
                if (fey != null)
                {
                    fey.Delete();
                }
                FeyWarriors.Remove(fey);
            }
            FeyWarriors.Clear();
            FeyWarriors.TrimExcess();

            foreach (Mobile tentacle in HorrifyingTentacles.ToList())
            {
                if (tentacle != null)
                {
                    tentacle.Delete();
                }
                HorrifyingTentacles.Remove(tentacle);
            }
            HorrifyingTentacles.Clear();
            HorrifyingTentacles.TrimExcess();

            foreach (Mobile tf in TreeFellows.ToList())
            {
                if (tf != null)
                {
                    tf.Delete();
                }
                TreeFellows.Remove(tf);
            }
            TreeFellows.Clear();
            TreeFellows.TrimExcess();

            foreach (Mobile vitriol in Vitriols.ToList())
            {
                if (vitriol != null)
                {
                    vitriol.Delete();
                }
                Vitriols.Remove(vitriol);
            }
            Vitriols.Clear();
            Vitriols.TrimExcess();

            foreach (Mobile spider in ZombieSpiders.ToList())
            {
                if (spider != null)
                {
                    spider.Delete();
                }
                ZombieSpiders.Remove(spider);
            }

            ZombieSpiders.Clear();
            ZombieSpiders.TrimExcess();

            SpawnZombies();
            SpawnDaemons();
            SpawnBirds();
            SpawnFey();
            SpawnSpider();
            SpawnTentacles();
            SpawnTreeFellow();
            SpawnVitriol();
            SpawnGoreFiends();
        }
 private void Start()
 {
     Birds.GetInstance().OnDied += Birds_OnDied;
     Hide();
 }
Exemplo n.º 29
0
 //.............................................................................
 private void Start()
 {
     Birds.GetInstance().OnDied           += Birds_OnDied;
     Birds.GetInstance().OnStartedPlaying += Birds_OnStartedPlaying;
 }
Exemplo n.º 30
0
 public void InitiateBirds(Birds bird)
 {
     _bird = bird;
     _bird.MoveTo(gameObject.transform.position, gameObject);
     Collider.enabled = true;
 }