void ApplyBaseEffect(Collider mob) { //Debug.Log ("entity entering"); if (slowPercentage > 0) { if (mob.gameObject.GetComponent <SlowEffect> () != null) { if (mob.gameObject.GetComponent <SlowEffect> ().slowPercentage < slowPercentage) { Destroy(mob.gameObject.GetComponent <SlowEffect> ()); ApplySlowEffect(mob); } } else { ApplySlowEffect(mob); } } if (damage > 0) { de = mob.gameObject.AddComponent <DamageEffect> () as DamageEffect; de.damage = damage; de.Apply(); } }
public Outcome ResolveEffect(DungeonMaster DM, Character user, Position posTarget, Deck deck, Card cardDrawn, List <Effect> typicalEffects) { var outcome = new Outcome(); //TODO: add slime splitting if (cardDrawn.TypeOfCard == Card.CardType.Armor) { //TODO: more elegant method if (cardDrawn.Name == "Split") { var emptySpaces = DM.GetEmptyAdjacentSquares(Pos); if (emptySpaces.Count != 0) { //int i = DungeonMaster.rand.Next(emptySpaces.Count); int i = 0; //TODO: derandomized for now for networking reasons var emptySpace = emptySpaces[i]; Vitality.Value = Vitality.Value / 2; var cloneCharacter = this.Clone() as Character; cloneCharacter.InitializeIndividual("Copy of " + Name, emptySpace, SideID, DM.GuidsInWaiting.Dequeue()); DM.CreateCharacter(cloneCharacter); } } if (cardDrawn.Name == "Burn") { if (user != null) { user.TakeDamage(DamageEffect.DamageType.Fire, 1); } } //reduce damage var damage = typicalEffects.FirstOrDefault(e => e.TypeOfEffect == Effect.EffectType.Damage) as DamageEffect; if (damage != null) { int amount = damage.GetAmount(DM, user, posTarget, this); int x = Math.Max(0, amount - ArmorProtection); var reducedDamage = new DamageEffect(damage.TypeOfDamage, x); reducedDamage.Apply(DM, user, posTarget, this, deck, cardDrawn); outcome.Message.AppendLine("Damage reduced to " + x + " by armor"); } var slimeArmor = Conditions.FirstOrDefault(c => c.Name == "Slime Armor"); if (slimeArmor != null) { slimeArmor.Value -= 1; if (slimeArmor.Value <= 0) { Conditions.Remove(slimeArmor); //TODO: auto remove if goes below 0? } } } return(outcome); }
protected bool ExecuteHitbox(ICombatant combatant, uint damage) { var hb = Hitbox; var xDir = Math.Sign(combatant.FacingDirection.x); if (xDir != 0) { hb.Center.x *= xDir; } hb.Center += (Vector2)combatant.Transform.position; var s = combatant as IGizmosSchedulable; if (s != null) { s.ScheduleGizmos(() => DebugUtil.DrawBounds2D(hb, Color.green)); } var success = false; var found = Physics2D.OverlapBoxAll(hb.Center, hb.Size, 0, HitboxMask); foreach (var hit in found) { var e = hit.GetComponentInParent <ICombatant>(); if (e != null && e.Ignored) { continue; } if (e == null || e == combatant || !e.CanAttack(combatant)) { continue; } Effect.Apply(e); success = true; if (!SingleEntity) { continue; } return(true); } return(success); }