Ejemplo n.º 1
0
    private void OnUnitAttacked(object sender, AttackEventArgs e)
    {
        if (!(CellGrid.CurrentPlayer is HumanPlayer)) return;
        OnUnitDehighlighted(sender, new EventArgs());

        if ((sender as Unit).HitPoints <= 0) return;

        OnUnitHighlighted(sender, e);
    }
Ejemplo n.º 2
0
        private void Actor_Hurt(object sender, AttackEventArgs attackArgs)
        {
            Actor victim = (Actor) sender;
            if (behaviorLists.ContainsKey(victim))
            {
                ActionList victimBehaviorList = behaviorLists[victim];
                Aggravated aggravated = new Aggravated(victimBehaviorList, victim, attackArgs.damageInfo.attacker);
                Stunned stunned = new Stunned(victimBehaviorList, victim);
                if (!victimBehaviorList.has(aggravated) && !victimBehaviorList.has(stunned))
                    victimBehaviorList.pushFront(aggravated);
                if (!victimBehaviorList.has(stunned))
                    victimBehaviorList.pushFront(stunned);
                
            }

        }
Ejemplo n.º 3
0
 private void ActorUnitDestroyed(object sender, AttackEventArgs e)
 {
     if (HasItem) { ThrowItem(); }
     if (HitPoints > 0)
     {
         var gameManager = FindObjectOfType<GameManager>();
         gameManager.SpawnTeleport(Cell.transform.position);
         gameManager.PlaySound(gameManager.teleportSoundEffect);
     }
     else
     {
         Instantiate(tombStone, transform.position, Quaternion.identity);
         PlayerPrefs.SetInt("Killed_Players", PlayerPrefs.GetInt("Killed_Players") + 1);
     }
         
 }
Ejemplo n.º 4
0
 protected virtual bool OnHitEntities(IReadOnlyList <IEntity> entities, AttackEventArgs eventArgs)
 {
     return(true);
 }
Ejemplo n.º 5
0
        public void AttackSelect(object sender, AttackPlanFrom attacker)
        {
            var e = new AttackEventArgs(attacker.Plan, attacker);

            AttackSelect(sender, e);
        }
Ejemplo n.º 6
0
 private void EnemyUnitAttacked(object sender, AttackEventArgs e)
 {
     PlayerPrefs.SetInt("Damage_Dealt", PlayerPrefs.GetInt("Damage_Dealt") + e.Damage);
 }
Ejemplo n.º 7
0
    private IEnumerator ClarkeController_BaseAttackEvent(object sender, AttackEventArgs e)
    {
        isCoolDown = true;
        if (!isAttacking)
        {
            Debug.Log("Attacking");
            actionMovementLockout = true;
            isAttacking = true;
            anim.SetBool("IsAttacking", true);
            var attackPoint = transform.position;
            var hitBox = new Vector3();
            switch (Facing)
            {
                case Direction.Up:
                    {
                        hitBox.y = 0.5f;
                        hitBox.x = 1.5f;
                        attackPoint.y += 1;
                        break;
                    }
                case Direction.Right:
                    {
                        hitBox.y = 1.5f;
                        hitBox.x = 0.5f;
                        attackPoint.x += 1;
                        break;
                    }
                case Direction.Down:
                    {
                        hitBox.y = 0.5f;
                        hitBox.x = 1.5f;
                        attackPoint.y -= 1;
                        break;
                    }
                case Direction.Left:
                    {
                        hitBox.y = 1.5f;
                        hitBox.x = 0.5f;
                        attackPoint.x -= 1;
                        break;
                    }
            }

            foreach (var item in nearEnemy)
            {
                Debug.Log("Enemy");
                Vector3 vec = item.transform.position;
                Vector3 direction = vec - attackPoint;
                var dot = Vector3.Dot(direction, hitBox);
                if (dot < 0.7)
                {
                    var itemStats = item.gameObject.GetComponent<Stats>();
                    itemStats.Health -= 10;
                }
            }
            yield return new WaitForSeconds(.2f);
            anim.SetBool("IsAttacking", false);
            isAttacking = false;
            actionMovementLockout = false;
        }
        yield return new WaitForSeconds(.6f);
        if (!isAttacking)
        {
            isCoolDown = false;
        }
    }
Ejemplo n.º 8
0
 private void OnUnitDestroyed(object sender, AttackEventArgs e)
 {
     InfoPanel.SetActive(false);
 }
Ejemplo n.º 9
0
 public void UseMana(AttackEventArgs attackEventArgs)
 {
     runtimeStats.Mana.Current = 0;
 }
Ejemplo n.º 10
0
 private void Actor_Attack(object sender, AttackEventArgs e)
 {
     handleActorAttack(e.damageInfo);
 }
Ejemplo n.º 11
0
    IEnumerator EndAbility(AttackEventArgs attackEventArgs)
    {
        yield return(new WaitForSeconds(baseStats.AbilityWindup + baseStats.AbilityWinddown));

        AbilityEndWinddownEvent?.Invoke(attackEventArgs);
    }
Ejemplo n.º 12
0
    IEnumerator DelayAbility(AttackEventArgs attackEventArgs)
    {
        yield return(new WaitForSeconds(baseStats.AbilityWindup));

        AbilityOrder(attackEventArgs);
    }
Ejemplo n.º 13
0
 // Ability
 // Kicks off coroutines for times off when Ability should hit and attack should end
 public void StartAbility(AttackEventArgs attackEventArgs)
 {
     StartCoroutine(DelayAbility(attackEventArgs));
     StartCoroutine(EndAbility(attackEventArgs));
 }
Ejemplo n.º 14
0
 // Calls PreAttack, Attack, and PostAttack events so they go in order
 public void AttackOrder(AttackEventArgs attackEventArgs)
 {
     PreAttackEvent?.Invoke(attackEventArgs);
     AttackEvent?.Invoke(attackEventArgs);
     PostAttackEvent?.Invoke(attackEventArgs);
 }
Ejemplo n.º 15
0
    IEnumerator DelayAttack(AttackEventArgs attackEventArgs)
    {
        yield return(new WaitForSeconds(baseStats.AttackWindup));

        AttackOrder(attackEventArgs);
    }
Ejemplo n.º 16
0
 // Kicks off coroutines for times off when attacks should hit and attack should end
 public void StartAttack(AttackEventArgs attackEventArgs)
 {
     StartCoroutine(DelayAttack(attackEventArgs));
     StartCoroutine(EndAttack(attackEventArgs));
 }
Ejemplo n.º 17
0
 // Lowers the Character's health bu the amount in attackEventArgs
 public void TakeDamage(AttackEventArgs attackEventArgs)
 {
     runtimeStats.Health.Current -= attackEventArgs.Damage;
     //Debug.Log("Damage done to \"" + ID + "\": attackEventArgs.Damage");
 }
Ejemplo n.º 18
0
 protected IEnumerator BaseAttack(AttackEventArgs e)
 {
     return AttackEvent(this, new AttackEventArgs());
 }
Ejemplo n.º 19
0
 private void OnUnitDestroyed(object sender, AttackEventArgs e)
 {
     Units.Remove(sender as Unit);
     var totalPlayersAlive = Units.Select(u => u.PlayerNumber).Distinct().ToList(); //Checking if the game is over
     if (totalPlayersAlive.Count == 1)
     {
         if(GameEnded != null)
         {
             GameEnded.Invoke(this, new EventArgs());
         }
     }
 }
 // For Testing
 // Changes color of character for end of attack
 public void EndAbilityAnimation(AttackEventArgs attackEventArgs)
 {
     spriteAttributeChanger.FlashColor(Color.cyan, character.baseStats.AbilityWinddown);
 }
Ejemplo n.º 21
0
 // Calls PreAbility, Ability, and PostAbility events so they go in order
 public void AbilityOrder(AttackEventArgs attackEventArgs)
 {
     PreAbilityEvent?.Invoke(attackEventArgs);
     AbilityEvent?.Invoke(attackEventArgs);
     PostAbilityEvent?.Invoke(attackEventArgs);
 }
Ejemplo n.º 22
0
    private void OnUnitDestroyed(object sender, AttackEventArgs e)
    {
		if ((sender as shinsaUnit).UnitName == "Archflamen") {
			if(GameEnded != null)
				GameEnded.Invoke(sender, new EventArgs());
		}
    }
 // Does the stuff for an animation of the attack
 public void AbilityAnimation(AttackEventArgs attackEventArgs)
 {
     //animator.SetTrigger("Attack");
     spriteAttributeChanger.FlashColor(Color.yellow, character.baseStats.AbilityWindup);
 }
Ejemplo n.º 24
0
 // This is bandaid work around for Events that will through an exception when nothing is subscribed to them
 public void StopException(AttackEventArgs attackEventArgs)
 {
 }
Ejemplo n.º 25
0
 public virtual void CastAbility(AttackEventArgs attackEventArgs)
 {
 }
Ejemplo n.º 26
0
 public void RaiseHitEvent(AttackEventArgs attackEventArgs)
 {
     HitEvent(attackEventArgs);
 }
Ejemplo n.º 27
0
 void OnAttack(Creature c, AttackEventArgs e)
 {
     setBuff(ref creature.statistics.critical, 0);
 }
Ejemplo n.º 28
0
 public void PeePeePooPoo(AttackEventArgs eh)
 {
     //Debug.Log("HEEHE");
 }
Ejemplo n.º 29
0
 private void EnemyUnitDestroyed(object sender, AttackEventArgs e)
 {
     PlayerPrefs.SetInt("Enemies_Killed", PlayerPrefs.GetInt("Enemies_Killed") + 1);
 }
Ejemplo n.º 30
0
 public void PrintStartAttackWindupEvent(AttackEventArgs attackEventArgs)
 {
     //Debug.Log("Start Attack Wind Up Event");
 }
Ejemplo n.º 31
0
        public void AttackSelect(object sender, AttackPlan plan)
        {
            var e = new AttackEventArgs(plan, null);

            AttackSelect(sender, e);
        }
Ejemplo n.º 32
0
 public void PrintEndAttackWindupEvent(AttackEventArgs attackEventArgs)
 {
     //Debug.Log("End Attack Wind Up Event");
 }
Ejemplo n.º 33
0
        bool IAttack.ClickAttack(AttackEventArgs eventArgs)
        {
            if (eventArgs.WideAttack)
            {
                return(false);
            }

            var curTime = _gameTiming.CurTime;

            if (curTime < _cooldownEnd || !eventArgs.Target.IsValid())
            {
                return(true);
            }

            var target = eventArgs.TargetEntity;

            var location = eventArgs.User.Transform.Coordinates;
            var angle    = new Angle(eventArgs.ClickLocation.ToMapPos(Owner.EntityManager) - location.ToMapPos(Owner.EntityManager));

            var audioSystem = EntitySystem.Get <AudioSystem>();

            if (target != null)
            {
                audioSystem.PlayFromEntity(_hitSound, target);
            }
            else
            {
                audioSystem.PlayFromEntity(_missSound, eventArgs.User);
                return(false);
            }

            if (target.TryGetComponent(out IDamageableComponent damageComponent))
            {
                damageComponent.ChangeDamage(DamageType, Damage, false, Owner);
            }
            SendMessage(new MeleeHitMessage(new List <IEntity> {
                target
            }));

            var targets = new[] { target };

            if (!OnHitEntities(targets, eventArgs))
            {
                return(false);
            }

            if (ClickArc != null)
            {
                var sys = EntitySystem.Get <MeleeWeaponSystem>();
                sys.SendAnimation(ClickArc, angle, eventArgs.User, Owner, targets, ClickAttackEffect, false);
            }

            _lastAttackTime = curTime;
            _cooldownEnd    = _lastAttackTime + TimeSpan.FromSeconds(CooldownTime);

            if (Owner.TryGetComponent(out ItemCooldownComponent cooldown))
            {
                cooldown.CooldownStart = _lastAttackTime;
                cooldown.CooldownEnd   = _cooldownEnd;
            }

            return(true);
        }
Ejemplo n.º 34
0
 public void PrintAttackEvent(AttackEventArgs attackEventArgs)
 {
     //Debug.Log("Attack Event");
 }
Ejemplo n.º 35
0
        bool IAttack.WideAttack(AttackEventArgs eventArgs)
        {
            if (!eventArgs.WideAttack)
            {
                return(true);
            }

            var curTime = _gameTiming.CurTime;

            if (curTime < _cooldownEnd)
            {
                return(true);
            }

            var location = eventArgs.User.Transform.Coordinates;
            var angle    = new Angle(eventArgs.ClickLocation.ToMapPos(Owner.EntityManager) - location.ToMapPos(Owner.EntityManager));

            // This should really be improved. GetEntitiesInArc uses pos instead of bounding boxes.
            var entities = ArcRayCast(eventArgs.User.Transform.WorldPosition, angle, eventArgs.User);

            var audioSystem = EntitySystem.Get <AudioSystem>();

            if (entities.Count != 0)
            {
                audioSystem.PlayFromEntity(_hitSound, entities.First());
            }
            else
            {
                audioSystem.PlayFromEntity(_missSound, eventArgs.User);
            }

            var hitEntities = new List <IEntity>();

            foreach (var entity in entities)
            {
                if (!entity.Transform.IsMapTransform || entity == eventArgs.User)
                {
                    continue;
                }

                if (entity.TryGetComponent(out IDamageableComponent damageComponent))
                {
                    damageComponent.ChangeDamage(DamageType, Damage, false, Owner);
                    hitEntities.Add(entity);
                }
            }
            SendMessage(new MeleeHitMessage(hitEntities));

            if (!OnHitEntities(hitEntities, eventArgs))
            {
                return(false);
            }

            if (Arc != null)
            {
                var sys = EntitySystem.Get <MeleeWeaponSystem>();
                sys.SendAnimation(Arc, angle, eventArgs.User, Owner, hitEntities);
            }

            _lastAttackTime = curTime;
            _cooldownEnd    = _lastAttackTime + TimeSpan.FromSeconds(ArcCooldownTime);

            if (Owner.TryGetComponent(out ItemCooldownComponent cooldown))
            {
                cooldown.CooldownStart = _lastAttackTime;
                cooldown.CooldownEnd   = _cooldownEnd;
            }

            return(true);
        }
Ejemplo n.º 36
0
 public void PrintEndAttackWinddownEvent(AttackEventArgs attackEventArgs)
 {
     //Debug.Log("End Attack Wind Down Event");
 }
Ejemplo n.º 37
0
 private void OnUnitDestroyed(object sender, AttackEventArgs e)
 {
     Destroy(_infoPanel);
 }
Ejemplo n.º 38
0
 // Enables charging of attack
 public void EnableCharge(AttackEventArgs attackEventArgs)
 {
     canCharge = true;
 }
Ejemplo n.º 39
0
 private void OnUnitDestroyed(object sender, AttackEventArgs e)
 {
     Destroy(_infoPanel);
 }
Ejemplo n.º 40
0
 // Disables charging of attack
 public void DisableCharge(AttackEventArgs attackEventArgs)
 {
     canCharge = false;
 }
 public void HitAnimation(AttackEventArgs attackEventArgs)
 {
     //spriteAttributeChanger.SquashSprite(.5f);
     ShowFloatingText(attackEventArgs);
 }
 // For Testing
 // Changes color of character for end of attack
 public void EndAttackAnimation(AttackEventArgs attackEventArgs)
 {
     spriteAttributeChanger.FlashColor(Color.green, character.baseStats.AttackWinddown);
 }
Ejemplo n.º 43
0
 void OnAttack(Creature c, AttackEventArgs e)
 {
     if (creature.modifyMana(-8))
         e.target.buffs.Add(new Frost(e.target, level));
 }
Ejemplo n.º 44
0
 private void ActorUnitAttacked(object sender, AttackEventArgs e)
 {
     PlayerPrefs.SetInt("Damage_Taken", PlayerPrefs.GetInt("Damage_Taken") + e.Damage);
 }