コード例 #1
0
 /// <summary>
 /// 启动
 /// </summary>
 public override void Start()
 {
     if (!IsInit)
     {
         throw new Exception("Socket 没有被初始化或者初始化设置失败");
     }
     try
     {
         IPAddress ipAdress = IPAddress.Parse(Ip);
         _socket = new Socket(ipAdress.AddressFamily, System.Net.Sockets.SocketType.Stream, ProtocolType.Tcp);
         IPEndPoint ipPoint = new IPEndPoint(ipAdress, Port);
         if (IsOpen)
         {
             this.Close();
         }
         //连接服务器
         if (this.ReciveBuffSize != -1)
         {
             _socket.ReceiveBufferSize = this.ReciveBuffSize;
         }
         _socket.Connect(ipPoint);
         LinkEvent?.Invoke(_socket);
         _recMsgThread = new Thread(RecMsg);
         _recMsgThread.IsBackground = true;
         _recMsgThread.Start();
         _isOpen = true;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
    IEnumerator Start()
    {
        NavMeshAgent agent = GetComponent <NavMeshAgent>();

        agent.autoTraverseOffMeshLink = false;
        while (true)
        {
            if (agent.isOnOffMeshLink)
            {
                OnLinkStart?.Invoke();
                if (m_Method == OffMeshLinkMoveMethod.NormalSpeed)
                {
                    yield return(StartCoroutine(NormalSpeed(agent)));
                }
                else if (m_Method == OffMeshLinkMoveMethod.Parabola)
                {
                    yield return(StartCoroutine(Parabola(agent, 2.0f, 0.5f)));
                }
                else if (m_Method == OffMeshLinkMoveMethod.Curve)
                {
                    yield return(StartCoroutine(Curve(agent, 0.5f)));
                }
                agent.CompleteOffMeshLink();
                OnLinkEnd?.Invoke();
            }
            yield return(null);
        }
    }
コード例 #3
0
    void TryAddCardToPath(Card cardClicked, Card previousCardClicked)
    {
        var link = GetLink(cardClicked, previousCardClicked);

        if (link != null)
        {
            cardClicked.Select();
            link.gameObject.SetActive(true);
            selectedCards.Add(cardClicked);
            cardFirstSelected.Invoke(cardClicked);
            LinkActivated.Invoke(link);
            UpdateNearSelectedCard(cardClicked);
        }
    }
コード例 #4
0
    void TryRemoveCardFromPath(Card cardClicked)
    {
        if (selectedCards.LastOrDefault().Equals(cardClicked))
        {
            cardClicked.Unselect();

            var link = default(Link);
            if (selectedCards.Count() == 1)
            {
                link = GetLink(cardClicked, cards.FirstOrDefault(c => c.isPlayer));
                UpdateNearSelectedCard(cards.FirstOrDefault(c => c.isPlayer));
            }
            else
            {
                link = GetLink(cardClicked, selectedCards[selectedCards.Count - 2]);
                UpdateNearSelectedCard(selectedCards[selectedCards.Count - 2]);
            }
            link.gameObject.SetActive(false);
            selectedCards.Remove(cardClicked);
            cardUnselected.Invoke(cardClicked);
            LinkDesactivated.Invoke(link);
        }
    }