Example #1
0
        public Player(Vector3 pos, QuakeCamera camera)
        {
            size = new Vector3(1, 1, 1);
            Matrix orientation = Matrix.Identity;

            physicsObject = new PlayerPhysicsObject(size, orientation, pos);

            controller = new PlayerController(this, camera);
        }
Example #2
0
        /// <summary>
        /// Get a new random map.
        /// </summary>
        private void GenerateNewMap()
        {
            //If in demo mode, score is reset to 0 (this will either be when the game is loaded or when the player
            //quits to the main menu

            if (Stage.GameState.DemoMode)
                Score = 0;
            else
            {
                //Update score
                Score += Level * ScorePerLevel;
                if (TimeOnLevel < 200)
                    Score += Level * (200 - TimeOnLevel);
            }

            int dimention = 12;
            int wallstobreak = 24;

            //clear breadcrumbs
            LastVisitedSquare = Point.Zero;
            VisitedGridSquares = new List<Point>();

            //Randomise Stage Manager's map.
            Stage.GenerateNewRandomSquareMap(dimention, wallstobreak);

            // NEW COLLISION/LOS MODEL DATA
            Stage.Map.CalculateWallCollision();

            // Get collision grid data and load into camera class.
            bool[] bg = new bool[Stage.Map.Width * Stage.Map.Height];

            for (int y = 0; y < Stage.Map.Height; y++)
            {
                for (int x = 0; x < Stage.Map.Width; x++)
                {
                    if (Stage.Map.GetSquareAt(x, y).type == MapSquareType.Closed)
                        bg[x + (y * Stage.Map.Width)] = true;
                    else
                        bg[x + (y * Stage.Map.Width)] = false;
                }
            }

            //Get starting location.
            List<Vector2> exclusion = new List<Vector2>();
            int playerquater = Helpers.RandomInt(1, 4);
            Vector2 StartingLocation = Stage.Map.GetRandomSquareCoordsByType(MapSquareType.Open, null, exclusion, playerquater);

            //Get Monster Starting Location.
            int monsterquater = playerquater;
            while (monsterquater == playerquater)
                monsterquater = Helpers.RandomInt(1, 4);
            exclusion.Add(StartingLocation);
            Vector2 MonsterStartingLocation = Stage.Map.GetRandomSquareCoordsByType(MapSquareType.Open, null, exclusion, monsterquater);

            //Get teleporter starting location.
            int teleporterquater = playerquater;
            while (teleporterquater == playerquater || teleporterquater == monsterquater)
                teleporterquater = Helpers.RandomInt(1, 4);
            //exclusion.Add(MonsterStartingLocation); // Makes it too easy
            Vector2 TeleporterStartingLocation = Stage.Map.GetRandomSquareCoordsByType(MapSquareType.Open, null, exclusion, teleporterquater);

            //Init camera/Player
            fpsCam = new QuakeCamera(GraphicsDevice.Viewport, new Vector3(StartingLocation.X*16 +4,10.0f,StartingLocation.Y*16+4), 0, 0);
            fpsCam.SetFacingDegrees(0);

            //Init Teleporter
            TeleporterGridLocation = TeleporterStartingLocation;
            TeleporterLocation = new Vector3(TeleporterStartingLocation.X * 16, 10.0f, TeleporterStartingLocation.Y * 16);
            TeleporterRenderLocation = new Vector3(TeleporterStartingLocation.X * 16, -10.0f, TeleporterStartingLocation.Y * 16);

            fpsCam.CollisionGrid = bg;
            fpsCam.GridHeight = Stage.Map.Height;
            fpsCam.GridWidth = Stage.Map.Width;
            fpsCam.SquareWidth = 8;
            fpsCam.SquareHeight = 8;

            //Init Monster
            Stage.ClearEntities(true, true);
            monster = new Actor();

            monster.CollisionGrid = bg;
            monster.GridWidth = Stage.Map.Width;
            monster.GridHeight = Stage.Map.Height;
            monster.SetFacingDegrees(-90);
            monster.SetLocation(MonsterStartingLocation.X*16+4, 10, MonsterStartingLocation.Y*16 +4);
            monster.FacingOffset = MathHelper.ToRadians(270);
            monster.FOV = 355.0f;
            monster.UpdateWorldMatrix();
            monster.Behaviours = FLAG_Behaviours.AGGRESSIVE | FLAG_Behaviours.MONSTER | FLAG_Behaviours.EVIL_GENIUS;
            monster.ScalingFactor = 1.0f;
            monster.FightRange = 2.0f;
            monster.HearingRadius = 640.0f;
            monster.SightRadius = 640.0f;
            monster.InstanceName = "Rex";
            monster.movespeed = 0.28f + MonsterSpeedupFactor*Level;
            //Set model
            monster.DefaultModel = monsterModel;
            //Set material
            Material monsterMaterial = new Material(Content, GraphicsDevice, baseEffect);
            monsterMaterial.SetTexturedMaterial(Color.White, Stage.ConfigurationSettings.WallSpecularPower, Stage.ConfigurationSettings.WallSpecularIntensity, "eyestex", "eyestex", 20f, 20f);
            monsterMaterial.Scaled = true;
            monster.DefaultMaterials.Add("default", monsterMaterial);
            //Load the monster into the Stage manager and bring him onstage.
            Stage.LoadActor(monster);
            Stage.BringActorOnStage("Rex");

            //Init Demo Zombie -- In demo mode the demo zombie patrolls a list of random waypoints and the player follows it.
            //The demo zombie is invisible.
            if (Stage.GameState.DemoMode)
            {
                demoZombie = new Actor();

                demoZombie.CollisionGrid = bg;
                demoZombie.GridWidth = Stage.Map.Width;
                demoZombie.GridHeight = Stage.Map.Height;
                demoZombie.SetFacingDegrees(-90);
                demoZombie.SetLocation(StartingLocation.X * 16 + 4, 10, StartingLocation.Y * 16 + 4);
                demoZombie.FacingOffset = MathHelper.ToRadians(270);
                demoZombie.FOV = 355.0f;
                demoZombie.UpdateWorldMatrix();
                demoZombie.Behaviours = FLAG_Behaviours.PATROLLER | FLAG_Behaviours.MONSTER;
                demoZombie.ScalingFactor = 0.0f;
                demoZombie.FightRange = 0.0f;
                demoZombie.HearingRadius = 0.0f;
                demoZombie.SightRadius = 0.0f;
                demoZombie.InstanceName = "Zombie";
                demoZombie.movespeed = 0.56f;

                //Set up the zombie's waypoints.
                //Set up patrol list.
                Vector2 lastLocation = Stage.Map.GetRandomSquareCoordsByType(MapSquareType.Open, null, null, 0);
                Vector2 nextLocation = lastLocation;

                Stage.Graph.SearchAStarPath(StartingLocation, nextLocation);
                demoZombie.SimplePatrolList = Stage.Graph.GetPathList();
                //The last node of this list will always be the same as the first node of the next list. This affects the direction in which the actor[0] looks
                //so.
                for (int zombiepaths = 0; zombiepaths < 10; zombiepaths++)
                {
                    demoZombie.SimplePatrolList.RemoveAt(demoZombie.SimplePatrolList.Count - 1);
                    nextLocation = Stage.Map.GetRandomSquareCoordsByType(MapSquareType.Open, null, null, 0);
                    Stage.Graph.SearchAStarPath(lastLocation, nextLocation);
                    demoZombie.SimplePatrolList.AddRange(Stage.Graph.GetPathList());
                    lastLocation = nextLocation;
                }

                demoZombie.SimplePatrolList.RemoveAt(demoZombie.SimplePatrolList.Count - 1);
                nextLocation = StartingLocation;
                Stage.Graph.SearchAStarPath(lastLocation, nextLocation);
                demoZombie.SimplePatrolList.AddRange(Stage.Graph.GetPathList());

                //Set model
                demoZombie.DefaultModel = monsterModel;
                //Set material
                Material zombieMaterial = new Material(Content, GraphicsDevice, baseEffect);
                zombieMaterial.SetTexturedMaterial(Color.White, Stage.ConfigurationSettings.WallSpecularPower, Stage.ConfigurationSettings.WallSpecularIntensity, "banner", "banner", 1f, 1f);
                zombieMaterial.Scaled = true;
                demoZombie.DefaultMaterials.Add("default", monsterMaterial);
                //Load the monster into the Stage manager and bring him onstage.
                Stage.LoadActor(demoZombie);
                Stage.BringActorOnStage("Zombie");

            }

            //Update level
            Level++;
            TimeInGame += TimeOnLevel;
            TimeOnLevel = -1;

            if (Stage.GameState.DemoMode)
                Level = 0;
        }
Example #3
0
 public PlayerController(Player player, QuakeCamera camera)
 {
     this.camera = camera;
     this.player = player;
     body        = player.PhysicsObject.PhysicsBody;
 }