public void CityBtnClick(string cityname)
    {
        if ("cancel" == cityname)
        {
            gameObject.SetActive(false);
            btnPanel.SetActive(true);
            return;
        }

        GameObject city = GameObject.Find("/Envi/City/" + cityname);

        if (city == null)
        {
            return;
        }

        curChampion.belongCity.ChampionLeaveCity(curChampion);
        curChampion.SetStatus(Status.OnWay);
        curChampion.SetTarCity(city.transform);
        curChampion.belongCity.fightManager.AddOnWayChampionList(curChampion);
        gameObject.SetActive(false);
        btnPanel.SetActive(true);
    }
示例#2
0
    void HandleTouchEvent()
    {
        foreach (Touch touch in Input.touches)
        {
            switch (touch.phase)
            {
            case TouchPhase.Began:
                //ShowLogTool.ReceiveLog("TouchPhase.Began"+linkSoldier.ToString());
                if (linkSoldier)
                {
                    if (fingerID2Soldier.ContainsKey(touch.fingerId))
                    {
                        fingerID2Soldier.Remove(touch.fingerId);
                    }
                    fingerID2Soldier.Add(touch.fingerId, linkSoldier);
                    //linkSoldier = null;
                }

                if (fingerID2StartPos.ContainsKey(touch.fingerId))
                {
                    fingerID2StartPos.Remove(touch.fingerId);
                }
                fingerID2StartPos.Add(touch.fingerId, touch.position);
                //if (Physics.Raycast(ray, out hit))
                //{
                //    if ((hit.transform.gameObject.tag.IndexOf("red") != -1)||(hit.transform.gameObject.tag.IndexOf("blue") != -1))
                //    {
                //        soldierTrans = hit.transform;


                //    }
                //    else
                //    {
                //        soldierTrans = null;
                //    }
                //}
                //else
                //{
                //    soldierTrans = null;
                //}

                break;

            case TouchPhase.Moved:
                break;

            case TouchPhase.Ended:
                ChampionBehaviour fingerSold = null;
                Vector2           fingerPos  = Vector2.zero;
                if (fingerID2Soldier.ContainsKey(touch.fingerId))
                {
                    fingerSold = fingerID2Soldier[touch.fingerId];
                    fingerID2Soldier.Remove(touch.fingerId);
                }

                if (fingerID2StartPos.ContainsKey(touch.fingerId))
                {
                    fingerPos = fingerID2StartPos[touch.fingerId];
                    fingerID2StartPos.Remove(touch.fingerId);
                }

                //ShowLogTool.ReceiveLog("TouchPhase.Ended"+fingerSold.ToString());
                if (fingerSold != null && fingerPos != Vector2.zero)
                {
                    direction = touch.position - fingerPos;
                    GameObject city = FindTouchCity(fingerSold, touch.position);
                    if (city != null)
                    {
                        fingerSold.belongCity.ChampionLeaveCity(fingerSold);
                        fingerSold.SetStatus(Status.OnWay);
                        fingerSold.GetComponent <ChampionBehaviour>().SetTarCity(city.transform);
                        AddOnWayChampionList(fingerSold);
                    }
                }
                break;
            }
        }
    }