public override IEnumerable <IActionEffect> Execute() { ActorData.Items.Remove(ItemToDrop); ItemToDrop.LogicalPosition = ActorData.LogicalPosition; yield return(ActionEffectFactory.CreateLambdaEffect(() => { ItemToDrop.Entity.RefreshWorldPosition(); ItemToDrop.Entity.Show(); })); }
public override IEnumerable <IActionEffect> Execute() { ActorData activeActor = ActorData; var activeActorPositionBefore = activeActor.LogicalPosition; var displacedActorPositionBefore = DisplacedActor.LogicalPosition; activeActor.LogicalPosition = displacedActorPositionBefore; DisplacedActor.LogicalPosition = activeActorPositionBefore; yield return(ActionEffectFactory.CreateMoveEffect(activeActor, activeActorPositionBefore)); yield return(ActionEffectFactory.CreateMoveEffect(DisplacedActor, displacedActorPositionBefore)); }
public override IEnumerable <IActionEffect> Execute() { Vector2Int previousPosition = ActorData.LogicalPosition; Vector2Int newPosition = previousPosition + Direction; if (_gridInfoProvider.IsWalkable(newPosition)) { if (ActorData.ActorType == ActorType.Player && _gameContext.EnvironmentTilemap.HasTile(newPosition.ToVector3Int())) { TileBase stairsDownTile = Resources.Load <TileBase>("Tiles/Environment/Stairs_down"); if (_gameContext.EnvironmentTilemap.GetTile(newPosition.ToVector3Int()) == stairsDownTile) { _textEffectPresenter.ShowTextEffect(ActorData.LogicalPosition, "Back down? Never!", Color.yellow); } } if (_gameContext.BasherSteps == 0 && ActorData.ActorType == ActorType.Basher && Vector2IntUtilities.WalkDistance(ActorData.LogicalPosition, _gameContext.PlayerActor.ActorData.LogicalPosition) <= 5) { _gameContext.BasherSteps = 1; _uiConfig.BasherMessage.gameObject.SetActive(true); _uiConfig.BasherMessage.SetMessage("Ha! So you didn't disappoint me! Finally I see you again, my rattish friend! As you might " + "have guessed, that was me that sent you the key. I'll be happy to take you away from this scary place. But first " + "we have to deal with one thing. You saved my life by attributing to yourself my deeds against the revolutionists. " + "But this also made me feel like a lousy coward. My honour has been terribly undermined and I need to clean it. " + "I challenge you to a duel! No magic, no eating, just me, you and steel. Prepare!"); IEnumerable <ActorData> friendsAndBuddies = _entityDetector.DetectActors(ActorData.LogicalPosition, 15) .Where(a => a.ActorType == ActorType.Friend || a.ActorType == ActorType.Buddy); foreach (var friendOrBuddy in friendsAndBuddies) { _deathHandler.HandleDeath(friendOrBuddy); } } IActionEffect effect = ActionEffectFactory.CreateMoveEffect(ActorData, previousPosition); ActorData.LogicalPosition = newPosition; if (ActorData.CaughtActor != null) { ActorData.CaughtActor.LogicalPosition = newPosition; } yield return(effect); } else { IActionEffect effect = ActionEffectFactory.CreateBumpEffect(ActorData, newPosition); yield return(effect); } }
public override IEnumerable <IActionEffect> Execute() { float chanceToDealAccurateBlow = ActorData.Accuracy; bool accurate = _rng.Check(chanceToDealAccurateBlow); if (_isDaringBlow) { ActorData.Swords -= 2; } bool hit = (_isDaringBlow || _attackedActor.Swords <= 0) && accurate; if (hit) { int damage = Math.Max(_rng.Next(ActorData.WeaponWeld.WeaponDefinition.MaxDamage + 1), _rng.Next(ActorData.WeaponWeld.WeaponDefinition.MaxDamage + 1)); _attackedActor.Health -= damage; if (_attackedActor.Health <= 0) { _deathHandler.HandleDeath(_attackedActor); ActorData.Xp += _attackedActor.XpGiven; } if (_attackedActor.ActorType == ActorType.Basher && ActorData.ActorType == ActorType.Player && _attackedActor.HealthProgress < 0.5f) { _uiConfig.BasherMessage.gameObject.SetActive(true); _uiConfig.BasherMessage.GetComponent <RectTransform>().sizeDelta = new Vector3(560, 180); _uiConfig.BasherMessage.SetMessage("Ouch! Enough for me! That was a satisfactory duel. My reputation is clean now. Thank you! Now, we have to go. To south, along the road!"); _gameContext.BasherSteps = 2; _attackedActor.Team = Team.Beasts; ActorData.HasFinishedDuel = true; ActorData.HasWonDuel = true; } if (_attackedActor.ActorType == ActorType.Player && ActorData.ActorType == ActorType.Basher && _attackedActor.HealthProgress < 0.5f) { _uiConfig.BasherMessage.gameObject.SetActive(true); _uiConfig.BasherMessage.GetComponent <RectTransform>().sizeDelta = new Vector3(560, 180); _uiConfig.BasherMessage.SetMessage("Ha! I think you've had enough. That was a good duel! My reputation is clean now. Thank you! Now, we have to go. To south, along the road!"); _gameContext.BasherSteps = 2; ActorData.Team = Team.Beasts; _attackedActor.HasFinishedDuel = true; _attackedActor.HasWonDuel = false; } yield return(new LambdaEffect(() => { Animator blood = Resources.Load <Animator>("Prefabs/Blood"); Animator bloodObject = GameObject.Instantiate(blood, AttackedActor.Entity.transform.position, Quaternion.identity); bloodObject.Play("Blood"); GameObject.Destroy(bloodObject.gameObject, .4f); })); } if (_attackedActor.Swords > 0 && accurate) { --_attackedActor.Swords; } if (ActorData.WeaponWeld.WeaponDefinition.IsBodyPart) { IActionEffect bumpEffect = ActionEffectFactory.CreateBumpEffect(ActorData, AttackedActor.LogicalPosition); yield return(bumpEffect); } else { IActionEffect strikeEffect = ActionEffectFactory.CreateStrikeEffect(ActorData, AttackedActor, !hit, _isDaringBlow); yield return(strikeEffect); } AttackedActor.BlockedUntil = DateTime.UtcNow + TimeSpan.FromMilliseconds(300); ActorData.BlockedUntil = DateTime.UtcNow + TimeSpan.FromMilliseconds(300); }