コード例 #1
0
ファイル: Lobby.cs プロジェクト: Richie78321/fighter-game
        public Lobby(Client hostClient, List <Lobby> lobbyCollection, Client.Print printMethod, Random serverRandom)
        {
            //Set vars
            this.hostClient      = hostClient;
            this.lobbyCollection = lobbyCollection;
            this.PrintMethod     = printMethod;
            lobbySeed            = serverRandom.Next();
            ColliderReferenceMap = new CollisionReferenceMap <Collider>(MapStandards.REFERENCE_MAP_RESOLUTION, MapStandards.REFERENCE_MAP_RESOLUTION, MapStandards.MAP_SIZE, MapStandards.MAP_SIZE);

            //Add host to clients
            clients.Add(hostClient);
        }
コード例 #2
0
        public GameMap(Random random, GraphicsDevice graphicsDevice, GameSession gameSession)
        {
            this.gameSession = gameSession;
            mapArchitecture  = MapArchitectures[random.Next(0, MapArchitectures.Length)];

            texturePack          = MapTexturePacks[random.Next(0, MapTexturePacks.Length)].Deploy();
            ReferenceMap         = new CollisionReferenceMap <RigidBody>(MapStandards.REFERENCE_MAP_RESOLUTION, MapStandards.REFERENCE_MAP_RESOLUTION, MapStandards.MAP_SIZE, MapStandards.MAP_SIZE);
            ParticleReferenceMap = new CollisionReferenceMap <RigidBody>(MapStandards.REFERENCE_MAP_RESOLUTION, MapStandards.REFERENCE_MAP_RESOLUTION, MapStandards.MAP_SIZE, MapStandards.MAP_SIZE);
            NoCollideMap         = new CollisionReferenceMap <RigidBody>(1, 1, MapStandards.MAP_SIZE, MapStandards.MAP_SIZE);

            parallaxBackground = new ParallaxBackground(texturePack.BackgroundImages);

            camera = new Camera(this, graphicsDevice);

            AddArchitectureCollision();
        }
コード例 #3
0
 //Object
 public StandardWalker(PlayerTexturePack playerTexturePack, float strafeAcceleration, float maxStrafeVelocity, float jumpVelocity, float dodgeVelocity, float mass, CollisionReferenceMap <RigidBody> referenceMap, GameTime gameTime, Vector2 drawDimensions, PlayerStandards.PlayerType PlayerType, GameMap gameMap, bool mobile = true) : base(playerTexturePack, CreateRigidBody(playerTexturePack.LoopSheets[0].textures[0], mass, referenceMap, drawDimensions, gameMap), gameTime, drawDimensions, PlayerType, gameMap)
 {
     this.Mobile             = mobile;
     this.strafeAcceleration = strafeAcceleration;
     this.maxStrafeVelocity  = maxStrafeVelocity;
     this.jumpVelocity       = jumpVelocity;
     this.dodgeVelocity      = dodgeVelocity;
     movementFriction        = this.strafeAcceleration;
     dodgeTime = playerTexturePack.EventSheets[(int)EventState.DodgeRoll][0].FrameTime * playerTexturePack.EventSheets[(int)EventState.DodgeRoll][0].spriteSheet.textures.Length;
     lastDodge = -dodgeTime;
 }
コード例 #4
0
        public static RigidBody CreateRigidBody(Texture2D boundaryTexture, float mass, CollisionReferenceMap <RigidBody> referenceMap, Vector2 drawDimensions, GameMap gameMap, bool noCollide = false)
        {
            int spriteHighest   = SpriteHighestPixel(boundaryTexture);
            int spriteLowest    = SpriteLowestPixel(boundaryTexture);
            int spriteLeftmost  = SpriteLeftmostPixel(boundaryTexture);
            int spriteRightmost = SpriteRightmostPixel(boundaryTexture);

            Vector2  colliderSize    = new Vector2((spriteRightmost - spriteLeftmost + 2) * (drawDimensions.X / boundaryTexture.Height), (spriteLowest - spriteHighest + 2) * (drawDimensions.Y / boundaryTexture.Height));
            Platform spawnPlatform   = gameMap.MapArchitecture.MapPlatforms[gameMap.gameSession.LocalRandom.Next(0, gameMap.MapArchitecture.MapPlatforms.Length)];
            int      spawnTile       = gameMap.gameSession.LocalRandom.Next(0, spawnPlatform.TileLength);
            Vector2  initialPosition = new Vector2(spawnPlatform.Position.X + (MapStandards.TILE_SIZE * (spawnTile + .5F)) - (colliderSize.X / 2), spawnPlatform.Position.Y - colliderSize.Y);

            //Create polygon
            RotationRectangle rotRec = new RotationRectangle(new RectangleF(initialPosition.X, initialPosition.Y, colliderSize.X, colliderSize.Y));

            RigidBody.VelocityRestriction[] velocityRestrictions = new RigidBody.VelocityRestriction[Enum.GetNames(typeof(RigidBody.VelocityRestriction)).Length];
            for (int i = 0; i < velocityRestrictions.Length; i++)
            {
                velocityRestrictions[i] = (RigidBody.VelocityRestriction)i;
            }
            return(new RigidBody(rotRec, mass, referenceMap, velocityRestrictions, staticBody: true, rotationOnForce: false));
        }
コード例 #5
0
        public StandardAttacker(PlayerTexturePack playerTexturePack, float strafeAcceleration, float maxStrafeVelocity, float jumpVelocity, float dodgeVelocity, AttackSpecification[] attackSpecifications, float mass, CollisionReferenceMap <RigidBody> referenceMap, GameTime gameTime, Vector2 drawDimensions, PlayerStandards.PlayerType PlayerType, GameMap gameMap, bool mobile = true) : base(playerTexturePack, strafeAcceleration, maxStrafeVelocity, jumpVelocity, dodgeVelocity, mass, referenceMap, gameTime, drawDimensions, PlayerType, gameMap, mobile)
        {
            if (attackSpecifications.Length == Enum.GetNames(typeof(AttackEvent)).Length)
            {
                this.attackSpecifications = attackSpecifications;
            }
            else
            {
                throw new Exception("Incorrect lunge speed data.");
            }

            BakeAttackColliders(playerTexturePack);
        }