public void copyOrientation(ATetrimino o) { orientation = o.orientation; orientations[orientation].Invoke(); foreach (Block b in shape) b.setOrientation(orientation); }
public Block(SpriteManager.ESprite color, ATetrimino cont, float transpar = 1f) : base(App.Game) { this.color = color; container = cont; hitBox = Rectangle.Empty; this.transparency = transpar; }
public GameSession(CoordHelper.EProfile pt, HUD h) : base(App.Game) { hud = h; playerType = pt; board = new Board(playerType, new Vector2(Constants.Measures.boardBlockWidth, Constants.Measures.boardBlockHeight)); climby = new Climby(playerType); // aroundRect = new Dictionary<Climby.EAroundSquare, Point>(); #region Set Around Rect aroundRect.Add(Climby.EAroundSquare.FRONT, Point.Zero); aroundRect.Add(Climby.EAroundSquare.FRONT_TOP, Point.Zero); aroundRect.Add(Climby.EAroundSquare.FRONT_UNDER, Point.Zero); aroundRect.Add(Climby.EAroundSquare.FRONT_UNDER_UNDER, Point.Zero); aroundRect.Add(Climby.EAroundSquare.TOP, Point.Zero); aroundRect.Add(Climby.EAroundSquare.UNDER, Point.Zero); #endregion lastDir = climby.Direction; // tetriminoFactory = TetriminoFactory.Instance; var tmp = tetriminoFactory.getTetrimino(playerType); currTetrimino = tmp.Item1; shadowTetrimino = tmp.Item2; hud.setNext(TetriminoFactory.Instance.getNextTetrimino(playerType), playerType); cur = TimeSpan.Zero; //lat = new TimeSpan(10000000/3); // 3 score = new Score(); level = new Level(); //lat = new TimeSpan(10000000 / (level.level + 1)); lat = new TimeSpan((10 - level.level) * 1000000); //lat = new TimeSpan(2 / (level.level + 1) * 10000000); tSpinLimit = new TimeSpan(1000000 * 3); // TSPIN TIME tSpinCur = TimeSpan.Zero; state = new Dictionary<Climby.EState, Action>(); #region Climby State state.Add(Climby.EState.FALL, climbyFall); state.Add(Climby.EState.FREE_FALL, climbyFreeFall); state.Add(Climby.EState.CLIMB, climbyClimb); state.Add(Climby.EState.END_CLIMB, climbyClimb); state.Add(Climby.EState.MOVE, climbyMove); state.Add(Climby.EState.STOP, climbyStop); #endregion updateAroundRects(); }
public override void Update(GameTime gameTime) { base.Update(gameTime); board.Update(gameTime); cur += gameTime.ElapsedGameTime; if (TagManager.Instance.NextTagIsPlace(playerType)) hud.setNext(tetriminoFactory.getAndSetNextTetriminoFromId(TagManager.Instance.getNextTag(playerType), playerType), playerType); //ACTIVE TETRIMiNO if (cur > lat) { cur = TimeSpan.Zero; if (tetriminoCanGoingDown()) currTetrimino.PosRel = new Vector2(currTetrimino.PosRel.X, currTetrimino.PosRel.Y + 1f); } if (!tetriminoCanGoingDown()) { if (tSpinCur == TimeSpan.Zero) tSpinCur = TimeSpan.Zero + gameTime.ElapsedGameTime; else tSpinCur += gameTime.ElapsedGameTime; if (tSpinCur > tSpinLimit) { SoundManager.Instance.play(SoundManager.EChannel.SFX, SoundManager.ESound.DROP, 0, 0.5f, false); death = board.pushBlocks(currTetrimino, climby.DeadZone); //END -- ACTIVE TETRIMiNO //BOARD #region FullLine Event List<int> brokenLines = board.checkFullLine(); climby.stepDown(aroundRect, board.CamUp); if (brokenLines.Count > 0) // Happens when lines are borken { Point climbyRelPos = climby.getRelPos(); score.addLineScore(brokenLines.Count * brokenLines.Count); hud.setScore(score.TotalScore, playerType); int nbDown = 0; foreach (int l in brokenLines) if (climbyRelPos.Y < l) nbDown++; if (nbDown > 0) climby.stepDown(aroundRect, nbDown); } #endregion if (climby.State != Climby.EState.CLIMB && climby.ActualPosition.Bottom > Constants.Measures.upBoardMargin + Constants.Measures.boardHeight) death = true; var tmp = tetriminoFactory.getTetrimino(playerType); currTetrimino = tmp.Item1; shadowTetrimino = tmp.Item2; hud.setNext(TetriminoFactory.Instance.getNextTetrimino(playerType), playerType); tSpinCur = TimeSpan.Zero; } } //state[climby.State](); climby.Update(gameTime); // state[climby.State](); // INVERTED UPDATE AND STATECHANGE if (lastDir != climby.Direction || climby.State == Climby.EState.MOVE || climby.State == Climby.EState.FREE_FALL) updateAroundRects(); lastDir = climby.Direction; var tmpClimbyStepHeight = climby.OldMinHeight - climby.MinHeight; if (tmpClimbyStepHeight > 0) { score.addClimbyScore(tmpClimbyStepHeight); hud.setScore(score.TotalScore, playerType); } if (level.updateLevel(tmpClimbyStepHeight)) { hud.setLevel(level.level, playerType); //lat = new TimeSpan(10000000 / (level.level + 1)); //lat = new TimeSpan(2 / ((level.level + 1) * 11) * 1000000000); lat = new TimeSpan((10 - level.level) * 1000000); climby.setSpeedFromLevel(level.level); } projectShadow(); }
public bool targetCanGoingDown(ATetrimino target) { List<Block> shapes = target.getBlocks(); foreach (Block b in shapes) { if (target.PosRel.Y + b.PosRel.Y > Constants.Measures.boardBlockHeight - 2) return false; if (board.isBusyCase(new Vector2(target.PosRel.X + b.PosRel.X, target.PosRel.Y + b.PosRel.Y + 1))) return false; } return true; }
public void dropDownTarget(ATetrimino target) { while (targetCanGoingDown(target)) target.downMove(); }
public bool pushBlocks(ATetrimino t, Rectangle climbyDeadZone) { bool ret = false; updatedLine = new HashSet<int>(); List<Block> blocks = t.getBlocks(); int tx = (int)t.PosRel.X; int ty = (int)t.PosRel.Y; float min = blocks[0].PosRel.Y + ty; camUp = 0; foreach (Block b in blocks) { b.setHitBoxValue((int)((b.PosRel.X + tx) * Constants.Measures.blockSize + CoordHelper.Instance.getLeftMargin(playerType)), (int)((b.PosRel.Y + ty) * Constants.Measures.blockSize + Constants.Measures.upBoardMargin)); if (climbyDeadZone.Intersects(b.HitBox)) ret = true; // DEATH grid[(int)(b.PosRel.Y + ty)][(int)(b.PosRel.X + tx)] = b; updatedLine.Add((int)(b.PosRel.Y + ty)); if (min > b.PosRel.Y + ty) min = b.PosRel.Y + ty; } camUp = (int)((Constants.Measures.boardBlockHeight / 2 - 2) - min); return ret; }
public void setNext(ATetrimino t, CoordHelper.EProfile profile) { nextValue[profile] = t; }