Exemplo n.º 1
0
 public void _Hide()
 {
     if (UI.UseDragNDrop())
     {
         return;
     }
     BuildManager.ClearBuildPoint();
     isOn = false;
     gameObject.SetActive(isOn);
 }
Exemplo n.º 2
0
        public void _Hide()
        {
            if (UI.UseDragNDrop() && !FPSControl.IsOn())
            {
                return;
            }

            BuildManager.ClearBuildPoint();

            isOn = false;
            thisObj.SetActive(isOn);
        }
Exemplo n.º 3
0
        public IEnumerator DragNDropRoutine()
        {
            GameControl.SelectTower(this);
            yield return(null);

#if (UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY) && !UNITY_EDITOR
            _TileStatus status = _TileStatus.NoPlatform;
            while (Input.touchCount >= 1)
            {
                Vector3 pos = Input.touches[0].position;

                status = BuildManager.CheckBuildPoint(pos, -1, prefabID);

                if (status == _TileStatus.Available)
                {
                    BuildInfo buildInfo = BuildManager.GetBuildInfo();
                    thisT.position = buildInfo.position;
                    thisT.rotation = buildInfo.platform.thisT.rotation;
                }
                else
                {
                    Ray        ray = Camera.main.ScreenPointToRay(pos);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                    {
                        thisT.position = hit.point;
                    }
                    //this there is no collier, randomly place it 30unit from camera
                    else
                    {
                        thisT.position = ray.GetPoint(30);
                    }
                }

                if (Input.touches[0].phase == TouchPhase.Ended)
                {
                    //if current mouse point position is valid, build the tower
                    if (status == _TileStatus.Available)
                    {
                        bool exception = BuildManager.BuildTower(srcTower);
                        if (exception == false)
                        {
                            GameControl.DisplayMessage("Can't build tower");
                        }
                    }
                    else
                    {
                        BuildManager.ClearBuildPoint();
                    }
                    break;
                }

                yield return(null);
            }
            GameControl.ClearSelectedTower();
#else
            while (true)
            {
                Vector3     pos    = Input.mousePosition;
                _TileStatus status = BuildManager.CheckBuildPoint(pos, -1, prefabID);
                if (status == _TileStatus.Available)
                {
                    BuildInfo buildInfo = BuildManager.GetBuildInfo();
                    thisT.position = buildInfo.position;
                    thisT.rotation = buildInfo.platform.thisT.rotation;
                }
                else
                {
                    Ray        ray = Camera.main.ScreenPointToRay(pos);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                    {
                        thisT.position = hit.point;
                    }
                    //this there is no collier, randomly place it 30unit from camera
                    else
                    {
                        thisT.position = ray.GetPoint(30);
                    }
                }

                //left-click, build
                if (Input.GetMouseButtonDown(0) && !UIUtilities.IsCursorOnUI())
                {
                    //if current mouse point position is valid, build the tower
                    if (status == _TileStatus.Available)
                    {
                        bool exception = BuildManager.BuildTower(srcTower);
                        if (exception == false)
                        {
                            GameControl.DisplayMessage("Can't build tower");
                        }
                    }
                    else
                    {
                        BuildManager.ClearBuildPoint();
                    }
                    GameControl.ClearSelectedTower();
                    thisObj.SetActive(false);
                    break;
                }
                //right-click, cancel
                if (Input.GetMouseButtonDown(1) || GameControl.GetGameState() == _GameState.Over)
                {
                    GameControl.ClearSelectedTower();
                    BuildManager.ClearBuildPoint();
                    thisObj.SetActive(false);
                    break;
                }
                yield return(null);
            }
#endif
            thisObj.SetActive(false);
            thisT.position = new Vector3(0, 9999, 0);
            BuildManager.ShowPlatform(false);
        }
Exemplo n.º 4
0
        public IEnumerator DragNDropRoutine()
        {
            GameControl.SelectTower(this);
            yield return(null);

            while (true)
            {
                Vector3 pos = Input.mousePosition;

                _TileStatus status = BuildManager.CheckBuildPoint(pos, -1, prefabID);

                if (status == _TileStatus.Available)
                {
                    BuildInfo buildInfo = BuildManager.GetBuildInfo();
                    thisT.position = buildInfo.position;
                    thisT.rotation = buildInfo.platform.thisT.rotation;
                }
                else
                {
                    Ray        ray = Camera.main.ScreenPointToRay(pos);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                    {
                        thisT.position = hit.point;
                    }
                    //this there is no collier, randomly place it 30unit from camera
                    else
                    {
                        thisT.position = ray.GetPoint(30);
                    }
                }


                //left-click, build
                if (Input.GetMouseButtonDown(0) && !UIUtilities.IsCursorOnUI())
                {
                    //if current mouse point position is valid, build the tower
                    if (status == _TileStatus.Available)
                    {
                        string exception = BuildManager.BuildTower(srcTower);
                        if (exception != "")
                        {
                            GameControl.DisplayMessage(exception);
                        }
                    }
                    else
                    {
                        BuildManager.ClearBuildPoint();
                    }
                    GameControl.ClearSelectedTower();
                    thisObj.SetActive(false);
                    break;
                }

                //right-click, cancel
                if (Input.GetMouseButtonDown(1) || GameControl.GetGameState() == _GameState.Over)
                {
                    GameControl.ClearSelectedTower();
                    BuildManager.ClearBuildPoint();
                    thisObj.SetActive(false);
                    break;
                }

                yield return(null);
            }

            thisT.position = new Vector3(0, 9999, 0);
        }