Пример #1
0
        public Agent(GameManager gameManager, Game game, Camera camera, int team)
        {
            _player = new Player(gameManager, game, camera, team, true);
            _game = game;
            _camera = camera;
            _fovRotation = 0;
            float x, y, z;
            x = (float)Math.Cos(_fovRotation) * _viewDistance;
            z = (float)Math.Sin(_fovRotation) * _viewDistance;
            y = _player.getPositionVector().Y;
            view = Matrix.CreateLookAt(_player.getPositionVector(), new Vector3(x, y, z), Vector3.Up);

            _farPlane = _viewDistance;

            projection = Matrix.CreatePerspectiveFieldOfView(
                MathHelper.PiOver4,
                (float)game.Window.ClientBounds.Width /
                (float)game.Window.ClientBounds.Height,
                1, _farPlane);

            _fov = new BoundingFrustum(view * projection);

            DebugManager dm = (DebugManager)gameManager.getGameEntity("debugManager");
            dm.registerDebugEntities(this);

            _court = (Court)gameManager.getGameEntity("court");
            _disk = (Disk)gameManager.getGameEntity("disk");

            _boundingSphere = new BoundingSphere(_player.getPositionVector(), 3f);

            _randomGenerator = new Random();
            _direction = Vector2.Zero;
            _direction.Y = -1;

            _player.Initialize();
            _player.LoadContent();

            _team = team;
            _hasShoot = false;

            _lastPositionWithDisk = Vector3.Zero;
        }
Пример #2
0
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            position = Matrix.Identity;

            Vector3 positionVector = Vector3.Zero;
            positionVector.Y = 0.7f;
            simulationState.Position = positionVector;
            simulationState.LastPositionVector = positionVector;

            simulationState.Velocity = Vector2.Zero;
            _maxVelocity = 12;

            simulationState.Rotation = 0;

            previousState = simulationState;
            displayState = simulationState;

            Matrix pos = Matrix.CreateTranslation(0, 0.7f, 0);
            _scale = Matrix.CreateScale(1.5f);
            world = world * _scale * pos;

            arrowKeysPressed = new List<Boolean>();
            for (int i = 0; i < 4; i++)
                arrowKeysPressed.Add(false);
            lastArrowKeysPressed = new List<Keys>();

            //lastPosition = new Vector3(0, 2, 0);
            stick = new BoundingSphere(new Vector3(2, 1f, 0), 0.5f);
            upBody = new BoundingSphere(new Vector3(0, 4.5f, 0), 1.2f);
            downBody = new BoundingSphere(new Vector3(0, 1.05f, -0.03f), 0.05f);

            CollisionManager cm = (CollisionManager)_gameManager.getGameEntity("collisionManager");
            DebugManager dm = (DebugManager)_gameManager.getGameEntity("debugManager");
            Ice ice = (Ice)_gameManager.getGameEntity("ice");
            ice.register(this);
            cm.register(this);
            dm.registerDebugEntities(this);

            MultiplayerManager mm = (MultiplayerManager)_gameManager.getGameEntity("multiplayerManager");
            if (mm != null)
                _disk = mm.getDisk();
            else
                _disk = (Disk)_gameManager.getGameEntity("disk");
            _arrowManager = (ArrowManager)_gameManager.getGameEntity("arrowManager");

            _deactivateKeyboard = false;

            _lastBouncePosition = Vector3.Zero;
            _keyDeactivated[(int)KeyboardKey.UP] = false;
            _keyDeactivated[(int)KeyboardKey.DOWN] = false;
            _keyDeactivated[(int)KeyboardKey.LEFT] = false;
            _keyDeactivated[(int)KeyboardKey.RIGHT] = false;

            base.Initialize();
        }
Пример #3
0
 public void Initialize()
 {
     //_playersInGame = new Dictionary<NetworkGamer, Player>();
     _packetReader = new PacketReader();
     _packetWriter = new PacketWriter();
     _lastPositionInput = Vector2.Zero;
     _rotationInput = Vector4.Zero;
     _priority = 0;
     _disk = new Disk(_gameManager, _game, _camera, false);
     _disk.Initialize();
 }