//private GUIContent[] contList;
		
		
		void Awake(){
			instance = (CameraControl)target;
			
			
			
			EditorUtility.SetDirty(instance);
		}
Пример #2
0
		void Awake(){
			thisT=transform;
			
			instance=this;
			
			//cam=Camera.main;
			camT=Camera.main.transform;
		}
Пример #3
0
 public override void Awake()
 {
     base.Awake();
     instance = (CameraControl)target;
 }
Пример #4
0
        public static SelectInfo GetSelectInfo(Vector3 pointer, int ID = -1, float towerSize = 1)
        {
            InitMask();

            Ray        ray = CameraControl.GetMainCam().ScreenPointToRay(pointer);
            RaycastHit hit;

            //for free from drag and drop mode
            if (UseFreeFormMode() && instance.dndTower != null)
            {
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, maskTerrain))
                {
                    Collider[] obstacles = Physics.OverlapSphere(hit.point, towerSize, ~maskTerrain);
                    if (obstacles.Length == 1 && obstacles[0].gameObject == instance.dndTower.gameObject)
                    {
                        obstacles = new Collider[0];
                    }

                    if (obstacles.Length == 0)
                    {
                        return(new SelectInfo(hit.point));
                    }
                    else
                    {
                        return(new SelectInfo("Invalid build-point!", hit.point));
                    }
                }
                return(new SelectInfo("No valid build-point has been found"));
            }

            //try to detect a platform and determine the node on it
            bool flag = Physics.Raycast(ray, out hit, Mathf.Infinity, RaycastForTerrain() ? mask : maskPlatform);

            if (flag)
            {
                if (hit.collider.gameObject.layer == TDTK.GetLayerPlatform())
                {
                    BuildPlatform platform = hit.collider.gameObject.GetComponent <BuildPlatform>();
                    if (platform != null)
                    {
                        Vector3 pos  = platform.GetTilePos(hit.point, GetGridSize());
                        NodeTD  node = platform.GetNearestNode(pos);

                        if (ID > 0)
                        {
                            if (lastSelectID == ID && sInfo.nodeID == node.ID)
                            {
                                return(sInfo);
                            }
                            else
                            {
                                lastSelectID = ID;
                            }
                        }

                        return(new SelectInfo(platform, node.ID));
                    }
                }
                else if (RaycastForTerrain())
                {
                    return(new SelectInfo("No platform has been found", hit.point));
                }
            }

            return(new SelectInfo("No platform has been found"));
        }