// Use this for initialization void Start() { State = TurnState.Draw; m_CurrentPlayer = 0; DiceObject diceObject = Resources.Load <DiceObject>("Prefabs/Dice"); List <DiceObject> dice = new List <DiceObject>(); SpriteLoader.Load(); DiceFaceLoader.Load(); DiceFace[] faces = new DiceFace[6]; for (int i = 1; i < 7; i++) { faces[i - 1] = DiceFaceLoader.Get("DebugCat-" + i); //new PlayFace(i, i, i, FaceType.Play, Color.black, Color.cyan, "DEFAULT-" + i, MaterialLoader.Get("DebugCat")); DiceFaceLoader.Serialise(faces[i - 1]); } for (int i = 0; i < 18; i++) { DiceObject instance = GameObject.Instantiate <DiceObject>(diceObject); instance.SetFaces(faces); instance.transform.position = new Vector3(-10.0f, 2.0f, -10.0f); instance.GetComponent <Rigidbody>().isKinematic = true; dice.Add(instance); } m_Players = new List <BasePlayer>(); CreatePlayer(dice, typeof(ControllingPlayer)); }
public void ResetHand() { if (!ReferenceEquals(null, Dice)) { Dice = null; } }
// Update is called once per frame void Update() { switch (Parent.State) { case TurnState.Roll: if (Input.GetMouseButtonDown(0)) { m_Touch.Start = Input.mousePosition; foreach (DiceObject die in m_Dice) { if (die.State == DiceState.Rolling) { die.Lift(); } } } if (Input.GetMouseButtonUp(0)) { m_Touch.End = Input.mousePosition; Vector3 velocity = m_Touch.End - m_Touch.Start; foreach (DiceObject die in m_Dice) { if (die.State == DiceState.Rolling) { die.Roll(); Parent.SetState(TurnState.Play); } } } break; case TurnState.Play: if (Input.GetMouseButtonUp(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 100.0f)) { if (hit.transform.name.StartsWith("Dice")) { DiceObject die = hit.transform.gameObject.GetComponent <DiceObject>(); if (die.Selected == false) { die.Lift(); die.Selected = true; } else { die.Lower(); die.Selected = false; } } } } break; } }
void PlaceDiceInSlot(DiceObject dice, DiceSlotObject slot) { dice._slot = slot; slot._dice = dice; dice.transform.SetParent(slot.transform); dice.transform.localPosition = Vector3.zero; }
public void Cancel() { for (int i = 0; i < dices.Count; i++) { dices[i].TurnOn(); } Dice = null; }
public void CreateDice() { for (var i = 0; i < numberOfDice; i++) { var diceInstance = Instantiate(dice); diceInstance.transform.SetParent(contentPanel); DiceObject diceObject = diceInstance.GetComponent <DiceObject>(); dices.Add(diceInstance); } }
void SwapDice(DiceObject d) { if (d._locked || _dice._locked) { return; } DiceSlotObject swapToSlot = d._slot; DiceSlotObject currentSlot = _dice._slot; PlaceDiceInSlot(d, currentSlot); PlaceDiceInSlot(_dice, swapToSlot); DeselectDice(_dice); }
public void Shuffle() { int i = m_Deck.Count; while (i > 1) { i -= 1; int j = UnityEngine.Random.Range(0, i); DiceObject first = m_Deck[i]; DiceObject second = m_Deck[j]; m_Deck[i] = second; m_Deck[j] = first; } }
public Dice(DiceObject diceObject) { _dice = PhotonNetwork.Instantiate($"{Constant.NetworkPrefabsPath}{diceObject.dice.name}", diceObject.activePosition, Quaternion.identity); BackToTheHidePosition(); _faces.AddRange(_dice.GetComponentsInChildren <Models.Face>()); _activePosition = diceObject.activePosition; _hidePosition = diceObject.hidePosition; _strength = diceObject.strength; _rigidbody = _dice.GetComponent <Rigidbody>(); }
public void Init() { round = 0; selectDice = null; onFixPhaseExit = null; entireNodes = new Dictionary <Vector2Int, NodeObject>(); connExits = new Dictionary <NodeObject, HashSet <Vector2Int> >(); dataManager = DataManager.Get(); spriteManager = SpriteManager.Get(); hand.onChangeHand = null; hand.onChangeHand += OnChangeHand; }
void SelectDice(DiceObject d) { if (d._locked) { return; } if (_dice != null) { DeselectDice(_dice); } _dice = d; d.HighlightOn(); }
DiceObject GetDiceUnderMouse() { List <RaycastResult> hits = new List <RaycastResult>(); PointerEventData ped = new PointerEventData(EventSystem.current); ped.position = Input.mousePosition; EventSystem.current.RaycastAll(ped, hits); foreach (RaycastResult h in hits) { DiceObject c = h.gameObject.GetComponentInParent <DiceObject>(); if (c != null) { return(c); } } return(null); }
public override bool Draw() { if (m_Hand.Count == 6) { return(false); } while (m_Hand.Count < 6) { DiceObject next = m_Deck[0]; next.Draw(); m_Deck.RemoveAt(0); m_Hand.Add(next); } MoveHand(); return(true); }
void ProcessDiscreteClicks() { if (Input.GetMouseButtonUp(0)) { DiceObject c = GetDiceUnderMouse(); if (c != null) { if (_dice != c) { SelectDice(c); } else { DeselectDice(c); } } } if (Input.GetMouseButtonUp(1)) { DiceObject c = GetDiceUnderMouse(); DiceSlotObject s = GetSlotUnderMouse(); if (_dice != null && s != null) { if (c == _dice) { DeselectDice(c); } else if (c == null) { PlaceDiceInEmptySlot(s); } else { SwapDice(c); } } } }
void AssignDicePhase() { if (_player._diceNumber == 0) { CombatPhase(); } else { _phase = GamePhase.AssignDice; Debug.Log("starting " + _phase + " phase"); List <CardTray> trays = new List <CardTray> { _playerTray, _handTray, _enemyTray }; foreach (CardTray tray in trays) { foreach (CardSlot slot in tray._slots) { if (slot._card != null) { slot._card._locked = true; } } } for (int i = 0; i < _player._diceNumber; i++) { DiceSlotObject slot = Instantiate(_gameManager._prefabDiceSlot, _diceTray.transform); DiceObject dice = Instantiate(_gameManager._prefabDice, slot.transform); dice._locked = false; slot._dice = dice; dice._slot = slot; int r = Random.Range(1, 6); dice.UpdateValue(r); } Debug.Log("ending " + _phase + " phase"); } }
/// <summary> /// </summary> /// <param name="ServerInstruction"> /// </param> public DiceRolls(string ServerInstruction) : base(ServerInstruction) { Dice = new DiceObject(); //Dice Filter needs Player Name "forced" Regex DiceREGEX = new Regex(DiceFilter, RegexOptions.IgnoreCase); System.Text.RegularExpressions.Match DiceMatch = DiceREGEX.Match(ServerInstruction); //Matches, in order: //1: shortname() //2: full(name) //3: dice(count) //4: sides() //5: +/-# //6: +/- (component match) //7: additional(Message) //8: Final(result) player = new Furre(DiceMatch.Groups[3].Value) { Message = DiceMatch.Groups[7].Value }; double.TryParse(DiceMatch.Groups[4].Value, out double num); Dice.DiceSides = num; num = 0; double.TryParse(DiceMatch.Groups[3].Value, out num); Dice.DiceCount = num; char.TryParse(DiceMatch.Groups[6].Value, out char cchar); Dice.DiceCompnentMatch = cchar; num = 0.0; double.TryParse(DiceMatch.Groups[5].Value, out num); Dice.DiceModifyer = num; num = 0; double.TryParse(DiceMatch.Groups[8].Value, out num); Dice.DiceSides = num; }
public void OnClickDice(DiceObject dice) { Dice = dice; onChangeHand?.Invoke(); }
void DeselectDice(DiceObject d) { _dice = null; d.HighlightOff(); }
public abstract bool Special(DiceObject diceRef);
public int OnClickNode(NodeObject node) { if (selectedNode == node) { return(1); } if (node.NodeState == ENodeState.Close || node.NodeState == ENodeState.Open || node.NodeType != ENodeType.Normal) { return(-1); } var diceFromHand = hand.GetDice(); if (ReferenceEquals(null, diceFromHand)) { return(-1); } if (selectDice == diceFromHand) { if (!ReferenceEquals(null, selectedNode)) { selectedNode.ReadyToTransfer(); selectedNode.ResetNode(); } var route = dataManager.RouteData[selectDice.DiceId]; var sprite = spriteManager.Sprites[route.Name]; node.SetupNode(route, sprite); AddRoundNode(node); LinkNodeAction(node); SelectNode(node); FixNode(); return(0); } selectDice = diceFromHand; if (ReferenceEquals(null, selectDice)) { if (node.Round == round) { SelectNode(node); } } else { if (node.Round == round) { hand.Return(node); } var route = dataManager.RouteData[selectDice.DiceId]; var sprite = spriteManager.Sprites[route.Name]; node.SetupNode(route, sprite); AddRoundNode(node); LinkNodeAction(node); Log.Debug($"Build : {route.Name} / {node.Position}"); hand.DisposeNode(); SelectNode(node); } FixNode(); return(0); }
private void ResetDice() { selectDice = null; }
public override bool Special(DiceObject diceRef) { return(false); }
public abstract bool DoDie(DiceObject dieRef);