using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace LP.FDG.InputManager
{
public class InputHandler : MonoBehaviour
{
public static InputHandler instance;
private RaycastHit hit; //what we hit with our ray
private List<Transform> selectedUnits = new List<Transform>();
// Start is called before the first frame update
void Start()
{
instance = this;
}
// Update is called once per frame
void Update()
{
}
public void HandleUnitMovement()
{
if(Input.GetMouseButtonDown(1))
{
Debug.Log("Right Clicked");
}
if(Input.GetMouseButtonDown(0)) // 0 left 1 right click
{
Debug.Log("Clicked");
//Create a Ray
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
// Check if we hit somthing
if (Physics.Raycast(ray,out hit))
{
//if we do , then do something with that data
LayerMask layerHit = hit.transform.gameObject.layer;
switch (layerHit.value)
{
case 8: // Units Layer
//do something
// click leftShift to MultiSelect
//if it down(Click) We 're gonna send true ,if not be false
SelectUnit(hit.transform);
break;
default: //if none of the above happens
//do something
// DeselectUnits();
break;
}
}
}
}
private void SelectUnit(Transform unit)
{
// if(!canMultiselect)//if we cant multiSelect
// {
// DeselectUnits(); //Deselect first before select unit
// }
selectedUnits.Add(unit);
//lets set an obj on the unit called Highlight
unit.Find("Highlight").gameObject.SetActive(true);
}
}
}
-
Notifications
You must be signed in to change notification settings - Fork 0
MarioCastle/Share
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published