Пример #1
0
        public IEnumerator Attack(Unit target)
        {
            yield return(_unitAnimation.Rotate(target.transform, 0.3f));

            yield return(_unitAnimation.Attack(target.Cell.Tile.transform.position, 10f));

            yield return(target.TakeDamage());

            if (target.UnitStatus.Health <= 0)
            {
                OnUnitDied?.Invoke(target);
            }

            yield return(new WaitForSeconds(0.3f));
        }
Пример #2
0
        public void GetDamage(int amount)
        {
            this.HP -= amount;
            if (this.HP <= 0)
            {
                this.HP = 0;
            }

            // Tigger when unit died
            if (!IsDead)
            {
                OnGetDamage?.Invoke(this, amount);
            }
            else if (IsDead)
            {
                OnGetDamage?.Invoke(this, amount);
                OnUnitDied?.Invoke(this, EventArgs.Empty);
            }
        }
Пример #3
0
        private void PerformAction(Action action, Unit unit, bool alreadyPerfomedType)
        {
            switch (action.Type)
            {
            case ActionType.Move:
                if (CanMove(unit, action.Direction))
                {
                    unit.Move(action.Direction, alreadyPerfomedType);
                    OnUnitMoved?.Invoke(this, new MoveEventArgs {
                        Unit = unit
                    });
                }
                break;

            case ActionType.Attack:
                Unit target = GetTarget(unit, action);
                if (target != null)
                {
                    unit.Attack(target);
                    if (target.Health <= 0)
                    {
                        OnUnitDied?.Invoke(this, new DeathEventArgs {
                            Unit = target
                        });
                        if (GameConfig.BloodLust)
                        {
                            unit.Power += 2;
                        }
                    }
                }
                OnUnitAttacked?.Invoke(this, new AttackEventArgs {
                    Unit = unit, Target = target
                });
                break;
            }
        }
        public void Parse(long timestamp, List <string> args)
        {
            if (BasicCombatlogEntry.TryParse(args, out BasicCombatlogEntry entry))
            {
                AmeisenLogger.I.Log("CombatLogParser", $"[{timestamp}] Parsing CombatLog: {JsonSerializer.Serialize(args)}", LogLevel.Verbose);

                switch (entry.Type)
                {
                case CombatlogEntryType.PARTY:
                    switch (entry.Subtype)
                    {
                    case CombatlogEntrySubtype.KILL:
                        AmeisenLogger.I.Log("CombatLogParser", $"OnPartyKill({entry.SourceGuid}, {entry.DestinationGuid})");
                        OnPartyKill?.Invoke(entry.SourceGuid, entry.DestinationGuid);
                        break;
                    }
                    break;

                case CombatlogEntryType.UNIT:
                    switch (entry.Subtype)
                    {
                    case CombatlogEntrySubtype.DIED:
                        AmeisenLogger.I.Log("CombatLogParser", $"OnUnitDied({entry.SourceGuid})");
                        OnUnitDied?.Invoke(entry.SourceGuid);
                        break;
                    }
                    break;

                case CombatlogEntryType.SWING:
                    switch (entry.Subtype)
                    {
                    case CombatlogEntrySubtype.DAMAGE:
                        if (int.TryParse(entry.Args[(int)CombatlogField.SwingDamageAmount], out int damage))
                        {
                            AmeisenLogger.I.Log("CombatLogParser", $"OnDamage({entry.SourceGuid}, {entry.DestinationGuid}, {entry.Args[(int)CombatlogField.SwingDamageAmount]})");
                            OnDamage?.Invoke(entry.SourceGuid, entry.DestinationGuid, -1, damage, 0);
                        }
                        break;
                    }
                    break;

                case CombatlogEntryType.SPELL:
                    switch (entry.Subtype)
                    {
                    case CombatlogEntrySubtype.DAMAGE:
                        if (int.TryParse(entry.Args[(int)CombatlogField.SpellAmount], out int spellAmount) &&
                            int.TryParse(entry.Args[(int)CombatlogField.SpellAmountOver], out int spellAmountOver) &&
                            int.TryParse(entry.Args[(int)CombatlogField.SpellSpellId], out int spellSpellId))
                        {
                            AmeisenLogger.I.Log("CombatLogParser", $"OnDamage({entry.SourceGuid}, {entry.DestinationGuid}, {entry.Args[(int)CombatlogField.SpellSpellId]}, {entry.Args[(int)CombatlogField.SpellAmount]}, {entry.Args[(int)CombatlogField.SpellAmountOver]})");
                            OnDamage?.Invoke(entry.SourceGuid, entry.DestinationGuid, spellSpellId, spellAmount, spellAmountOver);
                        }
                        break;

                    case CombatlogEntrySubtype.HEAL:
                        if (int.TryParse(entry.Args[(int)CombatlogField.SpellAmount], out int spellAmount2) &&
                            int.TryParse(entry.Args[(int)CombatlogField.SpellAmountOver], out int spellAmountOver2) &&
                            int.TryParse(entry.Args[(int)CombatlogField.SpellSpellId], out int spellSpellId2))
                        {
                            AmeisenLogger.I.Log("CombatLogParser", $"OnHeal({entry.SourceGuid}, {entry.DestinationGuid}, {entry.Args[(int)CombatlogField.SpellSpellId]}, {entry.Args[(int)CombatlogField.SpellAmount]}, {entry.Args[(int)CombatlogField.SpellAmountOver]})");
                            OnHeal?.Invoke(entry.SourceGuid, entry.DestinationGuid, spellSpellId2, spellAmount2, spellAmountOver2);
                        }
                        break;
                    }
                    break;
                }
            }
            else
            {
                AmeisenLogger.I.Log("CombatLogParser", $"Parsing failed: {JsonSerializer.Serialize(args)}", LogLevel.Warning);
            }
        }
Пример #5
0
 protected void Die()
 {
     // if there is some timeout or animations
     OnUnitDied?.Invoke(this, EventArgs.Empty);
 }