Ejemplo n.º 1
0
 // Constructor.
 public MazeController(GameController game, int size)
 {
     this.game = game;
     cellsize = 10;
     this.walls = new List<GameObject>();
     this.ground = new Ground(game, size * cellsize, size * cellsize);
     Generate(size, size);
 }
Ejemplo n.º 2
0
 public Ground(Game game, Camera cam)
     : base(game)
 {
     cube = new GameObject(game, "cube", game.Content, cam);
     game.Components.Add(cube);
     translation = rotation = scaling = Matrix.Identity;
     cube.translation = Matrix.CreateTranslation(0, -10, -10);
     cube.scale = Matrix.CreateScale(20);
 }
Ejemplo n.º 3
0
        public Enemy(Game game, Player player, Level level, GameObject body, GameObject fist, Vector3 pos)
            : base(game)
        {
            this.body = body;
            this.fist = fist;

            this.player = player;
            this.level = level;

            damage = 2;
            health = 10;

            fistX = 0;
            fistY = 0;
            fistZ = radius;

            //Attack parameters

            attackCooldown = 1f;  //Time till enemy can attack again

            isAttacking = false;
            canAttack = true;
            enemyYaw = 0;
            fistDefaultAngle = 0.5f;
            angle = fistDefaultAngle;
            speed = (2 * MathHelper.Pi) * 2;

            //Set body GameObject parameters
            setPosition(pos);
            body.setPosition(position);
            body.physobj.coltype = PhysicsObject.ColliderType.enemy;

            //Set fist GameObject parameters
            fist.setScale(0.5f);
            fistPosition = new Vector3(fistX + body.physobj.position.X, fistY + body.physobj.position.Y, fistZ + body.physobj.position.Z);
            fist.setPosition(fistPosition);
            fist.physobj.coltype = PhysicsObject.ColliderType.enemy;
            prevFistPos = fistPosition;
            fist.physobj.isStatic = true;
        }
Ejemplo n.º 4
0
        public Player(Game game, GameObject body, GameObject fist, Vector3 pos, Camera cam)
            : base(game)
        {
            this.body = body;
            this.fist = fist;

            damage = 2;
            health = 10;
            forward = back = left = right = 0;

            fistX = 0;
            fistY = 0;
            fistZ = radius;

            camX = 0;
            camY = 0;
            camZ = radius * 10;
            isAttacking = false;
            canAttack = true;
            fistDefaultAngle = 0.5f;
            angle = fistDefaultAngle;
            speed = (2 * MathHelper.Pi) * 2;

            //Set body GameObject parameters
            setPosition(pos);
            body.physobj.coltype = PhysicsObject.ColliderType.player;

            //Set fist GameObject parameters
            fist.setScale(0.5f);
            new Vector3(fistX + body.physobj.position.X, fistY + body.physobj.position.Y, fistZ + body.physobj.position.Z);
            fist.setPosition(fistPosition);
            fist.physobj.coltype = PhysicsObject.ColliderType.player;
            prevFistPos = fistPosition;
            fist.physobj.isStatic = true;

            camera = cam;
            setCamera();
        }
Ejemplo n.º 5
0
 // Remove a game object.
 public void Remove(GameObject obj)
 {
     if (gameObjects.Contains(obj) && !removedGameObjects.Contains(obj))
     {
         removedGameObjects.Push(obj);
     }
 }
Ejemplo n.º 6
0
 // Add a new game object.
 public void Add(GameObject obj)
 {
     if (!gameObjects.Contains(obj) && !addedGameObjects.Contains(obj))
     {
         addedGameObjects.Push(obj);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// This will create a BasicModel and a PhysicsObject for each in game object.
        /// </summary>
        /// <param name="game"></param>
        /// <param name="pos"></param>
        /// <param name="mdlname"></param>
        /// <param name="texname"></param>
        /// <returns></returns>
        public GameObject createGameObject(Game game, Vector3 pos, string mdlname, string texname)
        {
            BasicModel bmodel = createBasicModel(mdlname, texname);
            PhysicsObject physobj = createPhysicsObject(pos, bmodel.model.Meshes[0].BoundingSphere);
            GameObject gobj = new GameObject(game, pos, bmodel, physobj);
            components.Add(gobj);

            return gobj;
        }