// the response to clicking when in deployment places a cell owned by the current user public void addObject(Vector3 pos) { // find the cell underneath the point we clicked RaycastHit hit; int layerMask = 1 << (int)Layers.TableTile; // if there is an object under the vector if (Physics.Raycast(ray: Camera.main.ScreenPointToRay(pos), hitInfo: out hit, maxDistance: 5, layerMask: layerMask)) { // the id of the cell we clicked on var id = hit.collider.GetComponent <WARActorCell>().id; // add a ship to play with var ship = GameObject.Instantiate( WARToolUnitFinder.GetByArmyUnitName("Shmoogaloo", "ShmooTroop") ).GetComponent <WARUnit>() as WARUnit; ship.owner = WARControlGameplay.CurrentPlayer; WARControlBoard.AddObjectsToCell(id, new List <WARGridObject> { ship as WARGridObject }); // place the ship over the cell //ship.transform.position = WARControlBoard.Grid.GetCell(id).transform.position; // we're done deploying WARGame.SetMode(GAME_MODE.gameplay); } }
public void initBoard(UIPlane plane) { // create a new table with the given plane WARControlBoard.CreateTable(plane); // we're done with the setup mode so move to the deployment mode WARGame.SetMode(GAME_MODE.deployment); }
// when a move order is issued public void moveObject(Vector3 pos) { // find the cell underneath the point we clicked RaycastHit hit; int layerMask = 1 << (int)Layers.TableTile; // if there is an object under the vector if (Physics.Raycast(ray: Camera.main.ScreenPointToRay(pos), hitInfo: out hit, maxDistance: 5, layerMask: layerMask)) { // the id of the cell we clicked on var id = hit.collider.GetComponent <WARActorCell>().id; // add the current selected objects to a list if the current player owns them var list = WARControlSelection.Selection .Where(obj => (obj as WARUnit).owner == WARControlGameplay.CurrentPlayer) .ToList(); // if we own any selected objects if (list.Count > 0) { // move the list of objects to the right cell WARControlBoard.MoveObjectsToCell(id, list); } } }