//takes in a list of positions //finds tiles int the same postions and adds those to a list //this list is used to go through positions to move Gridtokens one position at a time public void StartCharacterMove(List <Vector2> movePositions) { ResetPanels(); _currTileMoves = new List <Tile>(); for (int i = 0; i < movePositions.Count; i++) { _currTileMoves.Add(_gridTiles[(int)movePositions[i].x, (int)movePositions[i].y]); //Debug.Log(_currTileMoves[i]); } //Debug.Log(_currTileMoves[0].PersonOnMe.name); _currMoveToken = _currTileMoves[0].PersonOnMe; int lasttile = _currTileMoves.Count - 1; _currMoveToken.GetTile = _currTileMoves[lasttile]; _currTileMoves[lasttile].PersonOnMe = _currMoveToken; _currTileMoves[0].PersonOnMe = null; //Debug.Log("before move, " + _currTileMoves.Count); _startTime = Time.time; //DebugBoard(); GameUpdate.ObjectSubscribe += MoveGridToken; }
void AbilityInteract(Ray mouse, RaycastHit point) { if (Physics.Raycast(mouse, out point)) { //if hits something //Debug.Log("hit something"); Collider objCollider = point.collider; if (objCollider.GetComponent <Tile>()) { Tile tile = objCollider.GetComponent <Tile>(); if (tile.IsTargetable && Input.GetMouseButtonDown(0)) { _abilityTarget = new Vector2(tile.GetXPosition, tile.GetYPosition); GridHandler.ShowReleventGrid(_abilityTarget, _selectedAbility.SplashRange, Color.red, Actions.ABILITY); _interactState = UIInteractions.ABILITYUSE; _battleCam.FocusPosition(tile.gameObject, CameraModes.ZOOMING); } } else if (objCollider.GetComponent <GridToken>()) { GridToken gt = objCollider.GetComponent <GridToken>(); if (gt.GetTile.IsTargetable && Input.GetMouseButtonDown(0)) { _abilityTarget = new Vector2(gt.GetTile.GetXPosition, gt.GetTile.GetYPosition); GridHandler.ShowReleventGrid(_abilityTarget, _selectedAbility.SplashRange, Color.red, Actions.ABILITY); _interactState = UIInteractions.ABILITYUSE; _battleCam.FocusPosition(gt.gameObject, CameraModes.ZOOMING); } } } }
public void CreateGridToken() { string color = Token.Color.ToString(); GridToken = ((GameObject)MonoBehaviour.Instantiate(Resources.Load("Prefabs/" + color + "GridToken") as GameObject, Position, Quaternion.identity)).GetComponent <GridToken>(); GridToken.Color = Token.Color; GetCellFromToken.Add(GridToken, this); }
//takes and deletes all gridtokens off of the board void DeleteCharacters() { for (int i = 0; i < _charactersOnField.Count; i = 0) { GridToken currentToken = _charactersOnField[i]; Destroy(currentToken.gameObject); _charactersOnField.RemoveAt(0); } _charactersOnField = new List <GridToken>(); }
//------------------CHARACTER SPAWNING---------------// //spawns in a single Gridtoken for a character public void SpawnEnemy(int xTilePos, int zTilePos) { GameObject newSpawn; newSpawn = Instantiate(_enemyOBJ, _gridTiles[xTilePos, zTilePos].transform.position, Quaternion.identity, null); GridToken tokenref = newSpawn.GetComponent <GridToken>(); tokenref.GetTile = _gridTiles[xTilePos, zTilePos]; _gridTiles[xTilePos, zTilePos].PersonOnMe = tokenref; _charactersOnField.Add(tokenref); }
public void CharacterDoneMoving(GridToken currChar) { if (_timeRef.GetCurrentTurnCharacter.Team == TeamType.PLAYER) { if (!_timeRef.GetCurrentTurnCharacter.CheckForMoreMove(currChar.GetTile.GetXPosition, currChar.GetTile.GetYPosition)) { _interactState = UIInteractions.MOVESELECT; } else { _optionsRef.ShowUI(); _interactState = UIInteractions.MENUOPEN; } } else { _timeRef.GetCurrentTurnCharacter.Strategy.ContinueTurn(); } _battleCam.FocusPosition(currChar.gameObject, CameraModes.MOVING); }
void CheckingCharacter(Ray mouse, RaycastHit point) { if (Physics.Raycast(mouse, out point)) { //if hits something //Debug.Log("hit something"); Collider objCollider = point.collider; if (objCollider.GetComponent <Tile>()) { //hover over tile //set short character UI //Debug.Log("tile hover"); Tile tile = objCollider.GetComponent <Tile>(); if (tile.PersonOnMe != null) { HighlightCharacter(tile); } else { UnHighlightCharacter(); } } else if (objCollider.GetComponent <GridToken>()) { //Debug.Log("character hover"); GridToken gt = objCollider.GetComponent <GridToken>(); HighlightCharacter(gt.GetTile); } } else { //turn off character detail UnHighlightCharacter(); } }
//spawns in player characters //spawns as Gridtokens public void SpawnPlayer(Character newPlayer) { GameObject newSpawn; if (newPlayer.GetType() == typeof(Warrior)) { newSpawn = Instantiate(_warriorOBJ, _gridTiles[_playerStartTiles[0].GetXPosition, _playerStartTiles[0].GetYPosition].transform.position, Quaternion.identity, null); } else { Debug.Log("didnt work"); newSpawn = Instantiate(_warriorOBJ, _gridTiles[_playerStartTiles[0].GetXPosition, _playerStartTiles[0].GetYPosition].transform.position, Quaternion.identity, null); } GridToken tokenref = newSpawn.GetComponent <GridToken>(); tokenref.GetTile = _gridTiles[_playerStartTiles[0].GetXPosition, _playerStartTiles[0].GetYPosition]; _gridTiles[_playerStartTiles[0].GetXPosition, _playerStartTiles[0].GetYPosition].PersonOnMe = tokenref; newPlayer.CurrentPosition = new Vector2(_playerStartTiles[0].GetXPosition, _playerStartTiles[0].GetYPosition); _playerStartTiles.RemoveAt(0); _charactersOnField.Add(tokenref); }
public static void GridTokenClicked(GridToken token) { GridCell cell = GetCellFromToken[token]; cell.OnMouseClicked(); }
void LookingMode(Ray mouse, RaycastHit point) { if (_battleCam.GetCameraMode == CameraModes.FREE && !_optionsRef.IsMoving) { //Debug.DrawRay(ray.origin, ray.direction, Color.black); //Debug.Log("casting"); if (Physics.Raycast(mouse, out point)) { //if hits something //Debug.Log("hit something"); Collider objCollider = point.collider; if (objCollider.GetComponent <Tile>()) { //hover over tile //set short character UI //Debug.Log("tile hover"); Tile tile = objCollider.GetComponent <Tile>(); if (tile.PersonOnMe != null) { if (Input.GetMouseButtonDown(0)) { //if left click //move camera to focus on character ShowActionsMenu(tile); } else if (Input.GetMouseButtonDown(1)) { //if right click //focus and zoom on character //show long detail on right side ShowDetail(tile); } } } else if (objCollider.GetComponent <GridToken>()) { //Debug.Log("character hover"); GridToken gt = objCollider.GetComponent <GridToken>(); if (Input.GetMouseButtonDown(0)) { //if left click //move camera to focus on character ShowActionsMenu(gt.GetTile); } else if (Input.GetMouseButtonDown(1)) { //if right click //focus and zoom on character //show long detail on right side ShowDetail(gt.GetTile); } } } } }