Exemplo n.º 1
0
    private void ResetSwap()
    {
        _swapDirection = Vector2Int.zero;

        _swapTile = null;

        _currentSwapState = SwapState.None;
    }
Exemplo n.º 2
0
    private void StartForwardSwap(Vector2Int direction)
    {
        _swapDirection = direction;

        _swapTile = _board.GetTileAt(_selectedTileInitialCoordinates + _swapDirection);

        _currentSwapState = SwapState.Forward;

        PerformForwardSwap();
    }
Exemplo n.º 3
0
    void Update()
    {
        if (needDrop == true)
        {
            Droping();
        }

        switch (_state)
        {
        case (SwapState.Default):
        {
            if (Input.GetMouseButton(0))
            {
                var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                if (hit.collider != null)
                {
                    _activeCell = hit.collider.GetComponent <CellCtrl> ();
                    _state      = SwapState.Swiping;
                }
            }
            break;
        }

        case (SwapState.Swiping):
        {
            if (Input.GetMouseButton(0))
            {
                var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                if (hit.collider != null && _activeCell.gameObject != hit.collider.gameObject)
                {
                    _passiveCell = hit.collider.GetComponent <CellCtrl> ();
                    if (!_activeCell.AreVerticalOrHorizontalNeighbors(_passiveCell))
                    {
                        _state = SwapState.Default;
                        Restore();
                    }
                    else
                    {
                        _state = SwapState.Updating;

                        StartCoroutine(Swaping());
                    }
                }
            }
            break;
        }
        }
    }
        private static SwapCompactState CompactStateBySwap(SwapState swap)
        {
            if (swap.IsComplete)
            {
                return(SwapCompactState.Completed);
            }

            if (swap.IsCanceled)
            {
                return(SwapCompactState.Canceled);
            }

            return(swap.IsRefunded
                ? SwapCompactState.Refunded
                : SwapCompactState.InProgress);
        }
Exemplo n.º 5
0
 private void Seat8_Click(object sender, EventArgs e)
 {
     if (StateSwap == SwapState.Off)
     {
         if (seat8.BackColor != Color.LightBlue)
         {
             seat1.BackColor = Color.White;
             seat2.BackColor = Color.White;
             seat3.BackColor = Color.White;
             seat4.BackColor = Color.White;
             seat5.BackColor = Color.White;
             seat6.BackColor = Color.White;
             seat7.BackColor = Color.White;
             seat8.BackColor = Color.Yellow;
         }
     }
     else if (StateSwap == SwapState.First)
     {
         seat1.BackColor = Color.White;
         seat2.BackColor = Color.White;
         seat3.BackColor = Color.White;
         seat4.BackColor = Color.White;
         seat5.BackColor = Color.White;
         seat6.BackColor = Color.White;
         seat7.BackColor = Color.White;
         seat8.BackColor = Color.Red;
         firstswap       = 8;
         StateSwap       = SwapState.Second;
     }
     else if (StateSwap == SwapState.Second && seat8.BackColor != Color.Red)
     {
         seat8.BackColor = Color.Green;
         secondswap      = 8;
         Button3_Click(null, null);
     }
 }
 private static SwapMode ModeBySwap(SwapState swap)
 {
     return(swap.IsInitiator
         ? SwapMode.Initiator
         : SwapMode.CounterParty);
 }
Exemplo n.º 7
0
        private void Button3_Click(object sender, EventArgs e)
        {
            //swap
            //first step, select first seat.
            if (StateSwap == SwapState.Off)
            {
                int firstseat  = 0;
                int secondseat = 0;
                button1.Visible = false;
                button2.Visible = false;
                button3.Visible = false;
                button4.Visible = false;
                MessageBox.Show("Swap mode is on, select two seats!");
                StateSwap = SwapState.First;
            }
            else
            {
                StateSwap       = SwapState.Off;
                seat1.BackColor = Color.Yellow;
                seat2.BackColor = Color.White;
                seat3.BackColor = Color.White;
                seat4.BackColor = Color.White;
                seat5.BackColor = Color.White;
                seat6.BackColor = Color.White;
                seat7.BackColor = Color.White;
                seat8.BackColor = Color.White;
                button1.Visible = true;
                button2.Visible = true;
                button3.Visible = true;
                button4.Visible = true;

                try
                {
                    var firstperson = (from f in assignedlist
                                       where f.SeatNumber == firstswap
                                       select f).First();
                    var secondperson = (from f in assignedlist
                                        where f.SeatNumber == secondswap
                                        select f).First();
                    assignedlist.Remove(firstperson);
                    assignedlist.Remove(secondperson);
                    UnassignedList.Add(firstperson);
                    UnassignedList.Add(secondperson);
                    if (AssignSeat(secondswap, firstperson) && AssignSeat(firstswap, secondperson))
                    {
                    }
                    else
                    {
                        //if something goes wrong, assign back to original.
                        AssignSeat(secondswap, secondperson);
                        AssignSeat(firstswap, firstperson);
                        MessageBox.Show("Wait, that's illegal!");
                    }
                    firstswap  = 0;
                    secondswap = 0;
                }
                catch (Exception err)
                {
                    MessageBox.Show("An Error has occured!");
                }
            }
            assignedcomp_label.Text = assignedlist.Count.ToString();
            unassigned_label.Text   = UnassignedList.Count.ToString();
        }
Exemplo n.º 8
0
    private void StartBackwardSwap()
    {
        _currentSwapState = SwapState.Backward;

        PerformBackwardSwap();
    }
Exemplo n.º 9
0
    void Update()
    {
        if (needDrop == true) {
            Droping();
        }

        switch (_state) {
        case (SwapState.Default):
        {
            if (Input.GetMouseButton (0)) {
                var hit = Physics2D.Raycast (Camera.main.ScreenToWorldPoint (Input.mousePosition), Vector2.zero);
                if (hit.collider != null) {
                    _activeCell = hit.collider.GetComponent<CellCtrl> ();
                    _state = SwapState.Swiping;
                }
            }
            break;
        }
        case(SwapState.Swiping):
        {
            if (Input.GetMouseButton (0)) {
                var hit = Physics2D.Raycast (Camera.main.ScreenToWorldPoint (Input.mousePosition), Vector2.zero);
                if (hit.collider != null && _activeCell.gameObject != hit.collider.gameObject) {
                    _passiveCell = hit.collider.GetComponent<CellCtrl> ();
                    if (!_activeCell.AreVerticalOrHorizontalNeighbors(_passiveCell))
                    {
                        _state = SwapState.Default;
                        Restore();
                    }
                    else
                    {
                        _state = SwapState.Updating;

                        StartCoroutine(Swaping());
                    }
                }
            }
            break;

        }
        }
    }
Exemplo n.º 10
0
 void Restore()
 {
     _state = SwapState.Default;
     _activeCell = null;
     _passiveCell = null;
 }
Exemplo n.º 11
0
 void Restore()
 {
     _state       = SwapState.Default;
     _activeCell  = null;
     _passiveCell = null;
 }