コード例 #1
0
ファイル: PostItQuote.cs プロジェクト: rroveri/triolozzi
        public PostItQuote(int middlePoint, Vector2 _postItSize, RandomTrack randomTrack, Texture2D _quoteTexture, Random random)
        {
            postItSize = _postItSize;

            float randomOffset = (float)MathHelper.Lerp(-0.90f, 0.90f, (float)random.NextDouble());
            position = randomTrack.curvePointsMiddle[middlePoint] - randomTrack.normals[middlePoint] * randomOffset;
            rotation = (float)MathHelper.Lerp(-MathHelper.Pi / 4f, MathHelper.Pi / 4f, (float)random.NextDouble());

            quoteTexture = _quoteTexture;
            textureScaleVec = new Vector2(postItSize.X / (float)quoteTexture.Width, postItSize.Y / (float)quoteTexture.Height);
        }
コード例 #2
0
ファイル: PostItDream.cs プロジェクト: rroveri/triolozzi
        public PostItDream(int middlePoint, Vector2 _postItSize, int indexNumber, RandomTrack randomTrack, World world, Texture2D _foregroundTexture, int postItIndex, Random random)
        {
            postItSize = _postItSize;

            float randomOffset = (float)MathHelper.Lerp(-0.30f, 0.30f, (float)random.NextDouble());
            position = randomTrack.curvePointsMiddle[middlePoint] - randomTrack.normals[middlePoint] * randomOffset;
            rotation = (float)MathHelper.Lerp(-MathHelper.Pi / 4f, MathHelper.Pi / 4f, (float)random.NextDouble());
            Texture2D textureContour = GameServices.GetService<ContentManager>().Load<Texture2D>("Images/Dreams/postitContourNightmare");

            color = Color.White;

            this.indexNumber = indexNumber;

            if (isNightmare == 0)
            {
                textureContour = GameServices.GetService<ContentManager>().Load<Texture2D>("Images/Dreams/postitContourWish");
                backgroundTexture = GameServices.GetService<ContentManager>().Load<Texture2D>("Images/Dreams/postitwish");
            }
            else if (isNightmare == 1)
            {
                textureContour = GameServices.GetService<ContentManager>().Load<Texture2D>("Images/Dreams/postitContourNightmare");
                backgroundTexture = GameServices.GetService<ContentManager>().Load<Texture2D>("Images/Dreams/postitnightmare");
            }
            else
            {
                backgroundTexture = GameServices.GetService<ContentManager>().Load<Texture2D>("Images/Dreams/postitFree");
            }

            textureContour = _foregroundTexture;

            contourPhysicsObject = new TexturePhysicsObject(world, textureContour, postItSize, Color.White);
            contourPhysicsObject._compound.Position = position;
            contourPhysicsObject._compound.Rotation = rotation;
            contourPhysicsObject._compound.UserData = postItIndex;
            contourPhysicsObject._compound.IsSensor = true;

            foregroundTexture = _foregroundTexture;
            textureScaleVec = new Vector2(postItSize.X / (float)backgroundTexture.Width, postItSize.Y / (float)backgroundTexture.Height);
        }
コード例 #3
0
ファイル: Car.cs プロジェクト: rroveri/triolozzi
        public Car(World world, Texture2D texture, Color Color, RandomTrack _randomTrack, int _index, PlayerIndex _carIndex)
            : base(world, texture, new Vector2(65.0f, 40.0f), Color, new Vector2(130.0f,80.0f))
        {
            vibrationTimer = 0.0f;
            mustVibrate = false;

            carIndex = _carIndex;

            hasNeverStarted = true;

            powerupDurationSpeed = powerupDuration / 2.7f;
            startBlinkingFromSpeed = startBlinkingFrom / 2.7f;
            powerupDurationCurrent = powerupDuration;
            startBlinkingFromCurrent = startBlinkingFrom;

            isInsideMucus=false;

            index = _index;

            message = new PopupMessage(this);

            isActive = true;

            this.randomTrack = _randomTrack;
            projectedPosition = new Vector2();

            mForceVector = new Vector2();
            mDirection = new Vector2();
            mForce = 1.0f;

            mTrailPoints = 0;
            mTrailVertices = new Vertices();
            mTrailPositions = new Vector2[mMaximumTrailPoints];

            mDummyTexture = new Texture2D(GameServices.GetService<GraphicsDevice>(), 1, 1);
            mDummyTexture.SetData(new Color[] { Color.White });
            mColor = Color;

            bullet = new Bullet(world, this,mDummyTexture);
            bulletIsShot = false;

            _compound.LinearDamping = 1;
            _compound.AngularDamping = 1;

            hasBoost = false;
            boostFrames = 0;

            for (int i = 0; i < trailVertices.Count(); i++) trailVertices[i].Color = mColor;

            for (int i = 0; i < burnoutsVertices.Count(); i++) burnoutsVertices[i].Color = Color.Black;

            newWVert = new Vector3(-0.1f);
            newEVert = new Vector3(-0.1f);
            oldWVert = new Vector3(-0.1f);
            oldEVert = new Vector3(-0.1f);

            texNW = new Vector2(0, 0);
            texNE = new Vector2(1, 0);
            texOW = new Vector2(0, 1);
            texOE = new Vector2(1, 1);

            newWVertBurnoutRight = new Vector3(-0.1f);
            newEVertBurnoutRight = new Vector3(-0.1f);
            oldWVertBurnoutRight = new Vector3(-0.1f);
            oldEVertBurnoutRight = new Vector3(-0.1f);

            newWVertBurnoutLeft = new Vector3(-0.1f);
            newEVertBurnoutLeft = new Vector3(-0.1f);
            oldWVertBurnoutLeft = new Vector3(-0.1f);
            oldEVertBurnoutLeft = new Vector3(-0.1f);

            newWVertBurnoutRightFront = new Vector3(-0.1f);
            newEVertBurnoutRightFront = new Vector3(-0.1f);
            oldWVertBurnoutRightFront = new Vector3(-0.1f);
            oldEVertBurnoutRightFront = new Vector3(-0.1f);

            newWVertBurnoutLeftFront = new Vector3(-0.1f);
            newEVertBurnoutLeftFront = new Vector3(-0.1f);
            oldWVertBurnoutLeftFront = new Vector3(-0.1f);
            oldEVertBurnoutLeftFront = new Vector3(-0.1f);

            score = 27;

            driftValue = 0;
            maxBoostFrames = -1;

            currentAcc = acc;
            currentMaxVel = maxVel;

            burnoutCounter = 0;

            freeToSwap = true;

            //register collision
            _compound.OnCollision += body_OnCollision;

            messageImagePos = ConvertUnits.ToDisplayUnits( _compound.Position);// +new Vector2(1, 1));

            painters = new List<Painter>();
            for (int i = 0; i < paintersCount; i++)
            {
                Painter newPainter=new Painter(seed);
                painters.Add(newPainter);
            }

            _graphicsDevice = GameServices.GetService<GraphicsDeviceManager>();
            _camera = GameServices.GetService<Camera>();
            _soundManager = GameServices.GetService<SoundManager>();

            loopBurnout = false;
            updateCounter=0;
            updateOrthogonalVelocityCounter = 0;

            _compound.CollisionCategories = Category.Cat20;

            ContentManager cm = GameServices.GetService<ContentManager>();

            powerupsTextures[0] = null;
            powerupsTextures[1] = cm.Load<Texture2D>("Images/powerups/powerup-ali");
            powerupsTextures[2] = cm.Load<Texture2D>("Images/powerups/powerup-fuoco");
            powerupsTextures[3] = null;
            powerupsTextures[4] = cm.Load<Texture2D>("Images/powerups/powerup-paracadute");
            powerupsTextures[5] = null;
            powerupsTextures[6] = cm.Load<Texture2D>("Images/powerups/powerup-freccia");

            powerupGlowTexture = cm.Load<Texture2D>("Images/powerups/glow");
            gloatingTexture = cm.Load<Texture2D>("Images/powerups/glow");

            screenRenderer = GameServices.GetService<ScreenRenderer>();

            isVisible = true;
        }
コード例 #4
0
ファイル: GameScreen.cs プロジェクト: rroveri/triolozzi
        public override void LoadContent()
        {
            // We add to the GameServices objects that we want to be able to use accross different classes
            // without having to pass them explicitly every time.
            GraphicsDevice = GameServices.GetService<GraphicsDevice>();
            Content = GameServices.GetService<ContentManager>();
            graphics = GameServices.GetService<GraphicsDeviceManager>();
            soundManager = GameServices.GetService<SoundManager>();

            ScreenManager.AddScreen(RankScreen, null, false);
            ScreenManager.AddScreen(PauseScreen, null, false);

            world = new World(new Vector2(0, 0));
            GameServices.AddService<World>(world);

            this.world.ContactManager.PostSolve += new PostSolveDelegate(PostSolve);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Create a new track
            randomRaceTrack = RandomTrack.createTrack();

            randomRaceTrack.polygonList = polygonsList;

            int[] crucialPoints = { 300, 600, 1000 };
            Logic = new GameLogic(crucialPoints, randomRaceTrack.curvePointsMiddle.Count);

            randomRaceTrack.gameLogic = Logic;
            Logic.DidFinishLap += randomRaceTrack.ResetStickyNotes;

            mySneezesManager.randomTrack = randomRaceTrack;

            LoadPaperEffect();

            screenRenderer = new ScreenRenderer();
            GameServices.AddService<ScreenRenderer>(screenRenderer);
            Logic.DidEliminateCar += screenRenderer.setSadToPlayer;
            Logic.DidFinishLap += screenRenderer.setLap;

            for (int i = 0; i < 4; i++)
            {
                Car aCar = new Car(world, Content.Load<Texture2D>("Images/small_car"), Color.White, randomRaceTrack, i, playerIndexes[i]);
                Cars.Add(aCar);
            }

            assetCreator = new AssetCreator(graphics.GraphicsDevice);
            assetCreator.LoadContent(this.Content);

            defaultViewport = GraphicsDevice.Viewport;

            isFullHd=(ScreenManager.preferredHeight!=720);

            // Single screen mode only
            cameraFollowing = new Camera(defaultViewport, Vector2.Zero, new Vector2(defaultViewport.Width / 2, defaultViewport.Height / 2), 0.0f, Cars.Count, isFullHd);
            //ZOOM:

            //low res:
            //0.95 for 2 players
            //0.93 for 3 players
            //0.91 for 4 players

            //high res:
            //0.95 for 4 players

            GameServices.AddService<Camera>(cameraFollowing);

            mySneezesManager.camera = cameraFollowing;

            //generate starting positions and angles
            int startingPoint = 0;
               // positionCars(startingPoint);

            _debugView = new DebugViewXNA(world);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.PerformanceGraph);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Joint);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactNormals);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Controllers);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.CenterOfMass);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.AABB);
            _debugView.DefaultShapeColor = Color.White;
            _debugView.SleepingShapeColor = Color.LightGray;
            _debugView.LoadContent(GraphicsDevice, Content);

            basicVert = new VertexPositionColorTexture[maxNumberOfTriangles];
            for (int i = 0; i < maxNumberOfTriangles; i++) basicVert[i].TextureCoordinate = new Vector2(-1);

            verticesBorders = new VertexPositionColorTexture[randomRaceTrack.curvePointsInternal.Count];

            fluid = new Fluid();
            fluid.Init();

            currentPoses = new Vector2[4];
            prevPoses = new Vector2[4];

            currentMousePos = new Vector2(100);
            prevMousePos = new Vector2(0);

            quad = new QuadRenderComponent(ScreenManager.Game, cameraFollowing, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
            ScreenManager.Game.Components.Add(quad);

            fluidUpdateThread = new Thread(this.UpdateFluid);
            fluidUpdateThread.Start();

            mySneezesManager.fluid = fluid;

            fluidEffect = Content.Load<Effect>("Shaders/FluidEffect");
            fluidEffect.Parameters["random"].SetValue(randomTex);

            texInk = new Texture2D(graphics.GraphicsDevice,
                fluid.m_w, fluid.m_h, true,
                SurfaceFormat.Color);
            buffer = new RenderTarget2D(GraphicsDevice, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height, true,
                SurfaceFormat.Color, GraphicsDevice.PresentationParameters.DepthStencilFormat);

            //gaussian = new GaussianBlur(ScreenManager.Game);
        }
コード例 #5
0
ファイル: RandomTrack.cs プロジェクト: rroveri/triolozzi
 public static RandomTrack createTrack()
 {
     RandomTrack result = new RandomTrack();
     result.buildRandomTrack();
     return result;
 }