// TODO: remove the double functions at some point since movement is calculated on cost basis... combine the functions // somehow but keep the notion of adding to movement and attack adjacency lists separate private void CheckTile(Vector3 direction, UnitState.ElementalState elementalState) { var halfExtents = new Vector3(0.25f, 0.5f, 0.25f); var colliders = Physics.OverlapBox(transform.position + direction, halfExtents); foreach (var item in colliders) { var tile = item.GetComponent <Tile>(); if (tile != null) { if (!Physics.Raycast(tile.transform.position, Vector3.up, out _, 1)) { adjMovementList.Add(tile); } } } }
public void SetAttackBudget(UnitState.ElementalState elementalState) { switch (elementalState) { default: case UnitState.ElementalState.Grass: _attackBudget = _attackBudgetsPerTileType[0]; break; case UnitState.ElementalState.Water: _attackBudget = _attackBudgetsPerTileType[1]; break; case UnitState.ElementalState.Fire: _attackBudget = _attackBudgetsPerTileType[2]; break; } }
public void CalculateMovementCostsPerTileType(UnitState.ElementalState elementalState) { // ** [0 = Grassland, 1 = Forest, 2 = Lake, 3 = Mountain] ** // ** Use this ^^ when inputting values below for each elemental state ** switch (elementalState) { default: case UnitState.ElementalState.Grass: _movementCostsPerTileType = new float[] { 0.5f, 1.0f, 0.5f, 100.0f }; break; case UnitState.ElementalState.Water: _movementCostsPerTileType = new float[] { 0.5f, 1.0f, 0.25f, 100.0f }; break; case UnitState.ElementalState.Fire: _movementCostsPerTileType = new float[] { 0.5f, 1.0f, 100.0f, 0.25f }; break; } }
private void DealDamage(UnitState.ElementalState playerState) { if (_target != null) { var target = _target.GetComponent <PlayerCombat>(); target.previousHealth = target.health; var targetState = _target.GetComponent <PlayerState>().GetElementalState(); int specialDamageMultiplier = Random.value >= 0.5f ? 6 : 5; int regularDamageMultiplier = Random.value >= 0.5f ? 4 : 3; int smallDamageMultiplier = Random.value >= 0.5f ? 2 : 1; int damage = 1; switch (playerState) { default: case UnitState.ElementalState.Grass: if (targetState == UnitState.ElementalState.Grass) { damage *= regularDamageMultiplier; } else if (targetState == UnitState.ElementalState.Water) { damage *= specialDamageMultiplier; } else { damage *= smallDamageMultiplier; } break; case UnitState.ElementalState.Water: if (targetState == UnitState.ElementalState.Water) { damage *= regularDamageMultiplier; } else if (targetState == UnitState.ElementalState.Fire) { damage *= specialDamageMultiplier; } else { damage *= smallDamageMultiplier; } break; case UnitState.ElementalState.Fire: if (targetState == UnitState.ElementalState.Fire) { damage *= regularDamageMultiplier; } else if (targetState == UnitState.ElementalState.Grass) { damage *= specialDamageMultiplier; } else { damage *= smallDamageMultiplier; } break; } target.health -= damage; if (target.health <= 0) { target.state = CombatState.Dead; if (deathText != null && !deathText.gameObject.activeInHierarchy) { deathText.gameObject.SetActive(true); } } } }