示例#1
0
        public float ObtainRadius(TutorialUnit unit)
        {
            if (unit == null)
            {
                return(0f);
            }
            Renderer renderer = unit.GetComponent <Renderer>();

            return(renderer.bounds.extents.magnitude / 2f);
        }
 void Start()
 {
     this.unit            = this.GetComponent <TutorialUnit>();
     this.targets         = new List <GameObject>();
     this.removeList      = new List <GameObject>();
     this.canExamineArea  = false;
     this.isOrderedToMove = false;
     if (this.attackManager == null)
     {
         Debug.LogError("Cannot find attack manager.");
     }
 }
 protected override void SelectOrder()
 {
     if (!this.selectionTutorialFlag)
     {
         return;
     }
     //if (this.attackStandingByFlag) {
     //	return;
     //}
     if (Input.GetMouseButtonDown(0))
     {
         if (this.selectedObjects.Count > 0)
         {
             foreach (GameObject obj in this.selectedObjects)
             {
                 TutorialUnit unit = obj.GetComponent <TutorialUnit>();
                 unit.SetDeselect();
             }
             this.selectedObjects.Clear();
         }
         Ray          ray        = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit[] hits       = Physics.RaycastAll(ray);
         bool         hasHitUnit = false;
         foreach (RaycastHit hit in hits)
         {
             GameObject obj = hit.collider.gameObject;
             if (obj.tag.Equals("Tutorial_Unit"))                         //<-----------  Fill in the unit's tag name here from the editor.
             {
                 hasHitUnit = true;
                 if (!this.selectedObjects.Contains(obj))
                 {
                     TutorialUnit unit = obj.GetComponent <TutorialUnit>();
                     unit.SetSelect();
                     this.selectedObjects.Add(obj);
                 }
                 break;
             }
         }
         if (!hasHitUnit)
         {
             this.selectedObjects.Clear();
         }
     }
     if (Input.GetMouseButton(0))
     {
         foreach (GameObject obj in this.unitManager.getAllObjects())
         {
             if (obj == null)
             {
                 this.unitManager.getRemoveList().Add(obj);
                 continue;
             }
             Vector2 screenPoint = Camera.main.WorldToScreenPoint(obj.transform.position);
             screenPoint.y = Screen.height - screenPoint.y;
             if (Selection.selectionArea.Contains(screenPoint) && !this.boxSelectedObjects.Contains(obj))
             {
                 this.boxSelectedObjects.Add(obj);
                 if (!this.selectedObjects.Contains(obj))
                 {
                     this.selectedObjects.Add(obj);
                 }
                 TutorialUnit unit = obj.GetComponent <TutorialUnit>();
                 unit.SetSelect();
             }
             else if (!Selection.selectionArea.Contains(screenPoint) && this.boxSelectedObjects.Contains(obj))
             {
                 this.boxSelectedObjects.Remove(obj);
                 if (this.selectedObjects.Contains(obj))
                 {
                     this.selectedObjects.Remove(obj);
                 }
                 TutorialUnit unit = obj.GetComponent <TutorialUnit>();
                 unit.SetDeselect();
             }
         }
     }
     if (Input.GetMouseButtonUp(0))
     {
         if (this.boxSelectedObjects.Count > 0)
         {
             foreach (GameObject obj in this.boxSelectedObjects)
             {
                 if (!this.selectedObjects.Contains(obj))
                 {
                     TutorialUnit unit = obj.GetComponent <TutorialUnit>();
                     unit.SetSelect();
                     this.selectedObjects.Add(obj);
                 }
             }
             this.boxSelectedObjects.Clear();
         }
     }
 }