Пример #1
0
    private void OnDiceTypeToRemoveChosen(int chosenIndex)
    {
        DiceData diceDataToRemove = null;

        if (chosenIndex == 0)
        {
            diceDataToRemove = levelZeroDie;
        }
        else if (chosenIndex == 1)
        {
            diceDataToRemove = levelOneDie;
        }
        else
        {
            return;
        }

        var item = widgets.Find(p => p.diceData == diceDataToRemove);

        if (item != null)
        {
            widgets.Remove(item);
            Destroy(item.gameObject);
        }

        rollerContainer.sizeDelta = new Vector2(widgets.Count * 100f, 200f);

        foreach (DiceRollerWidget widget in widgets)
        {
            StartCoroutine(RollerSetUpRoutine(widget));
        }
    }
Пример #2
0
        public void AddDice(Dice mini)
        {
            SwipeableImage diceImg;

            if (!mini.IsGenerated)
            {
                diceImg = ImageHelper.DrawDice(mini);
                Thread.Sleep(10);
            }
            else
            {
                var diceData = new DiceData(mini.Path);
                var skData   = DrawHelper.DrawDice(diceData);

                diceImg = new SwipeableImage
                {
                    Source         = ImageSource.FromStream(() => skData.AsStream()),
                    BindingContext = mini,
                    HeightRequest  = 64d,
                    WidthRequest   = 64d
                };
            }

            diceImg.SwipedLeft  += (sender, args) => RemoveDice(DiceLayout.Children.IndexOf(sender));
            diceImg.SwipedRight += (sender, args) => RemoveDice(DiceLayout.Children.IndexOf(sender));

            DiceLayout.Children.Add(diceImg);
        }
Пример #3
0
 public void SetStats2(int numberHitDice, int sizeHitDice, int bonusHitDice)
 {
     HitDice = new DiceData
     {
         NumberOf = numberHitDice,
         SizeOf   = sizeHitDice,
         Bonus    = bonusHitDice
     };
 }
Пример #4
0
 public void SetStats3(int numberDmgDice, int sizeDmgDice, int bonusDmgDice)
 {
     DamageDice = new DiceData
     {
         NumberOf = numberDmgDice,
         SizeOf   = sizeDmgDice,
         Bonus    = bonusDmgDice
     };
 }
Пример #5
0
    public DiceData GenerateDiceResult(DiceData dice, int extraRoll = 0)
    {
        var r = new System.Random();

        int[] results = new int[dice.RollCnt * 2];
        for (int i = 0; i < (dice.RollCnt * 2) + extraRoll; i++)
        {
            results[i] = r.Next(dice.MinValue, dice.MaxValue + 1);
        }
        return(dice.Final(results));
    }
Пример #6
0
 private void UpdateMovement(DiceData obj)
 {
     for (int i = 0; i < unitsController.Soldiers.Count; ++i)
     {
         var sol = unitsController.Soldiers[i].GetComponent <SoldierController>();
         if (sol.Data.Ownership == gameController.CurrentPlayer.Data.PlayerType)
         {
             sol.Data.Movement = obj.Points;
         }
     }
 }
Пример #7
0
 public void Load(DiceData _diceData)
 {
     id       = _diceData.id;
     name     = _diceData.name;
     hp       = _diceData.hp;
     x        = _diceData.x;
     y        = _diceData.y;
     flag     = _diceData.flag;
     activate = _diceData.activate;
     selected = _diceData.selected;
 }
Пример #8
0
 public DiceData this[DiceBase baseValue] {
     get {
         DiceData dice    = DiceTable[baseValue];
         var      r       = new System.Random();
         int[]    results = new int[dice.RollCnt * 2];
         for (int i = 0; i < (dice.RollCnt * 2); i++)
         {
             results[i] = r.Next(dice.MinValue, dice.MaxValue + 1);
         }
         return(dice.Final(results));
     }
 }
Пример #9
0
    private void Start()
    {
        widgets = new List <DiceRollerWidget>(rollerContainer.GetComponentsInChildren <DiceRollerWidget>());

        layoutGroup         = rollerContainer.GetComponent <LayoutGroup>();
        layoutGroup.enabled = true;
        chosenDiceData      = ScriptableObject.CreateInstance <DiceData>();
        chosenDiceData      = levelZeroDie;

        foreach (DiceRollerWidget wid in widgets)
        {
            wid.SetUp(chosenDiceData);
        }
    }
Пример #10
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));
        }
Пример #11
0
        public MobileTemplate(long id, string name)
            : base(id, name)
        {
            SavingThrows = new SavingThrowData();
            HitDice      = new DiceData();
            DamageDice   = new DiceData();
            Statistics   = new Dictionary <StatisticTypes, object>();

            ShortDescription  = $"A newly created {name}";
            LongDescription   = $"Somebody abandoned a newly created {name} here.";
            Level             = 1;
            Position          = "standing";
            DefensivePosition = "standing";
            Class             = "warrior";
            Race = "human";
            Statistics[StatisticTypes.Gender] = "male";
        }
Пример #12
0
    public static Dice MakeDice(DiceData data)
    {
        Dice dice = new Dice();

        dice.scarcity       = data.scarcity;
        dice.throwRemaining = data.throwQuantity;

        for (int i = 0; i < data.value.Length; i++)
        {
            dice.faces.Add(new Face()
            {
                value = data.value[i],
                type  = data.facesType[i],
            });
        }
        return(dice);
    }
Пример #13
0
    private void OnDiceTypeToAddChosen(int chosenIndex)
    {
        if (chosenIndex == 0)
        {
            chosenDiceData = levelZeroDie;
        }
        if (chosenIndex == 1)
        {
            chosenDiceData = levelOneDie;
        }

        var go     = Instantiate(rollerPrefab, rollerContainer, false);
        var widget = go.GetComponent <DiceRollerWidget>();

        widgets.Add(widget);
        StartCoroutine(RollerSetUpRoutine(widget));

        rollerContainer.sizeDelta = new Vector2(widgets.Count * 100f, 200f);
    }
Пример #14
0
    internal void SetUp(DiceData newDiceData)
    {
        incomingResultContainer.Setup();
        currentResultContainer.Setup();
        previousResultContainer.Setup();

        results  = new Queue <DiceResult>();
        diceData = newDiceData;
        var resultsArray = diceData.faces.ToArray();

        foreach (DiceResult result in resultsArray)
        {
            results.Enqueue(result);
        }
        //currentResult = resultsArray[0];
        incomingResult = resultsArray[1];
        incomingResultContainer.DisplayResult(incomingResult, 0f);
        currentResult = resultsArray[0];
        currentResultContainer.DisplayResult(currentResult, 0f);
        previousResult = resultsArray[resultsArray.Length - 1];
        previousResultContainer.DisplayResult(previousResult, 0f);
    }
Пример #15
0
    private void LiftDice()
    {
        //keep a reference to the original container.
        //may be used for replacing a dice in the same container.
        _initialDiceContainerController = diceContainerController;

        //assign the correct dice.
        _currentSelectedDice = diceContainerController.transform.Find("Dice Parent")
                               .GetChild(diceContainerController.diceList.Count - 1).gameObject;

        _isDiceSelected = true;

        //cache the components of the currently selected dice.
        _currentSelectedDiceRB2D = _currentSelectedDice.GetComponent <Rigidbody2D>();
        _currentSelectedDiceData = _currentSelectedDice.GetComponent <DiceData>();

        //stop simulating physics for the dice and change it's position.
        _currentSelectedDiceRB2D.simulated      = false;
        _currentSelectedDice.transform.position = diceContainerController.diceContainerAnchor.position;

        //remove the dice from that list, prepare to add it to a new container.
        diceContainerController.diceList.Remove
            (diceContainerController.diceList[diceContainerController.diceList.Count - 1]);
    }
Пример #16
0
        public int getDiceRecordsNums()
        {
            List <Dice> DiceList = DiceData.getAll();

            return(DiceList.Count);
        }
Пример #17
0
	public static DiceData RollDice () {
		// generate numbers for both dice
		int dice1 = Random.Range(1,7);
		int dice2 = Random.Range(1,7);
		DiceData diceRoll;
		
		// check if its a double
		if(dice1 == dice2){
			diceRoll = new DiceData(dice1+dice2,true);
		}
		else{
			diceRoll =  new DiceData(dice1+dice2,false);
		}
		Debug.Log (dice1+"+"+dice2);
		Debug.Log ("Rolled a "+diceRoll.number);
		Debug.Log ("isDouble?: "+diceRoll.isDouble);
		return diceRoll;
	}
Пример #18
0
	IEnumerator StartTurn () {
		// do stuff at start of turn
		Debug.Log("Started Turn For Player: "+playerName);
		
		// reset all the turn variables from the previous turn
		// and recalculate information
		ResetTurnVariables();
		// for AI
		OnTurnHasStarted();
		// wait for the turn start to be processed
		while(isProcessingTurnStart == true){
			yield return new WaitForEndOfFrame();
		}
		// roll dice
		moveDiceScore = GameController.RollDice();
		
		// start moving
		int doubleCount = 0;
		// check for a double
		if(moveDiceScore.isDouble == true){
			doubleCount = 1;
		}
		movedToJail = false;
		
		isMoving = true;
		StartCoroutine(MoveSpaces(moveDiceScore.number));
		
		// wait for the movement to finish
		while(isMoving == true){
			yield return new WaitForEndOfFrame();
		}
		yield return new WaitForSeconds(moveWaitTime);
		
		// keep rolling until double
		while(moveDiceScore.isDouble == true && movedToJail == false && isBankrupt == false){
		
			// reroll!
			moveDiceScore = GameController.RollDice();
		
			// move squares
			doubleCount ++;
			// did we move to jail?
			if(doubleCount > 2){
				movedToJail = true;
				Debug.Log ("JAILED!");
				GoToJail();
				// TODO move us to jail now.
			}
			// didnt move to jail
			else{
				// start the movement sequence
				isMoving = true;
				StartCoroutine(MoveSpaces(moveDiceScore.number));
				
				// wait for the movement to finish
				while(isMoving == true){
					yield return new WaitForEndOfFrame();
				}
			}
				yield return new WaitForSeconds(moveWaitTime);
		
		}
		
		StartCoroutine(EndOfTurn());
	}
Пример #19
0
 public DiceData(DiceData dice)
 {
     NumberOf = dice.NumberOf;
     SizeOf   = dice.SizeOf;
     Bonus    = dice.Bonus;
 }
Пример #20
0
    private IEnumerator MoveDice(RaycastHit2D hit)
    {
        yield return(new WaitForSeconds(0.1f));

        if (hit.collider != null)
        {
            if (hit.collider.GetComponentInParent <DiceContainerController>() != null)
            {
                diceContainerController = hit.collider.GetComponentInParent <DiceContainerController>();

                if (_isDiceSelected == false)
                {
                    if (diceContainerController.diceList.Count > 0)
                    {
                        LiftDice();

                        //if the dice number is 6 and the container has already been flaged as "filled",
                        //flag it as unfilled and down count the win condition counter.
                        if (_currentSelectedDiceData._diceNumber == 6)
                        {
                            if (diceContainerController.isFilled == true)
                            {
                                diceContainerController.isFilled = false;
                                _winConditionCounter--;
                            }
                        }
                    }
                }
                else if (_isDiceSelected == true)
                {
                    //if there is enough space in the container.
                    if (diceContainerController.diceList.Count < DiceContainerController._maxNumOfCells)
                    {
                        _currentDiceNumber = _currentSelectedDiceData._diceNumber;
                        //if the container is not empty.
                        if (diceContainerController.diceList.Count > 0)
                        {
                            GameObject _currentTopDice =
                                diceContainerController.diceList[diceContainerController.diceList.Count - 1];
                            DiceData _currentTopDiceData = _currentTopDice.GetComponent <DiceData>();

                            //if the current dice number is consecutive to the dice below it,
                            //or if it's the same container and the player wants to re-place it.
                            if ((_currentDiceNumber - 1) == _currentTopDiceData._diceNumber)
                            {
                                PlaceDice(diceContainerController);

                                CheckForWinCondition();
                            }
                            else
                            {
                                PlaceDice(_initialDiceContainerController);
                            }
                        }
                        //if the container is empty.
                        else
                        {
                            //if it's dice 1 the player wants to move.
                            //if (_currentDiceNumber == 1)
                            //{
                            PlaceDice(diceContainerController);
                            //}
                        }
                    }
                    //if the container is full.
                    else
                    {
                        PlaceDice(_initialDiceContainerController);
                    }

                    ResetVariables();
                }
            }
        }
        yield return(new WaitForSeconds(0.1f));
    }
Пример #21
0
        public List <Dice> getAllDice()
        {
            List <Dice> diceList = DiceData.getAll();

            return(diceList);
        }