Пример #1
0
    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;
    }
Пример #2
0
    public void MoveToSetDieArea()
    {
        GameState gs = GameState.GetCurrentGameState();

        DieSlot ds = gs.GetNextSetDieSlot();

        MoveToSlot(ds);
    }
Пример #3
0
 //	take me out of whatever slot I'm in right now
 void Unslot()
 {
     if (mySlot)
     {
         mySlot.removeChild(this.gameObject);
         mySlot = null;
     }
 }
Пример #4
0
    //  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;
    }
Пример #5
0
    //	put this die into the locked area
    public void MoveToLockedArea()
    {
        GameState gs = GameState.GetCurrentGameState();

        DieSlot ds = gs.GetNextLockedDieSlot();

        MoveToSlot(ds);
        GameState.LockedDieThisTurn();
    }
Пример #6
0
    void AttachToSlot(DieSlot ds)
    {
        dieSlot.SetDie(null);

        dieSlot = ds;
        dieSlot.SetDie(this);

        this.transform.SetParent(dieSlot.transform);
        this.transform.localPosition = Vector3.zero;
    }
Пример #7
0
    public void MoveToUnlockedArea()
    {
        if (this.isInLockedArea())
        {
            GameState.UnlockedDieThisTurn();
        }
        GameState gs = GameState.GetCurrentGameState();

        DieSlot ds = gs.GetNextActiveDieSlot();

        MoveToSlot(ds);
    }
Пример #8
0
    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;
    }
Пример #9
0
    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);
    }