public void OnEndDrag(PointerEventData eventData) { // Check if we're on a valid DieSlot, if not return to our old DieSlot List <RaycastResult> results = new List <RaycastResult>(); graphicRaycaster.Raycast(eventData, results); foreach (RaycastResult result in results) { DieSlot ds = result.gameObject.GetComponentInParent <DieSlot>(); if (ds != null) { // We're in a DieSlot! //Debug.Log("Hit!"); if (IsLegalForSlot(ds)) { AttachToSlot(ds); return; } } } // If we get here, we weren't dropped on a slot. Re-attach to the old spot. //Debug.Log("Missed!"); AttachToSlot(originalDieSlot); StatBlock.alpha = 1; }
public void MoveToSetDieArea() { GameState gs = GameState.GetCurrentGameState(); DieSlot ds = gs.GetNextSetDieSlot(); MoveToSlot(ds); }
// take me out of whatever slot I'm in right now void Unslot() { if (mySlot) { mySlot.removeChild(this.gameObject); mySlot = null; } }
// scale the die back to normal size. Hide the die. public void MoveToDiceCupArea() { DieSlot ds = GameState.GetCurrentGameState().diceCupSlot; MoveToSlot(ds); //Unslot(); //Rigidbody rb = this.GetComponent<Rigidbody>(); //rb.detectCollisions = false; }
// put this die into the locked area public void MoveToLockedArea() { GameState gs = GameState.GetCurrentGameState(); DieSlot ds = gs.GetNextLockedDieSlot(); MoveToSlot(ds); GameState.LockedDieThisTurn(); }
void AttachToSlot(DieSlot ds) { dieSlot.SetDie(null); dieSlot = ds; dieSlot.SetDie(this); this.transform.SetParent(dieSlot.transform); this.transform.localPosition = Vector3.zero; }
public void MoveToUnlockedArea() { if (this.isInLockedArea()) { GameState.UnlockedDieThisTurn(); } GameState gs = GameState.GetCurrentGameState(); DieSlot ds = gs.GetNextActiveDieSlot(); MoveToSlot(ds); }
void MoveToSlot(DieSlot ds) { Unslot(); this.onMoveCompleteUnslot = ds.onMoveCompleteUnslot; // this die does whatever the dieSlot wants to do ds.addChild(this.gameObject); mySlot = ds; //Rigidbody rb = this.GetComponent<Rigidbody>(); //rb.detectCollisions = false; //rb.constraints = RigidbodyConstraints.FreezeAll; }
bool IsLegalForSlot(DieSlot ds) { if (ds.CanOccupy(this) == false) { return(false); } // Make sure we are legal for this slot! if (ds.QuestDiceSlot.TargetType == QuestDeck.TARGET_TYPE.EXACT && GetValue() != ds.QuestDiceSlot.TargetPipValue) { return(false); } if (ds.QuestDiceSlot.TargetType == QuestDeck.TARGET_TYPE.MIN && GetValue() < ds.QuestDiceSlot.TargetPipValue) { return(false); } if (ds.QuestDiceSlot.TargetType == QuestDeck.TARGET_TYPE.MAX && GetValue() > ds.QuestDiceSlot.TargetPipValue) { return(false); } return(true); }