public override void Shoot(Vector3 position, float rotation, float timeFloat, Vector3 speed, HealthPoints damageAddition, Fraction currentFraction) { if (_rigidbody2D == null) { _rigidbody2D = GetComponent <Rigidbody2D>(); } if (_damageSkill == null) { _damageSkill = GetComponent <DamageSkill>(); } if (_classInformation == null) { _classInformation = GetComponent <ClassInformation>(); } if (_timer == null) { _timer = new ExpirationTimer(timeFloat); _timer.OnExpiredTimer += DespawnAction; } if (_timer.ExpirationTime != timeFloat) { _timer.ExpirationTime = timeFloat; } _timer.Start(); _damageSkill.DamageValue = damageAddition; _classInformation.CurrentFraction = currentFraction; _rigidbody2D.position = position; //_rigidbody2D.rotation = rotation; _rigidbody2D.velocity = speed; }
void DoAttackHeuristic(List <Node> nodesWithUnits, DamageSkill ds, Unit aiUnit) { foreach (Node nodeWithUnit in nodesWithUnits) { // Only accept units that are the other allegiance to attack if (nodeWithUnit.unit?.GetAllegiance() != aiUnit.GetAllegiance()) { // Get nodes in the area that the AI unit could hit the player unit from. List <Node> nodesCastable = Grid.m_Instance.GetNodesWithinRadius(ds.m_CastableDistance, nodeWithUnit); // Go through each of the nodes the AI unit could attack from and add the attack heuristic to them. for (int j = 0; j < nodesCastable.Count; j++) { Node castNode = nodesCastable[j]; // Calculate the new damage for the node's damage heuristic. float hValue = ds.m_DamageAmount * (Vector3.Distance(nodeWithUnit.worldPosition, castNode.worldPosition) * 0.1f) * aiUnit.GetHeuristicCalculator().m_DamageWeighting; if (castNode != null) { AddOrUpdateHeuristic( hValue, castNode, aiUnit, new DamageSkillTarget(ds, nodeWithUnit)); } } // Check for kill heuristic. if (nodeWithUnit.unit.GetCurrentHealth() <= ds.m_DamageAmount) { AddOrUpdateHeuristic( aiUnit.m_AIHeuristicCalculator.m_KillPoints, nodeWithUnit, aiUnit, new DamageSkillTarget(ds, nodeWithUnit)); } } } }
/// <summary> /// Activate one of the unit's skills. /// </summary> /// <param name="skill"> The skill to activate. </param> public void ActivateSkill(BaseSkill skill, Node castLocation) { Debug.Log($"<color=#9c4141>[Skill] </color>{PlayerManager.m_Instance.GetSelectedUnit().name} casts {skill.m_SkillName}" + $" {(castLocation.unit ? $"at {castLocation.unit.name}" : "")} ({castLocation.m_NodeHighlight.name})"); // Doing my own search cause List.Find is gross. for (int i = 0; i < m_Skills.Count; ++i) { // Check if the unit has the skill being cast. if (m_Skills[i].m_SkillName == skill.m_SkillName) { skill.m_AffectedNodes = Grid.m_Instance.GetNodesWithinRadius(m_Skills[i].m_AffectedRange, castLocation, true); skill.m_CastNode = castLocation; if (m_PassiveSkill != null) { DamageSkill ds = skill as DamageSkill; // Check if skill being cast is a damage skill. if (ds != null) { // Make sure the skill knows what units it will affect, so we can check them for the passive. List <Unit> hitUnits = ds.FindAffectedUnits(); if (m_PassiveSkill.GetAffectSelf() == false) { // Check which units meet the prerequisits for the unit's passive. foreach (Unit u in hitUnits) { foreach (InflictableStatus status in m_StatusEffects) { if (status.CheckPrecondition(TriggerType.OnDealDamage) == true) { status.TakeEffect(this); } } // Add extra damage to the skill from status effect (if there is any). if (m_DealExtraDamage > 0) { ds.AddExtraDamage(m_DealExtraDamage); } if (m_PassiveSkill.CheckPrecondition(TriggerType.OnDealDamage, u)) { m_PassiveSkill.TakeEffect(u); } if (m_PassiveSkill.CheckPrecondition(TriggerType.OnDealDamage)) { m_PassiveSkill.TakeEffect(); } } } else { if (m_PassiveSkill.CheckPrecondition(TriggerType.OnDealDamage, this)) { m_PassiveSkill.TakeEffect(this); } if (m_PassiveSkill.CheckPrecondition(TriggerType.OnDealDamage)) { m_PassiveSkill.TakeEffect(this); } } } HealSkill hs = skill as HealSkill; if (hs != null) { PestilencePassive pp = m_PassiveSkill as PestilencePassive; if (pp != null) { pp.UseHealResource(); StatusEffectTooltipManager.m_Instance.UpdatePassive(); } } } if (skill.m_IsMagic) { // TODO Play cast system } skill.CastSkill(); transform.LookAt(castLocation.worldPosition); // Play skill animation m_animator.SetTrigger("TriggerSkill"); // Play the damage sound effect. //FMODUnity.RuntimeManager.PlayOneShot(m_Skills[i].m_CastEvent, transform.position); return; } } Debug.LogError("Skill " + skill.m_SkillName + " couldn't be found in " + gameObject.name + "."); }
public DamageSkillTarget(DamageSkill damageSkill, Node node) { m_Skill = damageSkill; m_TargetNode = node; }
static void Main(string[] args) { using (var context = new GameDb()) { context.Database.Migrate(); Console.WriteLine(context.Players.Count()); foreach (var p in context.Players.Select(x => $"{x.Name} in {x.Location.Id}")) { Console.WriteLine(p); } //Seed the database if (context.Rooms.Count() == 0) { Room room1 = new Room(); Room room2 = new Room(); Equipment sword = new Equipment { BaseValue = 1, Name = "Sword", Type = EquipmentType.Holdable }; context.Add(room1); context.Add(room2); context.Add(sword); context.SaveChanges(); DamageSkill swing = new DamageSkill { Cooldown = 1, Damage = 10, Description = "You swing your sword at your enemy", Name = "Swing", Item = sword }; context.Add(swing); room1.Interactables.Add(new Path { LeadsTo = context.Rooms.Find(room2.Id) }); room2.Interactables.Add(new Path { LeadsTo = context.Rooms.Find(room1.Id) }); room2.Interactables.Add(new OptionalCombat { RoomId = room2.Id }); context.SaveChanges(); startingRoomId = room1.Id; testSwordId = sword.Id; } else { startingRoomId = context.Rooms.FirstOrDefault().Id; testSwordId = 1; } } RequestListener listener = new RequestListener(5723); var configure = listener.Configure(); configure.BuildDependencies(services => { services.AddDbContext <GameDb>(); services.AddSingleton <Authenticator>(); services.AddSingleton <IAlerter>(listener); services.AddSingleton <Mediator>(); }); configure.AddMiddleware(new Debugger()); configure.AddInteractionHandler <InteractionHandler>(); AddHandlers(configure); configure.StartListening(); }