示例#1
0
 void PlaceDiceInSlot(DiceObject dice, DiceSlotObject slot)
 {
     dice._slot = slot;
     slot._dice = dice;
     dice.transform.SetParent(slot.transform);
     dice.transform.localPosition = Vector3.zero;
 }
示例#2
0
 public void SetAbility(GameManager gameManager, CardAbility ability)
 {
     _gameManager      = gameManager;
     _ability          = ability;
     _requirementSlots = new List <DiceSlotObject>();
     for (int i = 0; i < _ability._conditions.Count; i++)
     {
         DiceSlotObject diceSlot = Instantiate(_gameManager._prefabDiceSlot, _requirementsObject.transform);
         diceSlot.UpdateUi(_ability._conditions[i]);
         _requirementSlots.Add(diceSlot);
     }
 }
示例#3
0
    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);
    }
示例#4
0
    void PlaceDiceInEmptySlot(DiceSlotObject s)
    {
        if (_dice._locked)
        {
            return;
        }

        DiceSlotObject oldSlot = _dice._slot;

        PlaceDiceInSlot(_dice, s);
        DeselectDice(_dice);
        oldSlot._dice = null;

        _gameManager._battle.UpdateUi();
    }
示例#5
0
    DiceSlotObject GetSlotUnderMouse()
    {
        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)
        {
            DiceSlotObject c = h.gameObject.GetComponentInParent <DiceSlotObject>();
            if (c != null)
            {
                return(c);
            }
        }
        return(null);
    }
示例#6
0
 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);
             }
         }
     }
 }
示例#7
0
    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");
        }
    }