Пример #1
0
 public void OnAttack(InputAction.CallbackContext context)
 {
     if (context.phase == InputActionPhase.Performed)
     {
         AttackEvent.Invoke();
     }
 }
Пример #2
0
        private void AttackCall(bool mbPress)
        {
            //Check the timer if it is time to attack
            if ((Time.time - timer) > gameObject.GetComponent <Stats>().attackSpeed.Value)
            {
                //We enable the hitbox to check for collisions for the weapon
                //weaponHitBox.SetActive(true);
                //Move the hit box a miniscule amount to get a reaction from the hit box while the animation has not yet been inplimented
                //NOTE: Take out this movement when the animation has been implimented
                weaponHitBox.GetComponent <HitBox>().startCheckingCollision();
                //NOTE: play attack animation from here

                //Call to the attack event callback system
                AttackEvent attackEventInfo = new AttackEvent();
                attackEventInfo.baseGO = gameObject;
                attackEventInfo.FireEvent();
                //Reset the timer for the next attack time check
                timer = Time.time;
            }

            //Check the timer if it is time to attack
            if ((Time.time - timer) > gameObject.GetComponent <Stats>().attackSpeed.Value)
            {
                //We disable the hitbox when the timer for the attack has run down
                weaponHitBox.GetComponent <HitBox>().stopCheckingCollision();
            }
        }
Пример #3
0
    //TODO: Controls a lot of stuff, may want to refactor
    public void EquipWeapon(Weapon Weapon, bool pickup = false, GameObject obj = null, bool drop = false)
    {
        if (currentWeapon != null)
        {
            UnEquipWeapon(drop);
        }
        myStats.Equip(Weapon);
        if (pickup)
        {
            currentWeapon = obj;
            Transform t = currentWeapon.transform;
            t.parent        = weaponHolder.transform;
            t.localPosition = Vector3.zero;
            t.rotation      = weaponHolder.transform.rotation;
        }
        else
        {
            currentWeapon = Instantiate(Weapon.model, weaponHolder.transform.position, weaponHolder.transform.rotation, weaponHolder.transform);
        }
        weaponGfx = currentWeapon.transform.GetChild(0).gameObject;
        currentWeapon.GetComponent <Collider>().enabled = false;
        weaponAnim     = currentWeapon.GetComponentInChildren <Animator>();
        weaponDialogue = currentWeapon.GetComponent <DialogueTrigger>();
        weaponDialogue.disableDialogueObject();
        AttackEvent weapAttackEvent = currentWeapon.GetComponent <AttackEvent>();

        weaponBox         = weapAttackEvent.GetCollider();
        weaponBox.enabled = false;
        weaponBoxScript   = weapAttackEvent.GetWeapBoxScript();
        weaponBoxScript.setDamage(myStats.Strength);
    }
Пример #4
0
    // Update is called once per frame
    void FixedUpdate()
    {
        float elapsedTime = Time.fixedDeltaTime;

        for (int i = 0; i < attackEventList.Length; i++)
        {
            AttackEvent a = attackEventList[i];

            a.time -= elapsedTime;
            while (a.time < 0 && (a.repeat == 0 || a.round < a.repeat))
            {
                GameObject g = Instantiate(a.spawner, e.gameObject.transform.position, Quaternion.identity) as GameObject;
                g.transform.SetParent(e.transform);
                BulletSpawner s = g.GetComponent <BulletSpawner>();

                s.bulletCount = a.bullets;
                s.prefab      = a.bullet;
                s.behaviour   = a.behaviour;
                s.clr         = a.c;
                if (a.track)
                {
                    s.track = e.p.gameObject;
                }
                s.offset += a.offset;
                a.round++;
                a.time += a.cd;
            }
        }
    }
Пример #5
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            var contextMessage = new ContextualString(actionInput.Actor, target)
            {
                ToOriginator = $"You cast ThunderClap at {target.Name}!",
                ToReceiver = $"{actionInput.Actor.Name} casts ThunderClap at you. You only hear a ringing in your ears now.",
                ToOthers = $"You hear {actionInput.Actor.Name} cast ThunderClap at {target.Name}! It was very loud.",
            };
            var sm = new SensoryMessage(SensoryType.Hearing, 100, contextMessage);

            var attackEvent = new AttackEvent(target, sm, actionInput.Actor);
            actionInput.Actor.Eventing.OnCombatRequest(attackEvent, EventScope.ParentsDown);
            if (!attackEvent.IsCancelled)
            {
                var deafenEffect = new AlterSenseEffect()
                {
                    SensoryType = SensoryType.Hearing,
                    AlterAmount = -1000,
                    Duration = new TimeSpan(0, 0, 45),
                };

                target.Behaviors.Add(deafenEffect);
                actionInput.Actor.Eventing.OnCombatEvent(attackEvent, EventScope.ParentsDown);
            }
        }
        bool IAttack.ClickAttack(AttackEvent eventArgs)
        {
            var target = eventArgs.TargetEntity;
            var user   = eventArgs.User;

            return(TryDoInject(target, user));
        }
Пример #7
0
        private void ProcessAttackEvent(AttackEvent kEvent)
        {
            KVector2   attackerPosition = kEvent.source;
            GameObject attacker         = FruitonsGrid[attackerPosition.x, attackerPosition.y];

            attacker.GetComponentInChildren <BoyFighterBattleAnimator>().Attack(() => AfterAttackAnimation(kEvent));
        }
Пример #8
0
        /// <summary>Executes the command.</summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        public override void Execute(ActionInput actionInput)
        {
            IController sender         = actionInput.Controller;
            var         contextMessage = new ContextualString(sender.Thing, this.target)
            {
                ToOriginator = "You cast ThunderClap at $ActiveThing.Name!",
                ToReceiver   = "$Aggressor.Name casts ThunderClap at you, you only hear a ringing in your ears now.",
                ToOthers     = "You hear $Aggressor.Name cast ThunderClap at $ActiveThing.Name!  It was very loud.",
            };
            var sm = new SensoryMessage(SensoryType.Hearing, 100, contextMessage);

            var attackEvent = new AttackEvent(this.target, sm, sender.Thing);

            sender.Thing.Eventing.OnCombatRequest(attackEvent, EventScope.ParentsDown);
            if (!attackEvent.IsCancelled)
            {
                var deafenEffect = new AlterSenseEffect()
                {
                    SensoryType = SensoryType.Hearing,
                    AlterAmount = -1000,
                    Duration    = new TimeSpan(0, 0, 45),
                };

                this.target.Behaviors.Add(deafenEffect);
                sender.Thing.Eventing.OnCombatEvent(attackEvent, EventScope.ParentsDown);
            }
        }
Пример #9
0
    //Take move that has been keyed in and charge for it
    public void pendingAction()
    {
        //always do move, bring heartPoints as low as 1, if need be
        Action pendingAction = listen();

        if (pendingAction == null)
        {
//			print("No valid keys pressed");
        }
        else if (pendingAction is Cancel)
        {
            GameLoop.endEvent(performing);
        }

        else if (pendingAction is Attack)
        {
            AttackEvent e = new AttackEvent((Attack)pendingAction, this, enemy);
            GameLoop.addToList(e);
            performing   = e;
            heartPoints -= performing.cost();
        }

        else if (pendingAction is Move)
        {
            MoveEvent e = new MoveEvent(this, (Move)pendingAction);
            GameLoop.addToList(e);
            performing   = e;
            heartPoints -= performing.cost();
        }

        if (heartPoints <= 0)
        {
            heartPoints = 1;
        }
    }
Пример #10
0
 public override void Awake()
 {
     base.Awake();
     OnAttack += Attack;
     //TODO
     GetComponentInChildren <HealthManager>().OnDie += Die;
 }
Пример #11
0
    public override void OnPointerUp(PointerEventData eventData)
    {
        AttackEvent?.Invoke();

        background.gameObject.SetActive(false);
        base.OnPointerUp(eventData);
    }
Пример #12
0
    public void Operation(IDuel duel, Card card, LauchEffect effect, Group group = null)
    {
        AttackEvent e  = duel.GetCurAttackEvent();
        StateEffect e1 = new StateEffect();

        e1.SetRangeArea(ComVal.Area_Monster);
        e1.SetCategory(ComVal.category_stateEffect | ComVal.category_limitTime);
        e1.SetCardEffectType(ComVal.cardEffectType_Single | ComVal.cardEffectType_normalStateEffect);
        e1.SetStateEffectType(ComVal.stateEffectType_addAfkVal);

        if (e.Attacker.controller == card.controller)
        {
            e1.SetTarget(e.Attacker);
            e1.SetStateEffectVal(e.Attackeder.GetCurAfk());
        }
        else
        {
            e1.SetTarget(e.Attackeder);
            e1.SetStateEffectVal(e.Attacker.GetCurAfk());
        }

        e1.SetResetCode(ComVal.resetEvent_LeaveEndPhase, 0);
        duel.ResignEffect(e1, card, card.controller);
        duel.FinishHandle();
    }
Пример #13
0
    public override void OnInspectorGUI()
    {
        Hitbox h = (Hitbox)target;

        DrawDefaultInspector();
        if (coreData == null)
        {
            foreach (string guid in AssetDatabase.FindAssets("t: CoreData"))//looks at whole project for assets tagged CoreData
            {
                coreData = AssetDatabase.LoadAssetAtPath <CoreData>(AssetDatabase.GUIDToAssetPath(guid));
            }
        }
        if (GUILayout.Button("Apply Hitbox"))
        {
            state = coreData.characterStates[h.stateIndex];
            for (int i = 0; i < state.attacks.Count; i++)
            {
                AttackEvent atk = state.attacks[i];
                atk.hitBoxPos   = h.transform.localPosition;
                atk.hitBoxScale = h.transform.localScale;
            }
            EditorUtility.SetDirty(coreData);
            AssetDatabase.SaveAssets();
        }
    }
Пример #14
0
 public void Initialize()
 {
     AttackEvent.Subscribe(this, 0, Attack);
     DamageEvent.Subscribe(this, 0, Damage);
     DeathEvent.Subscribe(this, 0, Death);
     PlayEvent.Subscribe(this, 0, Play);
     TurnEvent.Subscribe(this, 0, NewTurn);
 }
Пример #15
0
        public override Card Instantiate()
        {
            var card = new FuriousWolf();

            card.Initialize();
            AttackEvent.Subscribe(card, 50, OnAttack);
            return(card);
        }
        public virtual void Execute()
        {
            // PublishEventNode
            var PublishEventNode1_Event = new AttackEvent();

            System.Publish(PublishEventNode1_Event);
            PublishEventNode1_Result = PublishEventNode1_Event;
        }
Пример #17
0
    // Use this for initialization
    void Awake()
    {
        anim = GetComponent <Animator>();

        OnAttack     = Nothing;
        OnExitAttack = Nothing;
        controller   = transform.root.GetComponent <Controller>();
    }
Пример #18
0
        void Awake()
        {
            Debug.Log("Enemy Awake");

            attackEvent = new AttackEvent();
            enemyData   = GetComponent <EnemyData>();
            enemyView   = GetComponent <EnemyView>();
        }
Пример #19
0
    public void Operation(IDuel duel, Card card, LauchEffect effect, Group group = null)
    {
        AttackEvent e = duel.GetCurAttackEvent();
        Card        c = e.Attackeder;

        duel.AddFinishHandle();
        duel.SendToMainDeck(ComVal.Area_Monster, c.ToGroup(), card, ComVal.reason_Effect, effect);
    }
Пример #20
0
        bool IAttack.ClickAttack(AttackEvent 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 diff     = eventArgs.ClickLocation.ToMapPos(Owner.EntityManager) - location.ToMapPos(Owner.EntityManager);
            var angle    = Angle.FromWorldVec(diff);

            if (target != null)
            {
                SoundSystem.Play(Filter.Pvs(Owner), _hitSound, target);
            }
            else
            {
                SoundSystem.Play(Filter.Pvs(Owner), _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);

            RefreshItemCooldown();

            return(true);
        }
Пример #21
0
        private void Verify(
            GameEntity attacker,
            GameEntity victim,
            GameEntity sensor,
            SenseType attackerSensed,
            SenseType victimSensed,
            AbilityAction abilityAction,
            GameManager manager,
            int?damage,
            GameEntity weapon      = null,
            string expectedMessage = "")
        {
            var languageService = manager.Game.Services.Language;

            var appliedEffects = new List <GameEntity>();

            if (damage.HasValue)
            {
                using (var damageEffectEntity = manager.CreateEntity())
                {
                    var entity = damageEffectEntity.Referenced;

                    var appliedEffect = manager.CreateComponent <EffectComponent>(EntityComponent.Effect);
                    appliedEffect.Amount           = damage.Value;
                    appliedEffect.EffectType       = EffectType.PhysicalDamage;
                    appliedEffect.AffectedEntityId = victim.Id;

                    entity.Effect = appliedEffect;

                    appliedEffects.Add(entity);
                }

                if (weapon != null)
                {
                    using (var weaponEffectEntity = manager.CreateEntity())
                    {
                        var entity = weaponEffectEntity.Referenced;

                        var appliedEffect = manager.CreateComponent <EffectComponent>(EntityComponent.Effect);
                        appliedEffect.Amount           = damage.Value;
                        appliedEffect.EffectType       = EffectType.Activate;
                        appliedEffect.TargetEntityId   = weapon.Id;
                        appliedEffect.AffectedEntityId = victim.Id;

                        entity.Effect = appliedEffect;

                        appliedEffects.Add(entity);
                    }
                }
            }

            var attackEvent = new AttackEvent(sensor, attacker, victim, attackerSensed, victimSensed,
                                              appliedEffects, abilityAction, weapon,
                                              ranged: weapon != null && (weapon.Item.Type & ItemType.WeaponRanged) != 0, hit: damage.HasValue);

            Assert.Equal(expectedMessage, languageService.GetString(attackEvent));
        }
Пример #22
0
        public void AddAttackEvent(AttackEvent attackEvent)
        {
            if (attackEvent.Source != Source || attackEvent.Target != Target)
            {
                throw new ArgumentException($"This damage info is for {Source} and {Target},"
                                            + $" but you're adding an event for {attackEvent.Source} and {attackEvent.Target}.");
            }

            switch (attackEvent.AttackResult)
            {
            case AttackResult.WeaponHit:
                WeaponDamage += attackEvent.Amount.Value;
                ++WeaponHits;
                // Logs don't report crits/glances for specials. Track normal hits so we can better approximate crit/glance chance.
                if (!attackEvent.IsSpecialDamage)
                {
                    ++NormalHits;
                    if (attackEvent.AttackModifier == AttackModifier.Crit)
                    {
                        CritDamage += attackEvent.Amount.Value;
                        ++Crits;
                    }
                    else if (attackEvent.AttackModifier == AttackModifier.Glance)
                    {
                        GlanceDamage += attackEvent.Amount.Value;
                        ++Glances;
                    }
                }
                break;

            case AttackResult.Missed:
                ++Misses;
                break;

            case AttackResult.NanoHit:
                NanoDamage += attackEvent.Amount.Value;
                ++NanoHits;
                break;

            case AttackResult.IndirectHit:
                IndirectDamage += attackEvent.Amount.Value;
                ++IndirectHits;
                break;

            case AttackResult.Absorbed:
                // Only an 〈Unknown〉 source for events where the attack results in an absorb, so don't bother.
                break;

            default: throw new NotImplementedException();
            }

            if (attackEvent.DamageType.HasValue)
            {
                _damageTypeHits.Increment(attackEvent.DamageType.Value, 1);
                _damageTypeDamages.Increment(attackEvent.DamageType.Value, attackEvent.Amount ?? 0);
            }
        }
Пример #23
0
        protected override bool OnHitEntities(IReadOnlyList <IEntity> entities, AttackEvent eventArgs)
        {
            if (!Activated || entities.Count == 0 || Cell == null)
            {
                return(true);
            }

            if (!Cell.TryUseCharge(EnergyPerUse))
            {
                return(true);
            }

            SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Weapons/egloves.ogg", Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f));

            foreach (var entity in entities)
            {
                if (!entity.TryGetComponent(out StunnableComponent? stunnable))
                {
                    continue;
                }

                if (!stunnable.SlowedDown)
                {
                    if (_robustRandom.Prob(_paralyzeChanceNoSlowdown))
                    {
                        stunnable.Paralyze(_paralyzeTime);
                    }
                    else
                    {
                        stunnable.Slowdown(_slowdownTime);
                    }
                }
                else
                {
                    if (_robustRandom.Prob(_paralyzeChanceWithSlowdown))
                    {
                        stunnable.Paralyze(_paralyzeTime);
                    }
                    else
                    {
                        stunnable.Slowdown(_slowdownTime);
                    }
                }
            }

            if (!(Cell.CurrentCharge < EnergyPerUse))
            {
                return(true);
            }

            SoundSystem.Play(Filter.Pvs(Owner), AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f));
            TurnOff();

            return(true);
        }
 private void shoot()
 {
     if (Time.time > _nextFire)
     {
         if (AttackEvent != null)
         {
             AttackEvent.Invoke();
         }
         _nextFire = Time.time + _fireRate;
     }
 }
Пример #25
0
        public static AttackEvent CreateAttackEvent(Creature nAtt, Creature nDef)
        {
            AttackEvent aEvent = new AttackEvent(nAtt, nDef);

            aEvent.CreateTime   = Game.TurnsPassed;
            aEvent.ActivateTime = Game.TurnsPassed + 1;

            nAtt.State = Creature.EntityState.BUSY;

            return(aEvent);
        }
Пример #26
0
 public void RegisterEvent(AttackEvent finishedEvent, AttackEvent avalibleEvent)
 {
     if (finishedEvent != null)
     {
         WeaponFinishedEvent += finishedEvent;
     }
     if (avalibleEvent != null)
     {
         WeaponAvalibleEvent += avalibleEvent;
     }
 }
Пример #27
0
        public virtual Card Instantiate()
        {
            var card = new Card(name, description, MANA, ATTACK, HEALTH);

            AttackEvent.Subscribe(card, 0, Attack);
            DamageEvent.Subscribe(card, 0, Damage);
            DeathEvent.Subscribe(card, 0, Death);
            PlayEvent.Subscribe(card, 0, Play);
            TurnEvent.Subscribe(card, 0, NewTurn);
            return(card);
        }
Пример #28
0
        void ILogicNotifycationHandler.Handle(ILogicNotifycation notify)
        {
            if (notify is AttackEvent)
            {
                AttackEvent eventArgs = (AttackEvent)notify;

                Sprite sprite = (GuiImage)"[email protected]?208-213";
                sprite.Animation.Speed = 10;
                view.Particles.Add(new StaticAnimationParticle(sprite, eventArgs.Attacker));
                view.Particles.Add(new StaticAnimationParticle(sprite.Clone(), eventArgs.Defender));
            }
        }
Пример #29
0
 public void NewEvent(AttackEvent ae)
 {
     for (int i = 0; i < listeners.Count; i++)
     {
         listeners[i].ReceiveAttackEvent(ae);
     }
     ae.pass = 1;
     for (int i = 0; i < listeners.Count; i++)
     {
         listeners[i].ReceiveAttackEvent(ae);
     }
 }
Пример #30
0
 public bool CheckLauch(IDuel duel, Card card, LauchEffect effect, Code code)
 {
     if (code.reason.reason.IsBind(ComVal.reason_AttackDestroy))
     {
         AttackEvent e = duel.GetCurAttackEvent();
         if (e.Attacker == card)
         {
             return(true);
         }
     }
     return(false);
 }