public void beginAttacking() { //create enemy tiles hub.MakeTiles("EnemyTile"); //set cursor flag to know it needs to attack hub.cursor.attacking = true; hub.cursor.cursorCanMove = true; removeMenu(); }
/* * This function will see if there is a character to select * It is implied that when you get to this call you have tried selecting something * */ void DetectSelect() { Character c = hub.findCharacterAt((Vector2)transform.position); //if you hit a character, and you can select something if (c != null && canSelect) { //if its that characters turn if (c.playerNumber == turn.playerTurn) { //if they can still move if (c.canMove) { //select them with the cursor selectedCharacter = c; canSelect = false; charOrgX = selectedCharacter.transform.position.x; charOrgY = selectedCharacter.transform.position.y; } //if theyre a summoner, give them the chance to summon even if they cannot move else if (c.name == "Summoner" && hub.canSummon()) { cursorCanMove = false; ArrayList list = new ArrayList(); list.Add("Summon"); Vector3 pos = transform.position + new Vector3(2 * spacer, spacer, 0); hub.moveMenuHandler.MakeMoveMenu(list, pos); } } } if (!canSelect) { //if you select a character, put down move tiles //put down the places this char can move //save the original cooridinates incase we cancel the movement orgX /= spacer; orgY /= spacer; int oX = realRound(orgX); int oY = realRound(orgY); //print("Character is at: " + oX + " , " + oY); //displays all of the possible spaces that character can move to hub.FindMoveTile(selectedCharacter.move, oX, oY, selectedCharacter, false); hub.MakeTiles("MoveTile"); } }
void SummonCharacter(Character c) { //set this menu's canMove flag. canMove = false; //set the other can move flags. hub.moveMenuHandler.canMove = false; //make an instance of this character GameObject createdCharacter = (GameObject)GameObject.Instantiate(Resources.Load("Prefab/Characters/Units/" + c.name)); createdCharacter.GetComponent <Character>().CreateCharacter(); hub.getCurrentSummoner().mana -= c.cost; //make tiles showing where they can summon hub.MakeTiles("SummonTile"); //put that character onto the cursor hub.cursor.MoveTo((Vector2)hub.summonPositions[0]); createdCharacter.transform.position = hub.cursor.transform.position; //tell the cursor to stop caring about the summoner (if it did) if (hub.cursor.selectedCharacter != null) { hub.cursor.selectedCharacter.canMove = false; hub.cursor.selectedCharacter = null; } //assign the cursor to the character hub.cursor.canSelect = false; hub.cursor.summoning = true; hub.cursor.selectedCharacter = createdCharacter.GetComponent <Character>(); //let Confirm button place the character and delete the tiles(done in cursor) //move the camera hub.cam.moveCamera(hub.cursor.transform.position); hub.cam.toggleChildren(true); hub.cursor.confirmFromMoveMenu(); hub.moveMenuHandler.removeMenu(); }