public static string UnexpectedStrike(out int damageOut, EntityManager em, EntityCommandBuffer buffer, Entity attacker, Entity target, int damage) { string s = ""; damageOut = damage; if (DiceSystem.DiceRoll(6) == 6) { if (!em.HasComponent <Poison>(target)) { buffer.AddComponent <Poison>(target, new Poison() { duration = 1 }); s += "Poison attack\n"; } } if (DiceSystem.DiceRoll(6) == 6) { if (!em.HasComponent <BrokenArmour>(target)) { buffer.AddComponent <BrokenArmour>(target, new BrokenArmour() { duration = 1 }); s += "BrokenArmour\n"; } } if (DiceSystem.DiceRoll(6) == 6) { damageOut = damage * 2; s += "CRITICAL STRIKE"; } return(s); }
public static int Evasion(int damage) { if (DiceSystem.DiceRoll(10) == 10) { return(0); } return(damage); }
public static string CriticalStrike(out int damageOut, EntityManager em, EntityCommandBuffer buffer, Entity attacker, Entity target, int damage) { if (DiceSystem.DiceRoll(6) == 6) { damageOut = damage * 2; return("CRITICAL STRIKE"); } else { damageOut = damage; return(""); } }
public static string ClawHit(out int damageOut, EntityManager em, EntityCommandBuffer buffer, Entity attacker, Entity target, int damage) { damageOut = damage; if (DiceSystem.DiceRoll(4) == 4) { if (!em.HasComponent <Stunned>(target)) { buffer.AddComponent <Stunned>(target, new Stunned() { duration = 1 }); return("STUNNED"); } } return(""); }
public static string MightyStrike(out int damageOut, EntityManager em, EntityCommandBuffer buffer, Entity attacker, Entity target, int damage) { var hp = em.GetComponentData <HP>(target); damageOut = damage; if (DiceSystem.DiceRoll(10) == 10) { buffer.SetComponent <HP>(target, new HP() { startValue = hp.startValue, currentValue = hp.currentValue / 2 }); damageOut = 0; return("MIGHTY STRIKE"); } return(""); }
protected override void OnUpdate() { units = GetEntityQuery(tickEffectsDesc); var unit = units.ToEntityArray(Allocator.TempJob); foreach (var entity in unit) { if (EntityManager.HasComponent <BadSign>(entity)) { if (DiceSystem.DiceRoll(20) < 2) { PostUpdateCommands.RemoveComponent <Action>(entity); } if (EntityManager.GetComponentData <BadSign>(entity).duration == 0) { PostUpdateCommands.RemoveComponent <BadSign>(entity); } else { PostUpdateCommands.SetComponent <BadSign>(entity, new BadSign() { duration = EntityManager.GetComponentData <BadSign>(entity).duration - 1 }); } } if (EntityManager.HasComponent <FishTail>(entity)) { var move = EntityManager.GetComponentData <Move>(entity); PostUpdateCommands.SetComponent <Move>(entity, new Move() { index = 0 }); } if (EntityManager.HasComponent <Cooldown>(entity)) { if (EntityManager.GetComponentData <Cooldown>(entity).duration == 0) { PostUpdateCommands.RemoveComponent <Cooldown>(entity); } else { PostUpdateCommands.SetComponent <Cooldown>(entity, new Cooldown() { duration = EntityManager.GetComponentData <Cooldown>(entity).duration - 1 }); } } if (EntityManager.HasComponent <Poison>(entity)) { if (EntityManager.GetComponentData <Poison>(entity).duration == 0) { PostUpdateCommands.RemoveComponent <Poison>(entity); } else { PostUpdateCommands.SetComponent <Poison>(entity, new Poison() { duration = EntityManager.GetComponentData <Poison>(entity).duration - 1 }); PostUpdateCommands.SetComponent <HP>(entity, new HP() { startValue = EntityManager.GetComponentData <HP>(entity).startValue, currentValue = EntityManager.GetComponentData <HP>(entity).currentValue - 5 }); } } if (EntityManager.HasComponent <Stunned>(entity)) { if (EntityManager.GetComponentData <Stunned>(entity).duration == 0) { PostUpdateCommands.RemoveComponent <Stunned>(entity); } else { PostUpdateCommands.SetComponent <Stunned>(entity, new Stunned() { duration = EntityManager.GetComponentData <Stunned>(entity).duration - 1 }); } PostUpdateCommands.RemoveComponent <Stunned>(entity); } if (EntityManager.HasComponent <Bleeding>(entity)) { PostUpdateCommands.SetComponent <HP>(entity, new HP() { startValue = EntityManager.GetComponentData <HP>(entity).startValue, currentValue = EntityManager.GetComponentData <HP>(entity).currentValue - EntityManager.GetComponentData <Bleeding>(entity).damage }); } if (EntityManager.HasComponent <DestroyedArmour>(entity) && !EntityManager.HasComponent <BrokenArmour>(entity)) { PostUpdateCommands.AddComponent <BrokenArmour>(entity, new BrokenArmour() { }); } } unit.Dispose(); }
protected override void OnUpdate() { var attacker = GetEntityQuery(typeof(UnitAttack), typeof(Attack), typeof(Team), typeof(BoardPosition), typeof(UnitType)); var units = GetEntityQuery(unitQuery); bool didHit = false; if (attacker.CalculateLength() == 1) { var attackerEntity = attacker.ToEntityArray(Allocator.TempJob); units.SetFilter(new Team() { value = EntityManager.GetSharedComponentData <Team>(attackerEntity[0]).value * -1 }); var target = units.ToEntityArray(Allocator.TempJob); var targetHP = units.ToComponentDataArray <HP>(Allocator.TempJob); var targetId = units.ToComponentDataArray <Id>(Allocator.TempJob); var targetPosition = units.ToComponentDataArray <BoardPosition>(Allocator.TempJob); var targetType = units.ToComponentDataArray <UnitType>(Allocator.TempJob); var attackType = attacker.ToComponentDataArray <Attack>(Allocator.TempJob); var attackerPos = attacker.ToComponentDataArray <BoardPosition>(Allocator.TempJob); float shift = -1; List <SquadsManagement.attackData> attacks = new List <SquadsManagement.attackData>(); int damage = 0; if (EntityManager.HasComponent <ExperiencedFighter>(attackerEntity[0])) { damage = DiceSystem.RollBunchOfDice(attackType[0].amountOfCubes, attackType[0].typeOfCubes, true); } else { damage = DiceSystem.RollBunchOfDice(attackType[0].amountOfCubes, attackType[0].typeOfCubes); } for (int i = 0; i < units.CalculateLength(); i++) { /*ATTACK DAMAGE DEAL*/ if (AttackPatterns.chooseType(attackType[0].index, attackerPos[0].cell, targetPosition[i].cell) || (EntityManager.HasComponent <PizarroStrike>(attackerEntity[0]) && EntityManager.HasComponent <Curse>(target[0]))) { didHit = true; PostUpdateCommands.AddComponent(target[i], new Target() { }); /*close-up targets creation*/ float delta = 0 + 1.5f * (shift + 1) * (shift % 2 == 0 ? 1 : -1); var e = PostUpdateCommands.CreateEntity(closeUpTarget); PostUpdateCommands.SetComponent(e, new View() { state = 2 /*damage*/, frame = 0 }); PostUpdateCommands.SetComponent(e, new UnitType() { index = targetType[i].index }); PostUpdateCommands.SetComponent(e, new Translation() { Value = new float3(1030f + -100 * Mathf.Abs(delta), 180 + delta * 100, (4 + delta) * 0.1f) }); shift += 0.6f; if (EntityManager.HasComponent <Evasion>(target[i])) { damage = AttackPatterns.Evasion(damage); } if (EntityManager.HasComponent <Bleeding>(target[i])) { damage = EntityManager.GetComponentData <Bleeding>(target[i]).damage; } if (EntityManager.HasComponent <BrokenArmour>(target[i]) || EntityManager.HasComponent <DestroyedArmour>(target[i])) { damage *= 2; } string effect = AttackPatterns.chooseEffect(out damage, attackType[0].effect, EntityManager, PostUpdateCommands, attackerEntity[0], target[i], damage); PostUpdateCommands.SetComponent <HP>(target[i], new HP() { currentValue = targetHP[i].currentValue - damage, startValue = targetHP[i].startValue }); SquadsManagement.instance.allCards[targetId[i].value].GetComponent <UnitCardFight>().UpdateData(target[i], damage); attacks.Add(new SquadsManagement.attackData() { targetId = targetId[i].value, damage = damage, target = target[i], position = new float3(1030f + -100 * Mathf.Abs(delta), 180 + delta * 100, (4 + delta) * 0.1f) }); } SquadsManagement.instance.Attacks = attacks; } if (didHit == true) { /*close-up view creation*/ var e = PostUpdateCommands.CreateEntity(closeUpAttack); PostUpdateCommands.SetComponent(e, new Translation() { Value = new float3(1480, 180f, 1f) }); PostUpdateCommands.SetComponent(e, new View() { state = 1 /*attack*/ }); PostUpdateCommands.SetComponent(e, new UnitType() { index = EntityManager.GetComponentData <UnitType>(attackerEntity[0]).index }); PostUpdateCommands.AddComponent(attackerEntity[0], new UnitAnimation() { }); } else { Translation pos = EntityManager.GetComponentData <Translation>(attackerEntity[0]); animationManager.instance.DestroyMassAnimationInstance(new animationManager.particleAnimation() { name = "UnitCircle", position = new Vector3(pos.Value.x, pos.Value.y, -30) }); animationManager.instance.CreateMassAnimationName(new animationManager.particleAnimation() { name = "UnitCircle", position = new Vector3(pos.Value.x, pos.Value.y, -30) }, EntityManager.GetSharedComponentData <Team>(attackerEntity[0]).value); } PostUpdateCommands.RemoveComponent <UnitAttack>(attackerEntity[0]); target.Dispose(); attackerEntity.Dispose(); targetHP.Dispose(); targetId.Dispose(); targetPosition.Dispose(); targetType.Dispose(); attackType.Dispose(); attackerPos.Dispose(); } }