Esempio n. 1
0
        public void TA_AddPointsForClearedGrid(ref PieceGrid grid)
        {
            var points = grid.InitialSize * 20;

            LastPointTotal = (int)points;
            score         += LastPointTotal;

            var tdStr = string.Format("{0} +{1}", STR_LEVEL_CLEAR, LastPointTotal);

            Globals.tdFactory.CreateTD(Sj.TD_POINTS, tdStr, new Vector2(0, .5f));
        }
Esempio n. 2
0
        public void SetState(PieceState state)
        {
            this.state = state;
            GameObject ps = null;

            switch (state)
            {
            case PieceState.Drifting:
                speed     = pieceVars.driftSpeed;
                speedMult = 1 + (pieceVars.speedMultPerLevel * (GameMode.CurrentLevel - 1));

                if (color == PieceColor.Wild)
                {
                    speed *= .5f;
                }
                rotateSpeed = pieceVars.driftRotateSpeed;
                spriteRen.sortingLayerName = SortingLayers.PiecesDrift;
                // add a particle system!
                ps = pFactory.GetDriftPS(color);
                break;

            case PieceState.Shooting:
                speed       = pieceVars.shootSpeed;
                rotateSpeed = pieceVars.shootRotateSpeed;
                spriteRen.sortingLayerName = SortingLayers.PiecesDrift;
                // add a particle system!
                ps       = pFactory.GetShootingPS(color);
                pspShoot = ps.GetComponent <ParticleSysParent>();
                break;

            case PieceState.Dropping:
                speed       = pieceVars.shootSpeed * .65f;
                rotateSpeed = 0;
                velX        = -1;
                velY        = 0;

                // if the grid is reaching off-screen, drop the piece at the end of the grid
                // otherwise, just drop it right off the right side of the screen
                PieceGrid pg        = PieceFactory.grid;
                float     lastX     = pg.LastPieceX;
                bool      offScreen = lastX > Screenie.ScreenRight;
                x = offScreen ?
                    lastX + (pieceVars.size * 2) :
                    Screenie.ScreenRight + pieceVars.size;

                y = Screenie.ScreenBottom + pieceVars.size;
                SetPosition(x, y);
                spriteRen.sortingLayerName = SortingLayers.PiecesDrift;
                AddDroppingPiece(this);
                // add a particle system!
                ps       = pFactory.GetShootingPS(color);
                pspShoot = ps.GetComponent <ParticleSysParent>();
                break;

            case PieceState.Shifting:
                speed = pieceVars.shiftSpeed;
                break;

            case PieceState.InGrid:
                velX        = 0;
                velY        = 0;
                speed       = 0;
                rotateSpeed = 0;
                spriteRen.sortingLayerName = SortingLayers.PiecesGrid;
                spriteTrans.rotation       = Quaternion.identity;
                SetGridTargetPosition();
                SetPosition(gridTargetX, gridTargetY);

                if (pspShoot != null)
                {
                    pspShoot.Stop();
                }
                if (pspInGrid == null)
                {
                    ps        = pFactory.GetInGridPS(color);
                    pspInGrid = ps.GetComponent <ParticleSysParent>();
                }
                break;
            }

            // if we instantiated a particle system, initialize it now
            if (ps != null)
            {
                psys.Add(ps.GetComponent <ParticleSysParent>());
                ps.transform.parent   = trans;
                ps.transform.position = trans.position;
            }
        }