Example #1
0
        public long getNextTag(CoordHelper.EProfile p)
        {
            long ret = nextTag[p];

            usedTags.Add(nextTag[p]);
            return ret;
        }
Example #2
0
 public Climby(CoordHelper.EProfile pt)
     : base(App.Game)
 {
     playerType = pt;
     if (playerType == CoordHelper.EProfile.ONEPLAYER)
         skin = SpriteManager.ESprite.CLIMBYBLUE;
     else
         skin = SpriteManager.ESprite.CLIMBYRED;
     pos = new Vector2(CoordHelper.Instance.getLeftMargin(playerType) + Constants.Measures.boardWidth / 2,
                           Constants.Measures.upBoardMargin + Constants.Measures.boardHeight - Constants.Measures.blockSize);
     actualPosition = new Rectangle((int)pos.X, (int)pos.Y, (int)Constants.Measures.blockSize, (int)Constants.Measures.blockSize);
     deadZone = new Rectangle((int)pos.X + (int)(Constants.Measures.blockSize / 3),
                              (int)pos.Y + (int)(Constants.Measures.blockSize / 3), (int)(Constants.Measures.blockSize / 3), (int)(Constants.Measures.blockSize / 3));
     actions = new Dictionary<EState, Action<GameTime>>();
     #region Actions
     actions.Add(EState.CLIMB, climb);
     actions.Add(EState.END_CLIMB, move);
     actions.Add(EState.FALL, move);
     actions.Add(EState.FREE_FALL, fall);
     actions.Add(EState.MOVE, move);
     actions.Add(EState.STOP, stop);
     #endregion
     state = EState.MOVE;
     direction = EDirection.RIGHT;
     rotation = 0f;
     setSpeedFromLevel(0);
     influence = 1f;
     minHeight = (int)((pos.Y - Constants.Measures.upBoardMargin) / Constants.Measures.blockSize);
     oldMinHeight = minHeight;
 }
Example #3
0
 public TetriP(CoordHelper.EProfile pt, float transparency = 1f, bool shadow = false)
     : base(SpriteManager.ESprite.P, pt, transparency, shadow)
 {
     orientations.Add(pos2);
     orientations.Add(pos3);
     orientations.Add(pos4);
 }
Example #4
0
        public EndGame(Score s, CoordHelper.EProfile player)
            : base()
        {
            Color ph;
            Color tbcolor;
            score = s;
            if (player == CoordHelper.EProfile.TWOPLAYER)
            {
                tbcolor = Constants.Color.p2Dark;
                who = new GameString("RED", TextManager.EFont.AHARONI, tbcolor, 0.8f);
                ph = Constants.Color.p2Light;
            }
            else if (CoordHelper.Instance.Profile == CoordHelper.EProfile.TWOPLAYER)
            {
                tbcolor = Constants.Color.p1Dark;
                who = new GameString("BLUE", TextManager.EFont.AHARONI, tbcolor, 0.8f);
                ph = Constants.Color.p1Light;
            }
            else
            {
                tbcolor = Constants.Color.p1Dark;
                who = new GameString("YOU", TextManager.EFont.AHARONI, tbcolor, 0.8f);
                ph = Constants.Color.p1Light;
            }

            scored = new GameString(" SCORED", TextManager.EFont.AHARONI, Color.White, 0.8f);
            who.Pos = new Vector2((Constants.Measures.landscapeWidth - TextManager.Instance.getSizeString(TextManager.EFont.AHARONI, who.Value+scored.Value).X * who.Scale) / 2,
                            Constants.Measures.upBoardMargin + 130);
            scored.Pos = new Vector2(who.Pos.X + TextManager.Instance.getSizeString(TextManager.EFont.AHARONI, who.Value).X * who.Scale,
                                        Constants.Measures.upBoardMargin + 130);
            scoredBox = new Rectangle((int)(who.Pos.X - 50),
                                          (int)(scored.Pos.Y - 40),
                                          (int)(TextManager.Instance.getSizeString(TextManager.EFont.AHARONI, who.Value + scored.Value).X * scored.Scale + 100),
                                          (int)(TextManager.Instance.getSizeString(TextManager.EFont.AHARONI, who.Value + scored.Value).Y * scored.Scale + 40));

            scoreStr = new GameString(score.TotalScore.ToString(), TextManager.EFont.AHARONI, who.Color);
            scoreStr.Pos = new Vector2((Constants.Measures.landscapeWidth - TextManager.Instance.getSizeString(TextManager.EFont.AHARONI,scoreStr.Value).X) / 2,
                                        scoredBox.Bottom + 5);

            scoreBox = new Rectangle((int)(Constants.Measures.landscapeWidth - TextManager.Instance.getSizeString(TextManager.EFont.AHARONI, scoreStr.Value).X) / 2 - 30,
                                        scoredBox.Y + scoredBox.Height,
                                        (int)TextManager.Instance.getSizeString(TextManager.EFont.AHARONI, scoreStr.Value).X + 60,
                                        (int)TextManager.Instance.getSizeString(TextManager.EFont.AHARONI, scoreStr.Value).Y);
            name = new GameString("ENTER YOUR NAME", TextManager.EFont.AHARONI, Color.White, 0.8f);
            name.Pos = new Vector2((Constants.Measures.landscapeWidth - TextManager.Instance.getSizeString(TextManager.EFont.AHARONI, name.Value).X * name.Scale) / 2,
                                        scoreBox.Bottom + 200);
            nameBox = new Rectangle((int)name.Pos.X - 50, (int)name.Pos.Y - 40,
                (int)(TextManager.Instance.getSizeString(TextManager.EFont.AHARONI, name.Value).X * name.Scale + 100),
                (int)(TextManager.Instance.getSizeString(TextManager.EFont.AHARONI, name.Value).Y * name.Scale + 40));
            tb = new TextBox(saveScore, tbcolor, ph, new Rectangle((int)(Constants.Measures.landscapeWidth - 400) / 2, (int)nameBox.Bottom, 400, 150));

            SurfaceKeyboard.CenterX = (float)InteractiveSurface.PrimarySurfaceDevice.Width - (SurfaceKeyboard.Width / 2);
            SurfaceKeyboard.CenterY = (float)InteractiveSurface.PrimarySurfaceDevice.Height - (SurfaceKeyboard.Height / 2);
            SurfaceKeyboard.Layout = Microsoft.Surface.KeyboardLayout.Alphanumeric;
            SurfaceKeyboard.ShowsFeedback = false;
        }
Example #5
0
 public APlay(CoordHelper.EProfile profile)
     : base()
 {
     CoordHelper.Instance.setProfile(profile);
     hud = new HUD();
     control = new PlayerControl(this);
     player1 = new GameSession(CoordHelper.EProfile.ONEPLAYER, hud);
     ipt = null;
     if (App.UserInput is TouchInput)
         ipt = App.UserInput as TouchInput;
     else
         (App.UserInput as KeyboardInput).KeyRepeatTime = new TimeSpan(1500000);
 }
Example #6
0
 public ATetrimino(SpriteManager.ESprite color, CoordHelper.EProfile pt, float transparency = 1f, bool shadow = false)
     : base(App.Game)
 {
     PlayerType = pt;
     orientation = 0;
     posRel = new Vector2(3, -3);
     orientations = new List<Action>();
     orientations.Add(pos1);
     shape = new List<Block>();
     shape.Add(new Block((shadow ? SpriteManager.ESprite.NONE : color), this, transparency));
     shape.Add(new Block((shadow ? SpriteManager.ESprite.NONE : color), this, transparency));
     shape.Add(new Block((shadow ? SpriteManager.ESprite.NONE : color), this, transparency));
     shape.Add(new Block((shadow ? SpriteManager.ESprite.NONE : color), this, transparency));
     orientations[orientation].Invoke();
 }
Example #7
0
        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();
        }
Example #8
0
        private int getNextTetriminoId(CoordHelper.EProfile profile)
        {
            int key = rand.Next(tetriminiConstructors.Count);
            int it = key;

            while (tetriminiConstructors[it].Item2[profile] == true)
            {
                it = (it + 1) % tetriminiConstructors.Count;
                if (it == key)
                {
                    resetTetriminiConstructors(profile);
                    return getNextTetriminoId(profile);
                }
            }
            tetriminiConstructors[it].Item2[profile] = true;
            //tetriminiConstructors[it] = new Tuple<ConstructorInfo, bool>(tetriminiConstructors[it].Item1, true);
            return it;
        }
Example #9
0
 public Board(CoordHelper.EProfile pt, Vector2 size)
     : base(App.Game)
 {
     playerType = pt;
     this.size = size;
     pos = new Rectangle((int)(CoordHelper.Instance.getLeftMargin(playerType)), (int)(Constants.Measures.upBoardMargin), (int)(size.X * Constants.Measures.blockSize), (int)(size.Y * Constants.Measures.blockSize));
     grid = new Block[(int)size.Y][];
     limitLineHeight = 4;
     for (int i = 0; i < grid.Length; i++)
     {
         grid[i] = new Block[(int)size.X];
         for (int j = 0; j < (int)size.X; j++)
             grid[i][j] = null;
     }
     if (SettingsManager.Instance.Device != SettingsManager.EDevice.SURFACE)
     {
         Constants.Measures.leftBoardMargin = (Constants.Measures.portraitWidth - Constants.Measures.boardWidth) / 2;
     }
 }
Example #10
0
 // ALWAYS CALL THIS ONE BEFORE CALLING GET NEXT TETRIMINO
 public Tuple<ATetrimino, ATetrimino> getTetrimino(CoordHelper.EProfile profile)
 {
     var ret =  new Tuple<ATetrimino,ATetrimino>((ATetrimino)tetriminiConstructors[next[profile]].Item1.Invoke(new object[] {profile, 0.7f, false}), (ATetrimino)tetriminiConstructors[next[profile]].Item1.Invoke(new object[] {profile, 0.3f, false}));
     next[profile] = getNextTetriminoId(profile);
     return ret;
 }
Example #11
0
 // RETURNS A VISUAL NEXT TETRIMINO
 public ATetrimino getNextTetrimino(CoordHelper.EProfile profile)
 {
     return (ATetrimino)tetriminiConstructors[next[profile]].Item1.Invoke(new object[] {profile, 1f, false});
 }
Example #12
0
 // RETURNS A VISUAL NEXT TETRIMINO FROM A TAG ID AND SET THE TETRIMINO TO CREATE NEXT
 // HEXA 0 to D
 public ATetrimino getAndSetNextTetriminoFromId(long tagValue, CoordHelper.EProfile profile)
 {
     next[profile] = (int)(tagValue % tetriminiConstructors.Count);
     return (ATetrimino)tetriminiConstructors[(int)(tagValue % tetriminiConstructors.Count)].Item1.Invoke(new object[] {profile, 1f, false});
 }
Example #13
0
 private void resetTetriminiConstructors(CoordHelper.EProfile profile)
 {
     for (int i = 0; i < tetriminiConstructors.Count; i++)
         tetriminiConstructors[i].Item2[profile] = false;
     //tetriminiConstructors[i] = new Tuple<ConstructorInfo, Dictionary<CoordHelper.EProfile, bool>>(tetriminiConstructors[i].Item1, false);
 }
Example #14
0
 public void setScore(int p, CoordHelper.EProfile profile)
 {
     scoreValue[profile].Value = p.ToString();
     scoreValue[profile].Pos = CoordHelper.Instance.getScoreValue(scoreValue[profile], profile);
     scoreValBox[profile] = CoordHelper.Instance.getScoreValueBox(scoreValue[profile], profile);
 }
Example #15
0
 public void setLevel(int p, CoordHelper.EProfile profile)
 {
     levelValue[profile].Value = p.ToString();
     levelValue[profile].Pos = CoordHelper.Instance.getLevelValue(levelValue[profile], profile);
     levelValBox[profile] = CoordHelper.Instance.getLevelValueBox(levelValue[profile], profile);
 }
Example #16
0
 public bool getBlob(CoordHelper.EProfile eProfile)
 {
     return nextBlob[eProfile] == 1;
 }
Example #17
0
 public bool NextTagIsPlace(CoordHelper.EProfile p)
 {
     if (!usedTags.Contains(nextTag[p]) && nextTag[p] != -1)
         return true;
     return false;
 }
Example #18
0
 public TetriO(CoordHelper.EProfile pt, float transparency = 1f, bool shadow = false)
     : base(SpriteManager.ESprite.O, pt, transparency, shadow)
 {
 }
Example #19
0
 public void setNext(ATetrimino t, CoordHelper.EProfile profile)
 {
     nextValue[profile] = t;
 }