Пример #1
0
        public CameraSystem(Size gameView, Size gameArea)
        {
            SysType = SystemType.CameraSystem;

            _gameArea = gameArea;

            _width = (int)gameView.Width;
            _height = (int)gameView.Height;

            // StartLocation is center
            Center = new Point(gameArea.Width / 2, gameArea.Height / 2);
            TargetLocation = new Point(gameArea.Width / 2, gameArea.Height / 2);

            // Count zoom so as much as possible is on view in the beginning
            Zoom = (_gameArea.Width / _width > _gameArea.Height / _height ? _gameArea.Height / _height : gameArea.Width / _width);
        }
Пример #2
0
 /// <summary>
 ///  Location is upper left corner. Size is width and height
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public Rectangle(float x, float y, float width, float height)
 {
     Location = new Point(x, y);
     Size = new Size(width, height);
 }
Пример #3
0
 /// <summary>
 ///  Location is upper left corner. Size is width and height
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 public Rectangle(Point location, Size size)
 {
     Location = location;
     Size = size;
 }
Пример #4
0
        public void Initialize(Size gameAreaSize)
        {
            _gameAreaRectangle = new Rectangle(new Point(0, 0), gameAreaSize);
            _quadTree = new QuadTree<GameObject>(new Size(1, 1), _gameAreaRectangle);
            GameObject.QuadTree = _quadTree;

            Size test = _gameAreaRectangle.Size;
            _gameAreaSize = gameAreaSize;

            CharacterGroup b1 = new CharacterGroup();
            CharacterGroup b2 = new CharacterGroup();

            int count1 = 3;

            for (int i = 0; i < count1; i++)
            {
                Character c1 = ObjectFactory.GetKnight(0, BehaviorType.NoAI);
                c1.ID = i;
                c1.Initialize(b1, b2);
                //c1.Location = new Point(100, 100);
                c1.Location = new Point((_gameAreaSize.Width / (count1 + 1)) * (i + 1),  c1.Size.Height * 2 + 100);
                //c1.SetBehavior(BehaviorType.NoAI);
                objects.Add(c1);
                _quadTree.Insert(c1);
            }

            int count = 10 ;

            for (int i = 0; i < count; i++)
            {
                Character c2 = ObjectFactory.GetPeasant(1, BehaviorType.SmartAttack);
                c2.Initialize(b2, b1);
                //c2.Location = new Point(200,100);
                c2.Location = new Point(1000 + (i + 1) * ((_gameAreaSize.Width - 1000) / (count +1)), _gameAreaSize.Height - c2.Size.Height * 2);
                objects.Add(c2);
                //c2.SetBehavior(BehaviorType.SmartAttack);
                _quadTree.Insert(c2);
            }

            GameObject house = ObjectFactory.House();
            house.Location = new Point(400, _gameAreaSize.Height - 400);
            _quadTree.Insert(house);

            GameObject f1 = ObjectFactory.FenceHorizontal();
            f1.Location = new Point(400, _gameAreaSize.Height - 700);
            _quadTree.Insert(f1);

            GameObject f2 = ObjectFactory.FenceVertical();
            f2.Location = new Point(800, _gameAreaSize.Height - 400);
            _quadTree.Insert(f2);

            init(b1, b2);
        }