void CastTeleport(FighterComponent casterFighter, PositionComponent positionComponent, string abDesc) { Vector2 moveDir = new Vector2(positionComponent.directionData.X, positionComponent.directionData.Y) * 2; //Vector2 curDest = new Vector2(positionComponent.moveData.X, positionComponent.moveData.Y) + moveDir; //if (MapManager.instance.CanMoveTo(new MoveData(curDest.x, curDest.y)) == false){ // // try normal move // if MapManager.instance.CanMoveTo(new MoveData(curDest.x, curDest.y)) == false) // { // return; // } //} //positionComponent.moveData = new MoveData(positionComponent.moveData.) // Caster takes 40% of its health float dmg = casterFighter.curHP * 0.40f; casterFighter.ReceiveDamage(dmg); MessageLog_Manager.NewMessage(abDesc, Color.green); MoveData destData = new MoveData(moveDir.x, moveDir.y); positionComponent.Move(destData, true); }
/// <summary> /// Handle entity combat. /// Return true if combat resulted in defender's death /// and attacker is allowed to move unto that tile. /// </summary> /// <param name="attacker"></param> /// <param name="defender"></param> /// <returns></returns> private bool DoCombat(FighterComponent attacker, FighterComponent defender) { int attackPower = attacker.GetAttackPower(); // Debug.Log("Attacker attacks with power " + attackPower); //Debug.Log("Defender defends with power " + defender.GetDefensePower()); //if (attacker.thisEntity.isPlayer == true) //{ // MessageLog_Manager.NewMessage("You attack the " + defender.thisEntity.Name + " with " + attackPower + " attack!", Color.red); //} int damage = attackPower - defender.GetDefensePower(); //Debug.Log("After defense mitigation... damage is " + damage); if (damage > 0) { if (defender.thisEntity.isPlayer == true) { cameraShaker.AddTrauma(5.2f, 2.8f); MessageLog_Manager.NewMessage(attacker.thisEntity.Name + " hits you for " + damage.ToString() + "!", Color.white); } else { MessageLog_Manager.NewMessage("You hit the " + defender.thisEntity.Name + " for " + damage.ToString() + "!", Color.red); } } else { if (attacker.thisEntity.isPlayer == true) { MessageLog_Manager.NewMessage(defender.thisEntity.Name + "'s defense absorb your attack!", Color.white); } else { MessageLog_Manager.NewMessage("Your defenses absorb the attack!", Color.white); } } bool result = defender.ReceiveDamage(damage); if (result == true) { if (attacker.thisEntity.isPlayer == true) { MessageLog_Manager.NewMessage(defender.thisEntity.Name + " DIES!", Color.red); // Gain xp for kill XPComponent xPComponent = (XPComponent)attacker.thisEntity.GetEntityComponent(ComponentID.XP); EnemyComponent enemy = (EnemyComponent)defender.thisEntity.GetEntityComponent(ComponentID.AI); XPSystem.instance.DoXPGainAction(xPComponent.xpData, enemy.enemyLevel); } else { MessageLog_Manager.NewMessage(attacker.thisEntity.Name + " KILLS YOU!", Color.red); } } return(result); }
void CastBloodForLight(FighterComponent casterFighter, MoveData position, MoveData direction, string abDesc) { if (MapManager.instance.ClearDarkTile(new Vector2(position.X + direction.X, position.Y + direction.Y)) == false) { return; } // Caster takes 25% of its health float dmg = casterFighter.curHP * 0.25f; casterFighter.ReceiveDamage(dmg); MessageLog_Manager.NewMessage(abDesc, Color.green); }
/// <summary> /// Returns true if Entity can move to next tile, /// if false it will call the correct action to do /// </summary> /// <param name="entity"></param> /// <param name="lastPositionData"></param> /// <param name="newPositionData"></param> /// <returns></returns> public bool DoTileAction(Entity entity, MoveData lastPositionData, MoveData newPositionData) { MapTile curTile = mapManager.Map.GetTile(new Vector2(lastPositionData.X, lastPositionData.Y)); if (curTile == null) { Debug.LogError("Entity: " + entity.Name + " is standing on a NULL TILE!!"); return(false); } MapTile nextTile = mapManager.Map.GetTile(new Vector2(newPositionData.X, newPositionData.Y)); if (nextTile == null) { Debug.LogError("Entity: " + entity.Name + " is moving to a NULL TILE!!"); return(false); } if (nextTile.entities.Count > 0) { if (InteractTileEntities(entity, nextTile) == false) { // check if this can end turn //if (entity.CanEndTurnCB != null) //{ // if (entity.CanEndTurnCB() == true) // { // TurnManager.instance.FinishTurn(); // } //} return(false); } } // DARKNESS DAMAGE if (curTile.tileType == TileType.Darkness) { FighterComponent attacker = (FighterComponent)entity.GetEntityComponent(ComponentID.Fighter); attacker.ReceiveDamage(1000, true); return(false); } // Normal move action happens if (nextTile != curTile) { curTile.UnRegisterEntity(entity); nextTile.RegisterEntity(entity); if (entity.isPlayer == true && nextTile.tileType == TileType.Exit) { Global.PlayerReachedExit playerReachedExit = new Global.PlayerReachedExit(); playerReachedExit.exitPosition = nextTile.WorldPosition; playerReachedExit.FireEvent(); return(false); } } // check if this can end turn //if (entity.CanEndTurnCB != null) //{ // if (entity.CanEndTurnCB() == true) // { // TurnManager.instance.FinishTurn(); // } //} return(true); }