//public void MoveObject(Transform target, bool ToField2) //{ // Transform filed; // if (ToField2) // { // filed = _Field2; // } // else // { // filed = _Field1; // } // target.SetParent(filed, false); //} public void MoveBomb(CreateEffect target, bool ToField2) { if (target == null) { return; } if (target._isMoving) { return; } Transform field; if (ToField2) { field = _Field2; target.exprad = _BombScaleToField2; } else { field = _Field1; target.exprad = _BombScaleToField1; } target.exptime2 += 1.0f + _MoveBombNeedSeconds * 2.0f; StartCoroutine(Routine_MoveBomb(target, field)); }
private IEnumerator Routine_MoveBomb(CreateEffect target, Transform filed) { if (target) { target._isMoving = true; } Vector3 Scale = target.SpriteObj.transform.localScale; Vector3 b; //縮小 for (float t = 0.0f; t < _MoveBombNeedSeconds; t += Time.deltaTime) { float e = t / _MoveBombNeedSeconds; b = Vector3.Lerp(Scale, Vector3.zero, e); if (target) { target.SpriteObj.transform.localScale = Vector3.Lerp(b, Vector3.zero, e); } yield return(null); } if (target) { target.SpriteObj.transform.localScale = Vector3.zero; } //移動 if (target) { target.transform.SetParent(filed, false); Instantiate(_Effect, target.transform.position, Quaternion.identity); } Instantiate(_Prefab_Audio_MoveBomb); //拡大 for (float t = 0.0f; t < _MoveBombNeedSeconds; t += Time.deltaTime) { float e = t / _MoveBombNeedSeconds; b = Vector3.Lerp(Vector3.zero, Scale, e); if (target) { target.SpriteObj.transform.localScale = Vector3.Lerp(b, Scale, e); } yield return(null); } if (target) { target.SpriteObj.transform.localScale = Scale; } if (target) { target._isMoving = false; } target.transform.SetParent(filed, false); yield return(null); }
public void should_throw_error_if_effect_source_not_found() { var cmd = new CreateEffect { OwnerId = 100, EffectSourceId = 55 }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("Effect Source with Id 55 could not be found")); }
public void should_throw_error_if_player_not_found() { new EffectSourceBuilder() .With(ss => ss.Id, 55) .BuildAndSave(); var cmd = new CreateEffect { OwnerId = 100, EffectSourceId = 55 }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("Player with Id 100 could not be found")); }
public static Effect Create(Player player, EffectSource effectSource, CreateEffect cmd) { var effect = new Effect { Owner = player, EffectSource = effectSource, Duration = cmd.Duration, Level = cmd.Level, Cooldown = cmd.Cooldown, IsPermanent = cmd.IsPermanent }; return(effect); }
public void can_create_effect() { new PlayerBuilder() .With(p => p.Id, 100) .BuildAndSave(); new EffectSourceBuilder() .With(e => e.Id, 77) .BuildAndSave(); var cmd = new CreateEffect { OwnerId = 100, EffectSourceId = 77 }; Assert.That(() => DomainRegistry.Repository.Execute(cmd), Throws.Nothing); Assert.That(DataContext.AsQueryable <Effect>().Where(p => p.Owner.Id == 100 && p.EffectSource.Id == 77), Has.Exactly(1).Items); }
public static string GivePerkToPlayer(int effectSourceId, Player player, int?Duration = null, int?Cooldown = null) { IEffectRepository effectRepo = new EFEffectRepository(); // see if this player already has this perk. If so, reject it var possibleSamePerk = effectRepo.Effects.FirstOrDefault(e => e.EffectSourceId == effectSourceId && e.OwnerId == player.Id); if (possibleSamePerk != null) { return("You already have this perk. Choose another."); } // grab the static part of this effect var effectPlus = EffectStatics.GetDbStaticEffect(effectSourceId); if (effectPlus.isLevelUpPerk) { // assert that the perk doesn't require a level higher than the player if (effectPlus.AvailableAtLevel > player.Level) { return("You are not at a high enough level to earn this perk."); } // assert that the perk doesn't require a prerequisite that the player does not yet have if (effectPlus.PreRequisiteEffectSourceId != null) { var requiredPrerequisite = effectRepo.Effects.FirstOrDefault(e => e.OwnerId == player.Id && e.EffectSourceId == effectPlus.PreRequisiteEffectSourceId); if (requiredPrerequisite == null) { return("This perk requires the <b>" + EffectStatics.GetDbStaticEffect(effectPlus.PreRequisiteEffectSourceId.Value).FriendlyName + "</b> prerequisite perk which you do not have."); } } } var cmd = new CreateEffect(); cmd.EffectSourceId = EffectStatics.GetDbStaticEffect(effectSourceId).Id; cmd.OwnerId = player.Id; // this effect is a permanent levelup perk if (effectPlus.AvailableAtLevel > 0) { cmd.Duration = 99999; cmd.Cooldown = 99999; cmd.IsPermanent = true; cmd.Level = 1; } // this effect is temporary, grab some of its stats from the effect static if (effectPlus.AvailableAtLevel == 0) { var duration = Duration ?? effectPlus.Duration; var cooldown = Cooldown.HasValue ? Math.Max(duration, Cooldown.Value) : effectPlus.Cooldown; cmd.Duration = duration; cmd.Cooldown = cooldown; cmd.IsPermanent = false; } // okay to proceed--give this player this perk. DomainRegistry.Repository.Execute(cmd); IPlayerRepository playerRepo = new EFPlayerRepository(); var person = playerRepo.Players.FirstOrDefault(p => p.Id == player.Id); var logMessage = $"You have gained the perk {effectPlus.FriendlyName}."; if (cmd.IsPermanent) { // this is a level up perk so just return a simple message PlayerLogProcedures.AddPlayerLog(player.Id, logMessage, false); //remove an unused perk from the player person.UnusedLevelUpPerks--; } else { // this is a temporary perk so return the flavor text if (player.Gender == PvPStatics.GenderMale && !effectPlus.MessageWhenHit_M.IsNullOrEmpty()) { logMessage = effectPlus.MessageWhenHit_M; } else if (player.Gender == PvPStatics.GenderFemale && !effectPlus.MessageWhenHit_F.IsNullOrEmpty()) { logMessage = effectPlus.MessageWhenHit_F; } else { logMessage = effectPlus.MessageWhenHit; } PlayerLogProcedures.AddPlayerLog(player.Id, logMessage, false); } person.ReadjustMaxes(ItemProcedures.GetPlayerBuffs(person)); playerRepo.SavePlayer(person); return(logMessage); }