예제 #1
0
 void Start()
 {
     if (instance != null && instance != this)
     {
         Destroy(this);
         return;
     }
     started = false;
     //FrameworkCore.setContent(GameInfo.vocabularyContent);
     DifficultyManagement.setDifficulty(Difficulty.Four);
     ScoresManager.AddPoints(-ScoresManager.CurrentPoints);
     RestTime       = levelTime * 60f;
     Time.timeScale = 1;
     instance       = this;
     StartBoard();
 }
예제 #2
0
    void Update()
    {
        //checkMovesTimer += Time.deltaTime;
        if (ScoresManager.CurrentPoints >= WinningScore && started)
        {
            Time.timeScale = 0;
            GameOverText.GetComponent <Text>().text = "You Win!!";
            GameOverText.SetActive(true);
            started = false;
        }
        if (TimeOut && started)
        {
            Time.timeScale = 0;
            GameOverText.GetComponent <Text>().text = "Game Over";
            GameOverText.SetActive(true);
            started = false;
        }
        gameTimer += Time.deltaTime;
        RestTime  -= Time.deltaTime;
        if (RestTime <= 0)
        {
            TimeOut = true;
        }


        if (started)
        {
            _MovingPieces = false;
            for (int y = 0; y < rows; y++)
            {
                for (int x = 0; x < columns; x++)
                {
                    if (PlayingPieces[x, y] != null && PlayingPieces[x, y].Moving)
                    {
                        _MovingPieces = true;
                        y             = rows;
                        break;
                    }
                }
            }
            if (destroyed && !_MovingPieces)
            {
                PlayerCanMove = false;
                destroyed     = false;
                for (int x = 0; x < columns; x++)
                {
                    SlideDown(x, rows - 1);
                }
                NewPieces();
                PlayerCanMove = true;
            }
            if (!_MovingPieces && !destroyed)
            {
                PlayerCanMove = false;
                for (int y = 0; y < rows; y++)
                {
                    for (int x = 0; x < columns; x++)
                    {
                        CheckTileMatchX(x, y, false);
                        CheckTileMatchY(x, y, false);
                    }
                }
                //deal with coins
                int specialCount = 0;
                for (int y = 0; y < rows; y++)
                {
                    for (int x = 0; x < columns; x++)
                    {
                        if (PlayingPieces[x, y] != null && PlayingPieces[x, y].Selected && PlayingPieces[x, y].Piece != null)
                        {
                            //deal with coins
                            //todo
                            _CurrentPosition = GridPositions.GetVector(x, y);
                            switch (PlayingPieces[x, y].pieceScript.currentStrenght)
                            {
                            case TileType.Normal:
                                Destroy(PlayingPieces[x, y].Piece);
                                PlayingPieces[x, y].Piece    = null;
                                PlayingPieces[x, y].Selected = false;
                                PlayingPieces[x, y]          = null;
                                gdesc[x, y] = (int)TileType.Done;
                                ScoresManager.AddPoints(PointsNormal);
                                RestTime += timeToAdd;
                                break;

                            case TileType.Strong:
                                string name = PlayingPieces[x, y].Piece.GetComponent <TextMesh>().text.ToString();
                                Destroy(PlayingPieces[x, y].Piece);
                                GameObject tmp = PieceNormal[0];
                                tmp.GetComponent <TextMesh>().text = name;
                                PlayingPieces[x, y].Piece          = Instantiate(tmp, new Vector3(_CurrentPosition.x, _CurrentPosition.y, zPiecePosition - Random.Range(20f, 30f)), Quaternion.identity) as GameObject;
                                PlayingPieces[x, y].pieceScript.currentStrenght = TileType.Normal;
                                PlayingPieces[x, y].Selected = false;
                                gdesc[x, y] = (int)TileType.Normal;
                                ScoresManager.AddPoints(PointsNormal);
                                RestTime += timeToAdd;
                                break;
                            }
                            //audio.PlayOneShot(destroyPiece);
                            destroyed = true;
                        }
                    }
                }
                PlayerCanMove = true;
            }
        }
    }