public static void AutoSetTargets() { //*change to go for lowest health for players companions and enemies (depending on whose turn it is of course). if (_currTargets.Count <= 0) { if (DiceManager.GetCurrCharacter().tag.Contains("Player") || DiceManager.GetCurrCharacter().tag.Contains("Companion")) { if (GameObject.FindGameObjectsWithTag("Enemy") != null) { _currTargets.Add(GameObject.FindGameObjectsWithTag("Enemy")[0].GetComponent <Character>()); } } else { if (GameObject.FindGameObjectsWithTag("Player") != null) { _currTargets.Add(GameObject.FindGameObjectsWithTag("Player")[0].GetComponent <Character>()); } } } foreach (Character c in DiceManager.GetCurrTargets()) { Debug.Log(c.name); c.GetComponent <SpriteRenderer>().color = Color.red; } }
public void OnStopped() { Random.InitState((int)System.DateTime.Now.Ticks); int diceRoll = Random.Range(1, 7); GameObject.Find("ClickTheDice").GetComponent <Text>().text = "DICE VALUES: "; if (DiceManager.APFound() == false) { GameObject ap = DiceManager.FindEmptyTypeTotal(); ap.GetComponent <Text>().text = "AP: "; ap.transform.GetChild(0).GetComponent <Text>().enabled = true; DiceManager.SetAPFound(true); } string rollValueName = "RollValue" + Dice.LastDiceClicked().name.ToCharArray()[Dice.LastDiceClicked().name.Length - 1]; GameObject.Find(rollValueName).GetComponent <Text>().text = diceRoll.ToString(); int rollTotal = int.Parse(GameObject.Find("RollTotal").GetComponent <Text>().text); rollTotal += diceRoll; GameObject.Find("RollTotal").GetComponent <Text>().text = rollTotal.ToString(); GameObject.Find("RollTotal").GetComponent <Text>().enabled = true; int attackTotal = int.Parse(DiceManager.FindTypeTotalGameObject("AP").transform.GetChild(0).GetComponent <Text>().text); attackTotal += diceRoll; DiceManager.FindTypeTotalGameObject("AP").transform.GetChild(0).GetComponent <Text>().text = attackTotal.ToString(); if (diceRoll == 1) { GameObject.Find("AttackMissed").GetComponent <BillboardMessage>().ShowMessage(); } }
// Use this for initialization void Start() { diceManager = GameObject.FindObjectOfType <DiceManager> (); turnManager = GameObject.FindObjectOfType <TurnManager> (); currentTile = null; startPosition = this.transform.position; }
IEnumerator DeterminePlayerOrder(int timePerRoll) { Dictionary <PlayerColor, int> rolls = new Dictionary <PlayerColor, int>(); int roll; roll = DiceManager.GetDice().RollDice(false); rolls.Add(PlayerColor.Blue, roll); yield return(new WaitForSeconds(timePerRoll)); roll = DiceManager.GetDice().RollDice(false); rolls.Add(PlayerColor.Red, roll); yield return(new WaitForSeconds(timePerRoll)); roll = DiceManager.GetDice().RollDice(false); rolls.Add(PlayerColor.Yellow, roll); yield return(new WaitForSeconds(timePerRoll)); roll = DiceManager.GetDice().RollDice(false); rolls.Add(PlayerColor.Green, roll); yield return(new WaitForSeconds(timePerRoll)); while (rolls.Count > 0) { int n = 0; PlayerColor c = GetLowestRoll(rolls); rolls.Remove(c); order[n++] = c; } }
public void GetDicesTest_NegativeSidesPerDice_ArgumentOutOfRangeException() { int diceToGenerate = rand.Next(1000); int sides = -rand.Next(); Assert.ThrowsException <ArgumentOutOfRangeException>(() => DiceManager.GetDices(sides, diceToGenerate)); }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel(IDataService dataService) { _dataService = dataService; DiceManager = new DiceManager(new List <Dice>() { new Dice(6), new Dice(100), new Dice(10), new Dice(8), new Dice(7) }); //DiceCollectionView = diceManager.DiceView; DiceManager.DiceSorter.SetSortStrategy(new SortBySides(ListSortDirection.Ascending)); //AddDiceCommand = new RelayCommand<string>((sides) => Dices.Add(new Dice(int.Parse(sides)))); ClearDiceCommand = new RelayCommand(() => DiceManager.ClearDices()); ClacluateDiceCommand = new RelayCommand(RollDices); DiceTypeList = new ObservableCollection <DiceCounter>() { new DiceCounter(2), new DiceCounter(4), new DiceCounter(6), new DiceCounter(8), new DiceCounter(10), new DiceCounter(20), new DiceCounter(100) }; //CalculateDices(); }
private void CalculateWaitedResults() { foreach (Die die in DiceList) { die.Model.GetComponentInChildren <Rigidbody>().isKinematic = true; DieSide face = die.GetModelFace(); die.TrySetSide(face); if (die.IsWaitingForNewResult) { die.IsWaitingForNewResult = false; DiceManager.CallDiceResult(this, new DieResultEventArg(Owner, Type, die.Side)); } } if (IsDiceFacesVisibilityWrong()) { OrganizeDicePositions(); } else { UpdateDiceCompareHelperPrediction(); } Roster.GetPlayer(PlayerNo.Player1).SyncDiceResults(); // Server synchs dice Phases.CurrentSubPhase.IsReadyForCommands = true; }
public static int CalculateDiceRollThree() { int aP = 0; if (DiceManager.FindTypeTotalGameObject("AP") != null) { aP = int.Parse(DiceManager.FindTypeTotalGameObject("AP").transform.GetChild(0).GetComponent <Text>().text); } int diceRoll = 0; if (aP >= 30) { diceRoll = Random.Range(1, 3); } else { diceRoll = Random.Range(1, 138); if (diceRoll <= 12) { diceRoll = 1; } else if (diceRoll <= 27) { diceRoll = 2; } else { diceRoll = 3; } } return(diceRoll); }
public static List <AskModel> Ask(List <string> ques) { if (!ques.Any()) { return(new List <AskModel>()); } var list = ques.Select(p => new AskModel { Quest = p }).ToList(); int i = 0; while (i < 1000) { var dindex = DiceManager.RollDice(ques.Count) - 1; var des = DiceManager.RollDice(1000); if (des >= 850 && i <= 999) { var newRes = DiceManager.RollDice(999 - i); list[dindex].Percent += newRes / 10m; i += newRes; } else { list[dindex].Percent += 0.1m; i++; } } return(list); }
public void GetDicesTest_ZeroSidesPerDice_ArgumentOutOfRangeException() { int diceToGenerate = -rand.Next(1000); const int Sides = 0; Assert.ThrowsException <ArgumentOutOfRangeException>(() => DiceManager.GetDices(Sides, diceToGenerate)); }
private void MoveAndResetDice() { if (!_hasMovedDown) { //Move dice until it has reached its target if (this.GetComponent <ShakeObject>().IsShaking()) { this.GetComponent <ShakeObject>().StopShaking(); } MoveDown(); } else { //Reset roll values DiceManager.ResetRollValues(); //Reset dice position and question marks and start shaking ResetDice(); //Set necessary variables back to false _hasMovedDown = false; _resetDice = false; } }
// Use this for initialization void Start() { CanMoveCharacter = false; tiles = new GameObject[rowsNum, columnsNum]; diceManager = new DiceManager(); diceManager.Init(); room_1 = new Room(); characterPosition_i = testI; characterPosition_j = testJ; for (int i = 0; i < rowsNum; i++) { for (int j = 0; j < columnsNum; j++) { tiles[i, j] = Instantiate(TilePrefab, Vector3.zero, Quaternion.identity); tiles[i, j].GetComponent <Tile>().NewTile(i, j); tiles[i, j].GetComponent <Tile>().prev_Tile_Type = tiles[i, j].GetComponent <Tile>().tile_Type; } } room_1.NewRoom(5, 5, 2, 4); setCharacterPosition(characterPosition_i, characterPosition_j); }
private void ManageAttackAnimations() { if (TurnManager.GetCurrTurnCharacter().tag.Contains("Player")) { Animator myAnim = GameObject.Find("Ayanda").GetComponent <Animator>(); myAnim.SetBool("defaultAttack", false); myAnim.SetBool("specialAttack", false); myAnim.SetBool("multiplierAttack", false); myAnim.SetBool("attack", true); DiceType myDiceType = DiceManager.SearchDiceType(_attacks[_attackNum].GetMyType()); int aP = int.Parse(DiceManager.FindTypeTotalGameObject("AP").transform.GetChild(0).GetComponent <Text>().text); GameObject.Find("Ayanda").GetComponent <Animator>().SetBool(determineAnimationType(aP), true); } else { if (!TutorialManager.IsTutorial()) { GameObject.Find("AyandaMonster").GetComponent <Animator>().SetBool("attack", true); } } }
public void ConfirmAttack() { this.GetComponent <CustomButton>().Disable(); if (DiceManager.GetCurrTargets().Count <= 0) { DiceManager.AutoSetTargets(); } if (DiceManager.GetCurrTargets().Count > 0) { _originalPos = TurnManager.GetCurrTurnCharacter().gameObject.transform.position; _startAttack = true; DiceManager.CurrCombatStage = DiceManager.CombatStage.ExecutingAttack; _attacks = GameObject.Find("AttackHolder").GetComponent <AttackHolder>().GetAttacks(); _attackNum = 0; ManageAttackAnimations(); } if (TutorialManager.IsTutorial() && !TutorialManager.AttackButtonFirstClicked()) { GameObject.Find("TutorialManager").GetComponent <TutorialManager>().FadeTutorial(); } }
private static void LoadDice() { for (int i = 0; i < _save._savedDice.Count; i++) { DiceManager.GetInstance().LoadDice(_save._savedDice[i]); } }
public void GiveReward() { switch (m_rewardType) { case EPerkRewardType.PRT_Money: LevelManager.GetInstance().AddPerkMoney(m_rewardAmount); break; case EPerkRewardType.PRT_Dice: for (int i = 0; i < m_rewardAmount; i++) { DiceManager.GetInstance().AddPerkDice(); } break; case EPerkRewardType.PRT_Combo: ComboManager.GetInstance().UnlockCombo(m_comboReward); break; case EPerkRewardType.PRT_Power: for (int i = 0; i < m_rewardAmount; i++) { DiceManager.GetInstance().AddPerkPower(); } break; default: Debug.LogWarningFormat("Perk {0} has set a wrong reward!", name); break; } }
public static void ExecuteAttack() { foreach (Character c in _currTargets) { if (DiceManager.FindTypeTotalGameObject("AP") != null) { int damage = int.Parse(DiceManager.FindTypeTotalGameObject("AP").transform.GetChild(0).GetComponent <Text>().text); GameObject healthCanvas = Utilities.SearchChild("HealthCanvas", c.gameObject); GameObject healthBar = Utilities.SearchChild("HealthBar", healthCanvas); float excess = c.GetComponent <Character>().GetCurrHP() - damage; if (excess < 0) { GameObject currCharacter = TurnManager.GetCurrTurnCharacter().GetComponent <Character>().gameObject; GameObject healthCanvasChar = Utilities.SearchChild("HealthCanvas", currCharacter.gameObject); GameObject healthBarChar = Utilities.SearchChild("HealthBar", healthCanvasChar); healthBarChar.GetComponent <HealthBar>().ChangeHealth(Mathf.Abs(excess)); } healthBar.GetComponent <HealthBar>().ChangeHealth(-damage); } } }
public void Dice_Sort_Test() { List <Dice> list = new List <Dice> { new Dice(6), new Dice(100), new Dice(10), new Dice(8), new Dice(200) }; DiceManager manager = new DiceManager(list); manager.DiceSorter.SetSortStrategy(new SortBySides(ListSortDirection.Ascending)); var sorted = new int[] { 6, 8, 10, 100, 200 }; int count = 0; foreach (Dice dice in manager.DiceSorter.DiceView) { Assert.AreEqual(sorted[count], dice.DiceSides); count++; } manager.DiceSorter.SetSortStrategy(new SortBySides(ListSortDirection.Descending)); count = sorted.Length; foreach (Dice dice in manager.DiceSorter.DiceView) { Assert.AreEqual(sorted[count - 1], dice.DiceSides); count--; } }
public void OnStopped() { Random.InitState((int)System.DateTime.Now.Ticks); int diceRoll = Random.Range(1, 7); GameObject.Find("ClickTheDice").GetComponent <Text>().text = "DICE VALUES: "; FreezeOnRoll(diceRoll); if (DiceManager.PPFound() == false) { GameObject pp = DiceManager.FindEmptyTypeTotal(); pp.GetComponent <Text>().text = "PP: "; pp.transform.GetChild(0).GetComponent <Text>().enabled = true; if (!TurnManager.GetCurrTurnCharacter().tag.Contains("Enemy")) { GameObject.Find("ConfirmAttackButton").GetComponent <CustomButton>().Enable(); } DiceManager.SetPPFound(true); } string rollValueName = "RollValue" + Dice.LastDiceClicked().name.ToCharArray()[Dice.LastDiceClicked().name.Length - 1]; GameObject.Find(rollValueName).GetComponent <Text>().text = diceRoll.ToString(); int poisonTotal = int.Parse(DiceManager.FindTypeTotalGameObject("PP").transform.GetChild(0).GetComponent <Text>().text); poisonTotal += diceRoll; DiceManager.FindTypeTotalGameObject("PP").transform.GetChild(0).GetComponent <Text>().text = poisonTotal.ToString(); }
public void Init(TokenManager tokenManager, DiceManager diceManager, OpponentController oppCtrl, BoardHighlighter highlighter) { this.diceManager = diceManager; this.opponentCtrl = oppCtrl; this.highlighter = highlighter; this.tokenManager = tokenManager; opponentCtrl.onTokenSelected += TokenSelected; opponentCtrl.TokenManager = tokenManager; diceManager.onDiceRolled += DiceRolled; dice = diceManager.GetCurrentActiveDice(); tokenManager.onTokenAnimationsDone += TokenAnimationsEnd; selectedTypes = new Token.TokenType[tokenManager.Tokens.Keys.Count]; tokenManager.Tokens.Keys.CopyTo(selectedTypes, 0); foreach (KeyValuePair <Token.TokenType, Token[]> entry in tokenManager.Tokens) { for (int i = 0; i < entry.Value.Length; i++) { Token t = entry.Value[i].GetComponent <Token> (); t.onTokenSelected += TokenSelected; } } }
private void Start() { redHome = GetComponentInParent <RedHome>(); redHomeRollingDice = GetComponentInParent <RedHome>().rollingDice; aiManager = GetComponentInParent <AIManager>(); diceManager = GameObject.Find("DiceManager").GetComponent <DiceManager>(); }
public static DiceManager GetInstance() { if (_instance == null) { _instance = new DiceManager(); } return(_instance); }
// Start is called before the first frame update void Start() { m_photonView = GetComponent <PhotonView>(); m_turnManager = GetComponent <TurnManager>(); m_unitManager = GetComponent <UnitManager>(); m_combatManager = GetComponent <CombatManager>(); m_diceManager = GetComponent <DiceManager>(); }
public void RollDiceSingleTest() { IDice dice = DiceManager.GetDice(rand.Next()); DiceRoller roller = new DiceRoller(); int result = roller.RollDice(dice); Assert.IsTrue(result >= 1 && result <= dice.Sides); }
private void Start() { temp = GetComponent <PlayerPiece>(); _movePcOnce = true; blueHome = GetComponentInParent <BlueHome>(); blueHomeRollingDice = blueHome.rollingDice; diceManager = GameObject.Find("DiceManager").GetComponent <DiceManager>(); }
private void handleChoicePopupAccepted(int n) { //non c'è bisogno di de-registrarsi dal popup DiceManager diceManager = DiceManager.GetInstance(); diceManager.ResultReady += handleDiceResult; diceManager.Roll(n, _statoDifesa.TankNumber > n ? n : _statoDifesa.TankNumber); //Math.Min(n, _statoDifesa.TankNumber) }
public void GetDicesTest_GetTotalOfZeroDice_ShouldReturnZeroDice() { const int DiceToGenerate = 0; int sides = rand.Next(); IDice[] dices = DiceManager.GetDices(sides, DiceToGenerate); Assert.AreEqual(0, dices.Length); }
public static void FinishAttack() { GameObject.Find("ConfirmAttackButton").GetComponent <ConfirmAttackButton>().HideUI(); Debug.Log("FINISHED ATTACK"); DiceManager.GetCurrCharacter().SetTurnFinished(); DiceManager.CurrCombatStage = DiceManager.CombatStage.ChangingTurns; NextTurn(); }
public void ExecuteEnemyAI() { DiceManager.AutoSetTargets(); _firstRollTaken = false; _executeEnemyAI = true; _startTimer = true; Debug.Log("EXECUTE ENEMY AI CALLED"); }
private static void GatherDice() { _save._savedDice = new List <DiceStats>(); for (int i = 0; i < DiceManager.GetInstance().GetDiceList().Count; i++) { DiceStats temp = new DiceStats(DiceManager.GetInstance().GetDiceList()[i].GetStats()); _save._savedDice.Add(temp); } }
private static void Main(string[] args) { DiceManager dices = new DiceManager(new List<Dice>(){}, new Random().Next()); Buff<DiceManager> AddD10 = new Buff<DiceManager>((client) => { client.NewDice(new List<Range>() { new Range(1, 6) }); }); for (int i = 0; i < 10; i++) { dices.Buff(AddD10, (client) => { }); } DiceManager buffeddices = dices.ApplyBuffs(); for (int i = 0; i < 100; i++) { Console.Write(String.Format("{0} ", buffeddices.Roll())); } Console.ReadKey(); }