Beispiel #1
0
 // Use this for initialization
 void Start()
 {
     //Shader shader = GetComponent<Shader>();
     //switch (currentCityType)
     //{
     //    case CityType.Player:
     //        shader.material = City.playerMaterial;
     //        newMaterialRef = City.playerMaterial;
     //        break;
     //    case CityType.AI:
     //        shader.material = City.aiMaterial;
     //        newMaterialRef = City.aiMaterial;
     //        break;
     //    case CityType.Robot:
     //        shader.material = City.robotMaterial;
     //        newMaterialRef = City.robotMaterial;
     //        break;
     //}
     agent = GetComponent <NavMeshAgent>();
     lr    = GetComponentInChildren <LineRenderer> ();
     if (currentCityType == Team.Blue)
     {
         SatTruck.RegisterSelf(this);
     }
 }
Beispiel #2
0
 public void SelectTruck(int i)
 {
     if (selected)
     {
         selected.OnUnselect();
     }
     selected = SatTruck.GetTruck(i);
     selected.OnSelect();
 }
 void Update()
 {
     if (!reg)
     {
         reg = SatTruck.RegisterHotkey(unitNum, this);
     }
     else
     {
         enabled = false;
     }
 }
 void Start()
 {
     reg = SatTruck.RegisterHotkey(unitNum, this);
     img = GetComponent <Image> ();
 }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        Vector2 mousePos = Input.mousePosition;        //ScreenMouse.GetScreenMousePosition();

        //Debug.Log(mousePos);
        if (cursor)
        {
            cursor.rectTransform.position = mousePos;            //new Vector3(mousePos.x-cursorOffset.x,mousePos.y-cursorOffset.y,0);
        }
        //On Mouse Click
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;

            /*
             * if (!gr) {
             *      gr = GetComponentInChildren<GraphicRaycaster> ();
             * } else {
             *      //Set up a fake UI Event call
             *      //this was necessary for the CRT menu and can be removed now.
             *      //this lets us force events through the tv
             *      PointerEventData ped = new PointerEventData (eventSystem);
             *      ped.position = mousePos;
             *
             *      List<RaycastResult> results = new List<RaycastResult>();
             *      gr.Raycast (ped,results);
             *
             *
             *      foreach (RaycastResult r in results) {
             *              Button b = r.gameObject.GetComponent<Button> ();
             *
             *              if (b) {
             *                      if(selected)
             *                              selected.OnUnselect();
             *                      b.OnPointerClick (ped);
             *
             *              }
             *              Debug.Log (r.gameObject.name);
             *      }
             * }
             */
            if (cam == null)
            {
                cam = Camera.main;
            }
            //raycast to see what we hit
            if (Physics.Raycast(cam.ScreenPointToRay(mousePos), out hit))
            {
                Debug.Log(hit.collider.gameObject.name);

                SatTruck stTest = hit.collider.gameObject.GetComponentInParent <SatTruck> ();
                //if it is a SatTruck, Select it
                if (stTest != null && stTest.currentCityType.Equals(Team.Blue))
                {
                    if (selected)
                    {
                        selected.OnUnselect();
                    }
                    selected = stTest;
                    selected.OnSelect();
                }
                lastMousePos = mousePos;
            }
            //else if we are holding down the mouse Button
        }
        else if (Input.GetMouseButton(0))
        {
            Vector2 delta = mousePos - lastMousePos;
            transform.localPosition += new Vector3(-delta.x, 0, -delta.y);
            lastMousePos             = mousePos;
            //else if we right click
        }
        else if (Input.GetMouseButtonDown(1) && selected != null)
        {
            //Debug.Log ("Right Click");
            RaycastHit hit;
            if (Physics.Raycast(cam.ScreenPointToRay(mousePos), out hit))
            {
                //Debug.Log ("raycasted succes");
                if (hit.collider.gameObject.name.Equals("Ground"))
                {
                    selected.SetDestination(hit.point);
                    Debug.Log("Destination:" + hit.point);
                }
            }
        }
    }
Beispiel #6
0
 public static int RegisterSelf(SatTruck st)
 {
     allSats.Add(st);
     return(allSats.Count - 1);
 }