Ejemplo n.º 1
0
    //Zoom text to a position, wait for 1 second, then zoom to another position
    IEnumerator ZoomText(ZoomTextTemplate zoomObj)
    {
        //print(sunZoom.reachedMidPoint);
        while (zoomObj.reachedMidPoint == false)
        {
            zoomObj.reachedMidPoint = MoveToLocation(zoomObj.obj, zoomObj.mid);
            yield return(null);
        }
        yield return(new WaitForSeconds(1));

        zoomObj.show = !MoveToLocation(zoomObj.obj, zoomObj.end);
    }
Ejemplo n.º 2
0
 void Awake()
 {
     S       = this;
     sunZoom = new ZoomTextTemplate {
         obj = sunTurnText, start = new Vector3(6, 1.6f, 0), mid = new Vector3(0, 1.6f, 0), end = new Vector3(-6, 1.6f, 0), show = false, reachedMidPoint = false
     };
     moonZoom = new ZoomTextTemplate {
         obj = moonTurnText, start = new Vector3(-6, -1.6f, 0), mid = new Vector3(0, -1.6f, 0), end = new Vector3(6, -1.6f, 0), show = false, reachedMidPoint = false
     };
     winnerZoom = new ZoomTextTemplate {
         show = false, reachedMidPoint = false
     };
     loserZoom = new ZoomTextTemplate {
         show = false, reachedMidPoint = false
     };
 }
Ejemplo n.º 3
0
    //Switches the active player when the "End" button is pressed
    public void SwitchPlayers()
    {
        string winner = Board.S.CheckForWinner();

        if (winner == "")//what if all pieces have been used and still no winners?
        {
            DeactivateButtons();
            //print(activePiece.name);
            //Record the last move the previous player played to the board
            if (activePiece != null)
            {
                RecordMove(Utils.CreateStringFromPlacement(activePiece));
                activePiece.GetComponent <GamePiece>().ChangeMovement();
            }



            if (activePlayer == Player.sun)
            {   //Make moon the active player
                moonZoom.obj.transform.position = moonZoom.start;
                moonZoom.show            = true;
                moonZoom.reachedMidPoint = false;
                Utils.DimObject(sunTable);
                Utils.UndimObject(moonTable);
                activePlayer = Player.moon;
                Utils.DisablePieces(sunPieces);
                Utils.DisablePieces(moonPieces);
                GameObject[] flippablePieces = Utils.GetFlippablePieces(sunPieces);
                if (flippablePieces.Length == 0) //No flippable pieces
                {
                    GameObject[] unPlayedPieces = Utils.GetUnplayedPieces(moonPieces);
                    Utils.EnablePieces(unPlayedPieces);
                }
                else
                {
                    Utils.EnablePieces(flippablePieces);
                }
            }
            else
            {   //Make Sun the active player
                sunZoom.obj.transform.position = sunZoom.start;
                sunZoom.show            = true;
                sunZoom.reachedMidPoint = false;
                Utils.DimObject(moonTable);
                Utils.UndimObject(sunTable);
                activePlayer = Player.sun;
                Utils.DisablePieces(moonPieces);
                Utils.DisablePieces(sunPieces);
                GameObject[] flippablePieces = Utils.GetFlippablePieces(moonPieces);
                if (flippablePieces.Length == 0) //No flippable pieces
                {
                    GameObject[] unPlayedPieces = Utils.GetUnplayedPieces(sunPieces);
                    Utils.EnablePieces(unPlayedPieces);
                }
                else
                {
                    Utils.EnablePieces(flippablePieces);
                }
            }
        }
        else //If a winner is detected
        {
            //Display who won and lock all of the pieces.
            //Display Play again or Quit or Replay
            DeactivateButtons();
            Utils.DisablePieces(moonPieces);
            Utils.DisablePieces(sunPieces);
            //Display LOSER text to the loser facing the loser and WINNER text to winner
            //This text comes in from the left hand side
            //Then in the middle fade in the end-game options
            if (winner == "Sun")
            {
                GameObject winnerText = Instantiate(winnerTextPrefab) as GameObject;
                GameObject loserText  = Instantiate(loserTextPrefab) as GameObject;
                Vector3    scale      = winnerText.transform.localScale;
                scale.x *= -1;
                scale.y *= -1;
                winnerText.transform.localScale = scale;
                winnerText.transform.position   = new Vector3(6, 1.6f, 0);
                loserText.transform.position    = new Vector3(-6, -1.6f, 0);
                winnerZoom = new ZoomTextTemplate {
                    obj = winnerText, start = new Vector3(6, 1.6f, 0), mid = new Vector3(0, 1.6f, 0), end = new Vector3(0, 1.6f, 0), show = true, reachedMidPoint = false
                };
                loserZoom = new ZoomTextTemplate {
                    obj = loserText, start = new Vector3(-6, -1.6f, 0), mid = new Vector3(0, -1.6f, 0), end = new Vector3(0, -1.6f, 0), show = true, reachedMidPoint = false
                };
            }
            else if (winner == "Moon")
            {
                GameObject winnerText = Instantiate(winnerTextPrefab) as GameObject;
                GameObject loserText  = Instantiate(loserTextPrefab) as GameObject;
                Vector3    scale      = loserText.transform.localScale;
                scale.x *= -1;
                scale.y *= -1;
                loserText.transform.localScale = scale;
                winnerText.transform.position  = new Vector3(-6, -1.6f, 0);
                loserText.transform.position   = new Vector3(6, 1.6f, 0);
                loserZoom = new ZoomTextTemplate {
                    obj = loserText, start = new Vector3(6, 1.6f, 0), mid = new Vector3(0, 1.6f, 0), end = new Vector3(0, 1.6f, 0), show = true, reachedMidPoint = false
                };
                winnerZoom = new ZoomTextTemplate {
                    obj = winnerText, start = new Vector3(-6, -1.6f, 0), mid = new Vector3(0, -1.6f, 0), end = new Vector3(0, -1.6f, 0), show = true, reachedMidPoint = false
                };
            }
            else
            {
            }
        }
    }