private void DoTheSkill(bool toTheRight) { List <GameObject> hexesTargetedByThisSkill = FindHexesAvailableForSkill(); GameObject fenrir = turnManager.GetCharacterInTurn(); Stats fenrirStats = fenrir.GetComponent <Stats>(); SpriteRenderer fenrirSprite = fenrir.GetComponent <SpriteRenderer>(); Animator fenrirAnimator = fenrir.GetComponent <Animator>(); fenrirStats.currentSoulPoints -= 8; fenrirStats.currentActionPoints -= 2; turnManager.UpdateCombatUIValues(nextTurn: false); foreach (GameObject hexTargeted in hexesTargetedByThisSkill) { if (toTheRight) { fenrirSprite.flipX = false; if (hexTargeted.transform.position.x > fenrir.transform.position.x) { HexProperties hexProperties = hexTargeted.GetComponent <HexProperties>(); if (hexProperties.CharacterInHex != null) { if (hexProperties.CharacterInHex.tag == "Enemy") { Stats enemyStats = hexProperties.CharacterInHex.GetComponent <Stats>(); int damage = Random.Range(1, 5); damage += fenrirStats.strength; enemyStats.currentHealthPoints -= damage; combatAnimationManager.TakeDamage(enemyStats.gameObject.GetComponent <Animator>()); } } } } else { fenrirSprite.flipX = true; if (hexTargeted.transform.position.x < fenrir.transform.position.x) { HexProperties hexProperties = hexTargeted.GetComponent <HexProperties>(); if (hexProperties.CharacterInHex != null) { if (hexProperties.CharacterInHex.tag == "Enemy") { Stats enemyStats = hexProperties.CharacterInHex.GetComponent <Stats>(); int damage = Random.Range(1, 5); damage += fenrirStats.strength; enemyStats.currentHealthPoints -= damage; combatAnimationManager.TakeDamage(enemyStats.gameObject.GetComponent <Animator>()); } } } } } combatAnimationManager.FenrirSkill01Animation(fenrirAnimator); }
public void ClearAllHexes() { List <GameObject> gridHexesObjects = mapGenerator.gridHexesObjects; foreach (GameObject hex in gridHexesObjects) { hex.GetComponentsInChildren <SpriteRenderer>()[0].color = Color.white; HexProperties hexProperties = hex.GetComponent <HexProperties>(); hexProperties.canMove = false; hexProperties.canAttack = false; hexProperties.canSkill = false; } }
private void InstantiateHex(float xPosition, float yPosition, float zPosition, int row, int column, bool initialHex) { Vector3 hexPosition = new Vector3(xPosition, yPosition, zPosition); Vector3 hexRotation = new Vector3(60f, 0f, 0f); GameObject hexObject = Instantiate(hexPrefab, hexPosition, Quaternion.Euler(hexRotation)); gridHexesPositions.Add(hexPosition); hexObject.name = "Hex (" + row + "," + column + ")" + " (" + gridHexesPositions.Count + ") "; HexProperties hexProperties = hexObject.GetComponent <HexProperties>(); hexProperties.initialHex = initialHex; hexProperties.row = row; hexProperties.column = column; gridHexesObjects.Add(hexObject); }
private void HighlightHexToMove() { RaycastHit hit = MousePositionToRaycastHit(hexLayer); if (hit.collider != null) { if (hit.collider.gameObject.tag == "Hex") { if (hit.collider.gameObject != currentHex) { previousHex = currentHex; currentHex = hit.collider.gameObject; } HexProperties currentHexProperties = currentHex.GetComponent <HexProperties>(); if (currentHexProperties.canMove && currentHexProperties.CharacterInHex == null) { currentHex.GetComponentInChildren <SpriteRenderer>().color = Color.red; //combatAnimationManager.TurnTowardsTarget(turnManager.GetCharacterInTurn(), currentHex); if (Input.GetMouseButtonDown(0)) { characterMover.MoveToNewPosition(); } } else { currentHex.GetComponentInChildren <SpriteRenderer>().color = Color.white; } if (previousHex != null) { if (previousHex.GetComponent <HexProperties>().canMove) { previousHex.GetComponentInChildren <SpriteRenderer>().color = Color.yellow; } else { previousHex.GetComponentInChildren <SpriteRenderer>().color = Color.white; } } } } }
private void Update() { if (markedCharacter != null) { RaycastHit hit = HitHexes(); if (hit.collider != null) { if (hit.collider.gameObject.tag == "Hex") { GameObject hex = hit.collider.gameObject; if (previousHex != null) { previousHex.GetComponentsInChildren <SpriteRenderer>()[0].color = Color.white; previousHex.GetComponent <HexProperties>().CharacterInHex = null; } if (hit.collider.gameObject.GetComponent <HexProperties>().initialHex) { //Debug.Log("Segue o mouse"); markedCharacter.transform.position = hit.collider.gameObject.transform.position; markedCharacter.GetComponent <SpriteRenderer>().color = Color.green; hex.GetComponentsInChildren <SpriteRenderer>()[0].color = Color.green; previousHex = hit.collider.gameObject; characterAtValidPosition = true; } else { markedCharacter.transform.position = hit.collider.gameObject.transform.position; markedCharacter.GetComponent <SpriteRenderer>().color = Color.red; hex.GetComponentsInChildren <SpriteRenderer>()[0].color = Color.red; previousHex = hit.collider.gameObject; characterAtValidPosition = false; } } else { Debug.Log("No Hex here"); } } if (Input.GetMouseButtonDown(0)) { HexProperties hexProperties = previousHex.GetComponent <HexProperties>(); if (characterAtValidPosition && hexProperties.CharacterInHex == false) { Debug.Log("cancela"); markedCharacter.GetComponent <SpriteRenderer>().color = Color.white; previousHex.GetComponentsInChildren <SpriteRenderer>()[0].color = Color.white; previousHex.GetComponent <HexProperties>().CharacterInHex = markedCharacter; markedCharacter = null; } else { Debug.Log("nao da pra soltar aqui!"); } } } else { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, Mathf.Infinity, characterLayer)) { if (hit.collider.gameObject.tag == "Player") { markedCharacter = hit.collider.gameObject; markedCharacter.GetComponent <SpriteRenderer>().color = Color.green; } } } } }