Exemple #1
0
 void CmdsetMovementOnUnit(Vector3 pos)
 {
     if (currentlySelectedUnit != null && currentlySelectedUnit.movementLeft > 0)
     {
         currentlySelectedUnit.SetMovement(pos);  //Network this TODO
     }
 }
Exemple #2
0
    public void SelectionCast()
    {
        Ray        myRay = m_Cam.ScreenPointToRay(Input.mousePosition);    //Create a ray from the main camera using the mouse pointer
        RaycastHit hit;

        if (Physics.Raycast(myRay, out hit, selectable))
        {
            Debug.DrawLine(transform.position, hit.point, Color.blue, 10f);
            if (hit.collider.tag == "Grid")
            {
                if (currentlySelectedUnit != null && currentlySelectedUnit.movementLeft > 0)
                {
                    currentlySelectedUnit.SetMovement(hit.point);
                }
            }
            else if (hit.collider.tag == "Player")
            {
                if (currentlySelectedUnit != null)
                {
                    currentlySelectedUnit.deselectedUnit();
                }
                UnitSelection(hit);                  //Attempt to select the unit, or select it
            }
            else if (hit.collider.tag == "Charge")
            {
                if (currentlySelectedUnit != null && !currentlySelectedUnit.chargedDuringAction)
                {
                    currentlySelectedUnit.SendMessage("Charge", hit.transform.position);
                }
            }
            else
            {
                Debug.Log("No logic for " + hit.collider.name.ToString() + " in Select And Move");
            }
        }
    }