public void ExitSession()
    {
        if (GameType == GameType.MultiPlayer)
        {
            if (PhotonNetwork.CurrentRoom != null)
            {
                var obj = new Dictionary <int, object>();
                obj[0] = PhotonNetwork.LocalPlayer;
                PhotonNetwork.RaiseEvent(RaiseEventCodes.ExitGame, obj, new RaiseEventOptions()
                {
                    Receivers = ReceiverGroup.MasterClient
                }, SendOptions.SendReliable);
            }
        }
        else if (GameType == GameType.SinglePlayer)
        {
            MatchResult result = new MatchResult()
            {
                ScoreOne = GameStatusScript.getInstance().Score_Player_1,
                ScoreTwo = GameStatusScript.getInstance().Score_Player_2,
                Winner   = WinCase.Player2
            };

            GameSetupSingle.GetInstance().EndGameRPC(result);
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     if (Instance != null)
     {
         Destroy(this);
     }
     Instance = this;
     GameStatusScript.getInstance().MatchStatus = MatchStatus.NOTREADY;
     GameType = GameStatusScript.getInstance().GameType;
     CamObj   = Camera.main;
     setupGame();
 }
    private void OnTriggerExit(Collider other)
    {
        CoinScored coinScored = new CoinScored();

        coinScored.Player = GameStatusScript.getInstance().Turn;
        if (other.gameObject.transform.parent.name == "WhiteCoins")
        {
            coinScored.CoinType = ScoreCoinType.White;
            coinScored.CoinName = other.gameObject.name;
        }
        if (other.gameObject.transform.parent.name == "BlackCoins")
        {
            coinScored.CoinType = ScoreCoinType.Black;
            coinScored.CoinName = other.gameObject.name;
            // GameStatusScript.getInstance().setScore(score, turn);
        }
        if (other.gameObject.name == "Queen")
        {
            coinScored.CoinType = ScoreCoinType.Queen;
            coinScored.CoinName = other.gameObject.name;
        }
        var obj = new Dictionary <int, object>();

        obj[0] = coinScored.Player;
        obj[1] = coinScored.CoinName;
        obj[2] = coinScored.CoinType;
        if (GameType == GameType.MultiPlayer)
        {
            PhotonNetwork.RaiseEvent(RaiseEventCodes.CoinScoredEvent, obj, new RaiseEventOptions()
            {
                Receivers = ReceiverGroup.MasterClient
            }, SendOptions.SendReliable);
        }
        else if (GameType == GameType.SinglePlayer)
        {
            GameSetupSingle.GetInstance().updateScore(obj);
        }
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (GameStatusScript.getInstance() != null)
        {
            Turn = GameStatusScript.getInstance().Turn;
        }
        if (Turn == PlayerType.Player1)
        {
            if (Dragging)
            {
                Vector3 rayPoint = getRayPoint();
                if ((rayPoint.x >= -7.5 && rayPoint.x <= 7.5) && (rayPoint.z <= -10 && rayPoint.z >= -14))
                {
                    var point = rayPoint;
                    point.y            = transform.position.y;
                    point.z            = transform.position.z;
                    transform.position = point;
                    StrigerThrow       = false;

                    // Toggle Ray cast off here
                    StrigerRayCast.toggleLine(false);
                }
                if (rayPoint.z < -13)
                {
                    StrigerThrow = true;
                    // Toggle Ray cast on here
                    StrigerRayCast.toggleLine(false);
                    DragAngle  = AngleBetween(new Vector2(transform.position.x, transform.position.z), new Vector2(rayPoint.x, rayPoint.z));
                    DragLength = Vector3.Distance(transform.position, rayPoint);
                    ThrowAngle = 90 + DragAngle;
                    var x = 100 * Math.Cos(ThrowAngle * Mathf.Deg2Rad);
                    var z = 100 * Math.Sin(ThrowAngle * Mathf.Deg2Rad);
                    ThrowDirection = new Vector3((float)x, 0, (float)z);
                    Debug.DrawRay(transform.position, ThrowDirection, Color.green, 0.2f, false);
                    //  cast line
                    StrigerRayCast.castLine(transform.position, ThrowDirection);
                }
            }
        }
        if (StrigerMoving)
        {
            StrigerMoveTime += Time.deltaTime;
            if (StrigerMoveTime > 7)
            {
                //Unfreeze all y here
                UnfreezeAllYRPC();
                //PhotonView.RPC("UnfreezeAllYRPC", RpcTarget.All);
                if (CoinController.GetInstance().AllSleeping() && GetComponent <Rigidbody>().IsSleeping())
                {
                    StrigerMoveTime = 0;

                    if (GameSetupSingle.GetInstance() != null)
                    {
                        // Toggle turn here
                        GameSetupSingle.GetInstance().ToggleTurn();
                        //PhotonNetwork.RaiseEvent(RaiseEventCodes.ToggleTurnEvent, null, new RaiseEventOptions() { Receivers = ReceiverGroup.MasterClient }, SendOptions.SendReliable);
                        GameStatusScript.getInstance().StrigerMoving = false;
                        StrigerMoving = false;
                    }
                }
            }
        }
    }