Beispiel #1
0
 /**
  *      Default constuctor, just set the values to {1,1}
  */
 public GameDiceGump(DiceState _ds) : base(0, 30)
 {
     this.ds          = _ds;
     this.currentRoll = 10;
     this.diceToBeat  = 20;
     AddRollGump();
 }
 // Start is called before the first frame update
 void Start()
 {
     rb            = GetComponent <Rigidbody>();
     rb.useGravity = false;
     rollValue     = 0;
     currentState  = DiceState.NotRolled;
 }
    protected void Dice_OnUsed(DiceController InDice, DiceState InState)
    {
        // We're checking if player used all his dices already (or he has no other
        // moves available) if so, we're skipping his turn.
        // However, we want to do that only, if the player is actually supposed to move his pawn.
        // If that's not the case and the dice was used, it means that GameManager automatically
        // moved player's pawn from Band to the board. In such scenario, we'll skip player's turn
        // in Dice_OnRolled() after using MovePawnFromBand().

        if (State == GameState.RedPlayerMoves || State == GameState.WhitePlayerMoves)
        {
            bool bEveryFullyUsed = true;
            foreach (DiceController dice in Dices)
            {
                if (dice.GetUsageState() != DiceState.FullyUsed)
                {
                    bEveryFullyUsed = false;
                    break;
                }
            }

            // TODO: checking if there are any available moves
            bool bAvailableMovesExist = true;

            if (bEveryFullyUsed || !bAvailableMovesExist)
            {
                SwitchGameState();
            }
        }
    }
Beispiel #4
0
    public void Init(DiceState diceState)
    {
        image1.sprite = GameHelper.Instance.GetDiceSprite(diceState.Number1);
        image2.sprite = GameHelper.Instance.GetDiceSprite(diceState.Number2);

        this.GetComponent <RectTransform>().DOScale(Vector3.one, 0.6f);
    }
Beispiel #5
0
    //public void Ready()
    //{
    //    readyButton.gameObject.SetActive(false);
    //    rebetButton.gameObject.SetActive(false);

    //    rollButton.gameObject.SetActive(true);
    //    rollButton.interactable = true;
    //}

    //public void Rebet()
    //{

    //}

    public void ThrowTwoDices(DiceState diceState)
    {
        AudioControl.Instance.PlaySound(AudioControl.EAudioClip.RollDice);

        IsInBox = false;

        rollButton.interactable  = false;
        undoButton.interactable  = false;
        clearButton.interactable = false;

        ////Test code
        //GameTestHelper.Instance.gameObject.SetActive(false);

        CanvasControl.Instance.gameCrap.chipsManager.IsChipsCanDrag = false;

        hisDice.Init(diceState);
        hisDice.gameObject.SetActive(false);

        CanvasControl.Instance.gameCrap.CurrentDiceState = diceState;

        dice1.gameObject.SetActive(true);
        dice1.Throw(GetRandomDirection(), GetRandomVelocity());

        dice2.gameObject.SetActive(true);
        dice2.Throw(GetRandomDirection(), GetRandomVelocity());

        StartCoroutine(DelayOpenDiceCollider());
    }
Beispiel #6
0
 public LiarsDice(Serial serial) : base(serial)
 {
     this.Name   = "Liar's Dice Game";
     this.Weight = 1.0;
     this.Hue    = 2117;
     ds          = new DiceState(GOLD_PER_GAME, GAME_BALANCE_MIN, GAME_BALANCE_MAX, GAME_PLAYER_TO_ACT_SECONDS, GAME_MAX_PLAYERS);
 }
Beispiel #7
0
 /**
  *      Create new Dice Gump and set it's values to a given array)
  */
 public GameDiceGump(DiceState _ds, int _currentRoll, int _diceToBeat) : base(0, 30)
 {
     this.ds          = _ds;
     this.currentRoll = _currentRoll;
     this.diceToBeat  = _diceToBeat;
     AddRollGump();
 }
Beispiel #8
0
 public GameState(IDictionary <string, BoardUnit> playerUnits, RoundState roundState,
                  string currentGamePhase, DiceState diceState, int currentPlayerNumber)
 {
     _playerUnits        = playerUnits;
     _roundState         = roundState;
     DiceState           = diceState;
     CurrentGamePhase    = currentGamePhase;
     CurrentPlayerNumber = currentPlayerNumber;
 }
Beispiel #9
0
 public TokyoGameState(IDictionary <string, BoardUnit> playerUnits,
                       RoundState roundState,
                       string currentGamePhase,
                       DiceState diceState,
                       int currentPlayerNumber,
                       int score) : base(playerUnits, roundState, currentGamePhase, diceState, currentPlayerNumber)
 {
     Score = score;
 }
Beispiel #10
0
    internal void RollDice()
    {
        currentState  = DiceState.Rolled;
        rb.useGravity = true;
        float dirX = Random.Range(0, 500);
        float dirY = Random.Range(0, 500);
        float dirZ = Random.Range(0, 500);

        rb.AddForce(-transform.right * 3000);
        rb.AddTorque(dirX, dirY, dirZ);
    }
Beispiel #11
0
    public void PointButton()
    {
        DiceState diceState = GameHelper.Instance.RandomDice();

        while (!diceState.IsPoint())
        {
            diceState = GameHelper.Instance.RandomDice();
        }

        CanvasControl.Instance.gameCrap.diceManager.ThrowTwoDices(diceState);
    }
Beispiel #12
0
 private void AnimateDice(DiceState c)
 {
     DiceRolls = c.GetDiceValues().ToList();
     if (NotifyPropertyChanged.Count != 0 && NotifyPropertyChanged[0] is DiceState)
     {
         NotifyNoPossibleMovesAvailable();
     }
     else
     {
         GenerateDiceImages();
     }
 }
    public void AddDiceState(DiceState diceState)
    {
        if (diceQueue.Count < MaxNumber)
        {
            diceQueue.Enqueue(diceState);
        }
        else
        {
            diceQueue.Dequeue();
            diceQueue.Enqueue(diceState);
        }

        BuildHisDice(diceState);
    }
Beispiel #14
0
    public void Roll()
    {
        if (CanvasControl.Instance.gameCrap.chipsManager.GetAllChipsValue() > 0)
        {
            DiceState diceState = GameHelper.Instance.RandomDice();

            CanvasControl.Instance.gameCrap.SetGameStateText(CanvasControl.Instance.gameCrap.chipsManager.GetAllChipsValue(), true);
            CanvasControl.Instance.gameCrap.OneRollWinAndLoseResult = 0;

            ThrowTwoDices(diceState);
        }
        else
        {
            GameHelper.Instance.ShowDialogMessage("Please place a bet on the table.");
        }
    }
Beispiel #15
0
    public void CrapsButton()
    {
        DiceState diceState = GameHelper.Instance.RandomDice();

        while (!diceState.IsCraps())
        {
            diceState = GameHelper.Instance.RandomDice();
        }

        CanvasControl.Instance.gameCrap.diceManager.ThrowTwoDices(diceState);

        //showeDice.Init(diceState);

        //CanvasControl.Instance.gameCrap.CurrentDiceState = diceState;
        //CanvasControl.Instance.gameCrap.historyPanelManager.AddDiceState(diceState);
    }
Beispiel #16
0
 public ExitDiceGump(DiceState _ds) : base(325, 345)
 {
     this.ds         = _ds;
     this.Closable   = false;
     this.Disposable = false;
     this.Dragable   = true;
     this.Resizable  = false;
     this.AddPage(0);
     this.AddBackground(6, 4, 225, 150, 9200);
     this.AddLabel(LEFT_BAR, 25, 0, @"Are You Sure You");
     this.AddLabel(LEFT_BAR, 45, 0, @"Want To Exit?");
     this.AddLabel(LEFT_BAR, 85, 32, @"Back");
     AddButton(LEFT_BAR, 110, 4005, 4006, 1, GumpButtonType.Reply, 3);
     this.AddLabel(LEFT_BAR + 95, 85, 32, @"Yes");
     AddButton(LEFT_BAR + 95, 110, 4017, 4018, 2, GumpButtonType.Reply, 3);
 }
    protected void SetState(DiceState InState)
    {
        State = InState;

        if (FadeRenderer != null)
        {
            if (State == DiceState.NotUsed)
            {
                FadeRenderer.gameObject.SetActive(false);
            }
            else
            {
                FadeRenderer.sprite = State == DiceState.FullyUsed ? FadeFull : FadeHalf;
                FadeRenderer.gameObject.SetActive(true);
            }
        }
    }
Beispiel #18
0
        // szansa, że w kroku t będzie stan iState
        private StateWithChance MaxhChanceToBeInIState(int t, DiceState iState)
        {
            var maxChance = new StateWithChance(default(DiceState), double.MinValue);

            foreach (var jState in this.States)
            {
                var value = this.chances[jState][t - 1].Chance +
                            Math.Log(this.TransitionMatrix[jState, iState]) +
                            Math.Log(this.EmissionMatrix[iState, this.Observations[t]]);

                if (value > maxChance.Chance)
                {
                    maxChance = new StateWithChance(jState, value);
                }
            }
            return(maxChance);
        }
Beispiel #19
0
        public static TokyoGameState Create()
        {
            var turnDice = new DiceData("TurnDice", "res://BoardGame/Dice/DiceDisplay.tscn",
                                        new [] { "Attack", "Energy", "Health" },
                                        new [] { 0, 0, 0 },
                                        new [] { "res://BoardGame/Dice/bite.png", "res://BoardGame/Dice/miss.png", "res://BoardGame/Dice/ok.svg" },
                                        3);

            var diceDictionary = new Dictionary <string, DiceData>
            {
                { "TurnDice", turnDice }
            };

            var diceState = new DiceState(diceDictionary, string.Empty, DicePhase.Hidden, string.Empty);

            return(new TokyoGameState(new Dictionary <string, BoardUnit>(), new RoundState(0, 1), string.Empty, diceState, 1, 0));
        }
    public void Roll()
    {
        if (bCanRoll)
        {
            State = DiceState.NotUsed;
            if (FadeRenderer != null)
            {
                FadeRenderer.gameObject.SetActive(false);
            }

            bCanRoll         = false;
            bFinishedRolling = false;
            StartCoroutine(RollCoroutine());
        }
        else
        {
        }
    }
Beispiel #21
0
 public NewDiceGameGump(DiceState _ds, int _bankBalance) : base(325, 345)
 {
     this.ds          = _ds;
     this.bankBalance = _bankBalance;
     this.Closable    = false;
     this.Disposable  = false;
     this.Dragable    = true;
     this.Resizable   = false;
     this.AddPage(0);
     this.AddBackground(6, 4, 190, 150, 9200);
     this.AddLabel(LEFT_BAR, 20, 0, @"Liars Dice");
     this.AddLabel(LEFT_BAR, 40, 0, @"");
     this.AddLabel(LEFT_BAR, 60, 32, @"Balance: " + bankBalance + " gp.");
     AddImageTiled(LEFT_BAR, 80, 142, 21, 2501);
     AddTextEntry(LEFT_BAR + 7, 80, 200, 30, 255, 0, @"");
     AddButton(LEFT_BAR, 110, 4005, 4006, 1, GumpButtonType.Reply, 3);
     AddButton(LEFT_BAR + 95, 110, 4017, 4018, 2, GumpButtonType.Reply, 3);
 }
    void Awake()
    {
        DontDestroyOnLoad(this);

        bcManager = (BattleCheckManager)FindObjectOfType(typeof(BattleCheckManager));

        diceStates = new DiceState[battleDice.Length];
        for (int i = 0; i < battleDice.Length; i++)
        {
            diceStates[i] = new DiceState();
        }

        //if (characterInstance == null) {
        //	characterInstance = this;
        //} else {
        //	DestroyObject(gameObject);
        //}

        _animator = this.GetComponent <Animator> ();
    }
Beispiel #23
0
    public void OkButton()
    {
        int diceNumber;

        if (int.TryParse(diceInputField.text, out diceNumber))
        {
            if (diceNumber >= 2 && diceNumber <= 12)
            {
                DiceState diceState = GameHelper.Instance.RandomDice();

                while (diceState.Sum != diceNumber)
                {
                    diceState = GameHelper.Instance.RandomDice();
                }

                diceInputField.text = "";
                CanvasControl.Instance.gameCrap.diceManager.ThrowTwoDices(diceState);
            }
        }
    }
    private void BuildHisDice(DiceState diceState)
    {
        GameObject goPrefab = Resources.Load("HisDice") as GameObject;

        GameObject go = Instantiate(goPrefab) as GameObject;

        go.transform.SetParent(historyPanel);
        go.transform.localScale    = Vector3.zero;
        go.transform.localPosition = Vector3.zero;
        go.transform.SetAsFirstSibling();

        currentNumber++;

        HisDice hisDice = go.GetComponent <HisDice>();

        hisDice.Init(diceState);

        if (currentNumber > MaxNumber)
        {
            Destroy(historyPanel.GetChild(currentNumber - 1).gameObject);
            currentNumber--;
        }
    }
 public StatusDiceGump(DiceState _ds, string[] playerNames, int[] playerBalances, int[] playPrevRollIdx, int currPlayerIdx) : base(325, 30)
 {
     this.ds = _ds;
     AddStatusGump();
     AddInformation(playerNames, playerBalances, playPrevRollIdx, currPlayerIdx);
 }
 public StatusDiceGump(DiceState _ds) : base(325, 30)
 {
     this.ds = _ds;
     AddStatusGump();
 }
Beispiel #27
0
 public Dice(DiceState diceState, int maxNumber = 6)
 {
     DiceState = diceState;
     MaxNumber = maxNumber;
     Random    = new Random();
 }
 public CallBluffGump(DiceState _ds) : base(325, 345)
 {
     this.ds = _ds;
     AddCallBluffGump();
 }
 public CallBluffGump(DiceState _ds, int bluffedRoll) : base(325, 345)
 {
     this.ds = _ds;
     AddCallBluffGump();
     AddInformation(bluffedRoll);
 }
Beispiel #30
0
 public static void Initialize()
 {
     CommandSystem.Register("mex", AccessLevel.Player, new CommandEventHandler(DiceCommand_OnCommand));
     ds = new DiceState(GOLD_PER_GAME, GAME_BALANCE_MIN, GAME_BALANCE_MAX, GAME_PLAYER_TO_ACT_SECONDS, GAME_MAX_PLAYERS);
 }