예제 #1
0
 public void foldData(Vector3 vec, Vector3 point, float angle, Board b)
 {
     foreach (Player p in players)
     {
             p.foldData(vec, point, angle, b.PointInBeforeFold(p.getCenter()), b.PointInAfterFold(p.getCenter()));
     }
 }
예제 #2
0
 public void foldData(Vector3 vec, Vector3 point, float angle, Board b)
 {
     foreach (Hole h in holes)
     {
         if (b.PointInBeforeFold(h.getCenter()))
             h.foldData(vec, point, angle);
     }
 }
예제 #3
0
 public void foldData(Vector3 vec, Vector3 point, float angle, Board b)
 {
     foreach (PowerUp p in powerups)
     {
         if (b.PointInBeforeFold(p.getCenter()))
             p.foldData(vec, point, angle);
     }
 }
예제 #4
0
 // I changed it so the axis and the point will be relevent to the closest point - Tom
 public void foldData(float angle, Board b)
 {
     foreach (PowerUp p in powerups)
     {
         if (b.PointInBeforeFold(p.getCenter()))
         {
             p.foldData(angle);
         }
     }
 }
예제 #5
0
        // I changed it so the axis and the point will be relevent to the closest point - Tom
        public void foldData(float angle, Board b)
        {
            int i = 0;
            while (i<players.Count())
            {
                if (b.PointInAfterFold(players.ElementAt(i).getCenter()) || b.PointInBeforeFold(players.ElementAt(i).getCenter()))
                    players.ElementAt(i).foldData(angle, b.State);
                i++;

            }
        }
예제 #6
0
 public override void foldData(float a, Board.BoardState state)
 {
     if (!beforFold) return;
     if ((a > -MathHelper.Pi + Game1.closeRate) && (moving))
     {
         worldMatrix = Matrix.Identity;
         worldMatrix *= Matrix.CreateTranslation(-point);
         worldMatrix *= Matrix.CreateFromAxisAngle(axis, a);
         worldMatrix *= Matrix.CreateTranslation(point);
     }
 }
예제 #7
0
 // XXX need to recieve all the instances: bordMan, playerMan, holeMan etc.
 public GameManager(SpriteFont f, SpriteFont sf, HoleManager h, PlayerManager p, PowerUpManager pu,
     Board bo)
 {
     font = f;
     scoreFont = sf;
     holeManager = h;
     playerManager = p;
     powerupManager = pu;
     board = bo;
     gamestate = GameState.normal;
     folds = 0;
     level = 1;
     endLevel = 1;
 }
예제 #8
0
        public override void foldData(float a,Board.BoardState state)
        {
            if (beforFold)
            {
                if (state == Board.BoardState.folding1) {
                    if ((a > -MathHelper.Pi + Game1.closeRate) && (moving))
                    {
                        worldMatrix = Matrix.Identity;
                        worldMatrix *= Matrix.CreateTranslation(-point);
                        worldMatrix *= Matrix.CreateFromAxisAngle(axis, a);
                        worldMatrix *= Matrix.CreateTranslation(point);
                    }
                } else
                if ((state == Board.BoardState.folding2) && !(stuckOnPaper))
                {
                    float oldy;
                    stuckOnPaper = true;
                    switchPoints();
                    worldMatrix = Matrix.Identity;
                    worldMatrix *= Matrix.CreateTranslation(-point);
                    worldMatrix *= Matrix.CreateFromAxisAngle(axis, -MathHelper.Pi);
                    worldMatrix *= Matrix.CreateTranslation(point);
                    for (int i = 0; i < vertices.Length; i++)
                    {
                        oldy = vertices[i].Position.Y;
                        vertices[i].Position = Vector3.Transform(vertices[i].Position, worldMatrix);
                        vertices[i].Position.Y = oldy;
                    }
                    calcCenter();
                    worldMatrix = Matrix.Identity;
                    checkCollision = 1;
                }
            } else if (afterFold && (state == Board.BoardState.folding2))
            {

                worldMatrix = Matrix.Identity;
                worldMatrix *= Matrix.CreateTranslation(-getCenter());
                worldMatrix *= Matrix.CreateRotationZ(MathHelper.Pi);
                worldMatrix *= Matrix.CreateTranslation(getCenter());
                worldMatrix *= Matrix.CreateTranslation(-point);
                worldMatrix *= Matrix.CreateFromAxisAngle(axis,a - MathHelper.Pi);
                worldMatrix *= Matrix.CreateTranslation(point);
                checkCollision = -1;
            }
        }
예제 #9
0
        public GameManager(SpriteFont f, SpriteFont sf, HoleManager h, AcidManager a, PlayerManager p, PowerUpManager pu,
            Board bo,Table tab, Texture2D st, Texture2D help, Texture2D ls)
        {
            font = f;
            scoreFont = sf;
            holeManager = h;
            acidManager = a;
            playerManager = p;
            powerupManager = pu;
            board = bo;
            table = tab;
            gamestate = GameState.normal;
            folds = 0;
            level = 0;

            startScreen = st;
            helpScreen = help;
            levelScreen = ls;
            for (int i = 0; i <= endLevel; i++)
            {
            levelsPics.Add(Game1.content.Load<Texture2D>("level" + i));
            levelsPicsBtn.Add(new Rectangle(300 + ((levelsPics.ElementAt(i).Width+30) * ((i<3)? i : i-3)), (i < 3) ? 220 : 400, levelsPics.ElementAt(i).Width, levelsPics.ElementAt(i ).Height));
            }
        }
예제 #10
0
 //public virtual void foldData(Vector3 axis, Vector3 point, float a,bool beforeFold,bool afterFold) { }
 public virtual void foldData(float a,Board.BoardState state)
 {
 }
예제 #11
0
 public void preFoldData(Vector3 foldp1, Vector3 foldp2, Vector3 axis, Board b)
 {
     Matrix checkMatrix;
     Vector3 check;
     float rotantionAngle;
     foreach (Player p in players)
     {
         if (b.PointInBeforeFold(p.getCenter()))
         {
             rotantionAngle = MathHelper.PiOver2;
             checkMatrix = Matrix.Identity;
             checkMatrix *= Matrix.CreateFromAxisAngle(axis, rotantionAngle);
             check = Vector3.Transform(p.getCenter(), checkMatrix); // where the point will be after rotation
             if (check.Y > 0.0f) // if it is in the right deriction
                 p.preFoldData(axis, (foldp1 + foldp2) / 2, true, false);
             else // not in the right deriction
                 p.preFoldData(-axis, (foldp1 + foldp2) / 2, true, false);
         }
         else if (b.PointInAfterFold(p.getCenter()))
         {
             rotantionAngle = -1.5f * MathHelper.PiOver2;
             checkMatrix = Matrix.Identity;
             checkMatrix *= Matrix.CreateTranslation(-p.getCenter());
             checkMatrix *= Matrix.CreateRotationZ(MathHelper.Pi);
             checkMatrix *= Matrix.CreateTranslation(p.getCenter());
             checkMatrix *= Matrix.CreateTranslation(-(foldp1 + foldp2) / 2);
             checkMatrix *= Matrix.CreateFromAxisAngle(axis, rotantionAngle);
             checkMatrix *= Matrix.CreateTranslation((foldp1 + foldp2) / 2);
             check = Vector3.Transform(p.getCenter(), checkMatrix); // where the point will be after rotation
             if (check.Y > 0.0f) // if it is in the right deriction
                 p.preFoldData(axis, (foldp1 + foldp2) / 2, false, true);
             else // not in the right deriction
                 p.preFoldData(-axis, (foldp1 + foldp2) / 2, false, true);
         }
     }
 }
예제 #12
0
        public override void foldData(float a, Board.BoardState state)
        {
            if (beforFold)
            {
                if (state == Board.BoardState.folding1 || stuckOnPaper)
                {
                    if ((a > -MathHelper.Pi + Game1.closeRate) && (moving))
                    {
                        worldMatrix = Matrix.Identity;
                        worldMatrix *= Matrix.CreateTranslation(-point);
                        worldMatrix *= Matrix.CreateFromAxisAngle(axis, a);
                        worldMatrix *= Matrix.CreateTranslation(point);
                    }
                }
                else
                    if ((state == Board.BoardState.folding2) && !(stuckOnPaper))
                    {
                      //  float oldy;
                        stuckOnPaper = true;
                        //switchPoints();
                        worldMatrix = Matrix.Identity;
                        worldMatrix *= Matrix.CreateTranslation(-point);
                        worldMatrix *= Matrix.CreateFromAxisAngle(axis, -MathHelper.Pi);
                        worldMatrix *= Matrix.CreateTranslation(point);
                     /*   for (int i = 0; i < vertices.Length; i++)
                        {
                            oldy = vertices[i].Position.Y;
                            vertices[i].Position = Vector3.Transform(vertices[i].Position, worldMatrix);
                            vertices[i].Position.Y = oldy;
                        }
                        calcCenter();
                        worldMatrix = Matrix.Identity;
                    //    playerManager.makeNewPlayer("normal", center);
                     //  playerManager.changePlayerType(this, "normal", center);*/
                       checkCollision = 1;

                        Vector3 temp = vertices[1].Position;
                        temp = Vector3.Transform(temp, worldMatrix);
                        playerManager.makeNewPlayer("normal", new Vector2(temp.X,temp.Z),true);
                    }
            }
            else if (afterFold && (state == Board.BoardState.folding2))
            {

                worldMatrix = Matrix.Identity;
                worldMatrix *= Matrix.CreateTranslation(-getCenter());
                worldMatrix *= Matrix.CreateRotationZ(MathHelper.Pi);
                worldMatrix *= Matrix.CreateTranslation(getCenter());
                worldMatrix *= Matrix.CreateTranslation(-point);
                worldMatrix *= Matrix.CreateFromAxisAngle(axis, a - MathHelper.Pi);
                worldMatrix *= Matrix.CreateTranslation(point);
                checkCollision = -1;
                if (!stuckOnPaper)
                {
                    stuckOnPaper = true;
                    Vector3 temp = vertices[1].Position;
                    temp = Vector3.Transform(temp, worldMatrix);
                    playerManager.makeNewPlayer("normal", new Vector2(temp.X, temp.Z),true);
                }
            }
        }
예제 #13
0
 public void Divide(DividingVert first, DividingVert second, out Board partOne, out Board partTwo)
 {
     //
     /* ADD TEST TO FIND IF NOT ON THE SAME EDGE*/
     //
     Board part1 = new Board(texture,effect);
     Board part2 = new Board(texture, effect);
     int p1_pNum, p2_pNum;
     p1_pNum = Math.Abs(first.big - second.small) + 3;
     if ((first.big == vertNum - 1) && (second.small == 0))
         p1_pNum -= 2;
     p2_pNum = indices.Length - p1_pNum + 2;
     Vector3[] p1_points = new Vector3[p1_pNum];
     Vector2[] p1_texCords = new Vector2[p1_pNum];
     p1_points[0] = first.position;
     p1_texCords[0] = findTexCords(first);
     p1_points[p1_pNum - 1] = second.position;
     p1_texCords[p1_pNum - 1] = findTexCords(second);
     for (int i = 0; i < p1_pNum - 2; i++)
     {
         p1_points[i + 1] = vertices[(first.big + i) % vertNum].Position;
         p1_texCords[i + 1] = vertices[(first.big + i) % vertNum].TextureCoordinate;
     }
     Vector3[] p2_points = new Vector3[p2_pNum];
     Vector2[] p2_texCords = new Vector2[p2_pNum];
     p2_points[0] = second.position;
     p2_texCords[0] = p1_texCords[p1_pNum - 1]; //alreadt calculated before a moment
     p2_points[p2_pNum - 1] = first.position;
     p2_texCords[p2_pNum - 1] = p1_texCords[0]; //alreadt calculated before a moment
     for (int i = 0; i < p2_pNum - 2; i++)
     {
         p2_points[i + 1] = vertices[(second.big + i) % vertNum].Position;
         p2_texCords[i + 1] = vertices[(second.big + i) % vertNum].TextureCoordinate;
     }
     part1.Initialize(p1_pNum, p1_points, p1_texCords);
     part2.Initialize(p2_pNum, p2_points, p2_texCords);
     // storing the smaller part in parOne , bigger -> partTwo
     if (Vector3.Distance(center,part1.center) >= Vector3.Distance(center,part2.center))
     {
         partOne = part1;
         partTwo = part2;
     } else
     {
         partOne = part2;
         partTwo = part1;
     }
 }
예제 #14
0
 public void preFoldData(Vector3 foldp1, Vector3 foldp2, Vector3 axis, Board b)
 {
     Matrix checkMatrix;
     Vector3 check;
     foreach (Hole h in holes)
     {
         if (b.PointInBeforeFold(h.getCenter()))
         {
             checkMatrix = Matrix.Identity;
             checkMatrix *= Matrix.CreateFromAxisAngle(axis, MathHelper.ToRadians(90));
             check = Vector3.Transform(h.getCenter(), checkMatrix); // where the point will be after rotation
             if (check.Y > 0.0f) // if it is in the right deriction
                 h.preFoldData(axis, (foldp1 + foldp2) / 2);
             else // not in the right deriction
                 h.preFoldData(-axis, (foldp1 + foldp2) / 2);
         }
     }
 }
예제 #15
0
 // I changed it so the axis and the point will be relevent to the closest point - Tom
 public void foldData(float angle, Board b)
 {
     foreach (Hole h in holes)
     {
         if (b.PointInBeforeFold(h.getCenter()))
         {
             h.foldData(angle);
         }
     }
 }
예제 #16
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     device = graphics.GraphicsDevice;
     // Create a new SpriteBatch, which can be used to draw textures.
     spriteBatch = new SpriteBatch(GraphicsDevice);
     SpriteFont font = Content.Load<SpriteFont>(@"font");
     SpriteFont scoreFont = Content.Load<SpriteFont>("scoreFont");
     HoleManager holeManager = new HoleManager(Content.Load<Texture2D>("hole2"), Content.Load<Effect>("effects"));
     AcidManager acidManager = new AcidManager(Content.Load<Texture2D>("acid"), Content.Load<Effect>("effects"));
     PlayerManager playerManager = new PlayerManager(Content.Load<Texture2D>("gum"), Content.Load<Effect>("effects"), Content.Load<Texture2D>("dupGum"), Content.Load<Texture2D>("staticGum"));
     PowerUpManager powerupManager = new PowerUpManager(Content.Load<Texture2D>("inkspot"), Content.Load<Effect>("effects"));
     Board board = new Board(Content.Load<Texture2D>("paper"), Content.Load<Effect>("effects"));
     Table table = new Table(Content.Load<Model>("Table"));
     camera = new Camera(this);
     input = new InputHandler(this);
     ourGame = new GameManager(font, scoreFont, holeManager, acidManager, playerManager, powerupManager, board,table, Content.Load<Texture2D>("startScreen"), Content.Load<Texture2D>("help"), Content.Load<Texture2D>("levelsScreen"));
     ourGame.loadCurrLevel();
 }
예제 #17
0
파일: Game1.cs 프로젝트: tsela85/Foldit3D
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     device = graphics.GraphicsDevice;
     // Create a new SpriteBatch, which can be used to draw textures.
     spriteBatch = new SpriteBatch(GraphicsDevice);
     SpriteFont font = Content.Load<SpriteFont>("font");
     SpriteFont scoreFont = Content.Load<SpriteFont>("scoreFont");
     HoleManager holeManager = new HoleManager(Content.Load<Texture2D>("hole2"), Content.Load<Effect>("effects"));
     PlayerManager playerManager = new PlayerManager(Content.Load<Texture2D>("gummy2"), Content.Load<Effect>("effects"));
     PowerUpManager powerupManager = new PowerUpManager(Content.Load<Texture2D>("inkspot"), Content.Load<Effect>("effects"));
     Board board = new Board(Content.Load<Texture2D>("paper"), Content.Load<Effect>("effects"));
     camera = new Camera(this);
     input = new InputHandler(this);
     ourGame = new GameManager(font, scoreFont, holeManager, playerManager, powerupManager,board);
     ourGame.loadCurrLevel();
 }
예제 #18
0
 // I changed it so the axis and the point will be relevent to the closest point - Tom
 public void foldData(float angle, Board b)
 {
     foreach (Acid a in acids)
     {
         if (b.PointInBeforeFold(a.getCenter()))
         {
             a.foldData(angle);
         }
     }
 }