예제 #1
0
 public void Add(Cage cage)
 {
     if (!_cages.Contains(cage))
     {
         _cages.Add(cage);
     }
 }
예제 #2
0
파일: Program.cs 프로젝트: MarcoKoch/Jantu
        static void Main(string[] args)
        {
            Console.WindowWidth  = 100;
            Console.WindowHeight = 60;

            var data    = new DataManager();
            var balance = new Balancing();
            var game    = new Game(Console.WindowWidth - 22, Console.WindowHeight - 3, new Vector2(0, 3), balance, data);
            var menu    = new ActionMenu(new Vector2(Console.WindowWidth - 22, 0), 22, 18);
            var menu2   = new InfoBar(game, new Vector2(0, 0), Console.WindowWidth - 22, 3);
            var menu3   = new CageMenu(new Vector2(Console.WindowWidth - 22, 18), 22, Console.WindowHeight - 18, game);
            var watch   = new Stopwatch();
            var key     = new KeyPressManager(Console.WindowWidth - 20, Console.WindowHeight - 3, game);

            double menuUpdateInterval      = 5;
            double timeSinceLastMenuUpdate = menuUpdateInterval;

            // Test code

            var cageType = CageType.ReadFromFile("../../../data/cages/cross.cage");

            var species = new Species("Cow");

            species.Symbol    = 'c';
            species.PooPeriod = 2;

            var cage = new Cage(cageType, new Vector2(3, 3), game, balance, false);

            game.Cages.SelectedCage = cage;

            var cow1 = new AnimalEntity(species);
            var cow2 = new AnimalEntity(species);

            cow1.Tile = cage.EnclosedTiles[0];
            cow2.Tile = cage.EnclosedTiles[2];

            // End of test code

            watch.Start();

            while (true)
            {
                double dt = 0.001 * (double)watch.ElapsedMilliseconds;
                watch.Restart();

                game.Update(dt);
                ///<summary>
                ///key input handling
                ///</summary>
                //key.KeyInput();

                game.World.Draw();

                timeSinceLastMenuUpdate += dt;
                if (timeSinceLastMenuUpdate >= menuUpdateInterval)
                {
                    menu.Draw();
                    menu2.Draw();
                    menu3.Draw();
                    timeSinceLastMenuUpdate = 0;
                }

                // This is to avoid an 'empty' line at the bottom of the screen
                Console.SetCursorPosition(0, 0);

                if (1.0 / _fps * 0.001 > dt)
                {
                    Thread.Sleep(Math.Max(0, (int)((long)(1.0 / _fps * 1000.0) - watch.ElapsedMilliseconds)));
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="cage">Cage to which the wall belongs</param>
 public CageWallEntity(Cage cage)
 {
     _cage = cage;
 }
예제 #4
0
 public void Remove(Cage cage)
 {
     _cages.Remove(cage);
 }