public void OnAttack(InputAction.CallbackContext context) { if (context.phase == InputActionPhase.Performed) { AttackEvent.Invoke(); } }
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(); } }
//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); }
// 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; } } }
/// <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)); }
private void ProcessAttackEvent(AttackEvent kEvent) { KVector2 attackerPosition = kEvent.source; GameObject attacker = FruitonsGrid[attackerPosition.x, attackerPosition.y]; attacker.GetComponentInChildren <BoyFighterBattleAnimator>().Attack(() => AfterAttackAnimation(kEvent)); }
/// <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); } }
//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; } }
public override void Awake() { base.Awake(); OnAttack += Attack; //TODO GetComponentInChildren <HealthManager>().OnDie += Die; }
public override void OnPointerUp(PointerEventData eventData) { AttackEvent?.Invoke(); background.gameObject.SetActive(false); base.OnPointerUp(eventData); }
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(); }
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(); } }
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); }
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; }
// Use this for initialization void Awake() { anim = GetComponent <Animator>(); OnAttack = Nothing; OnExitAttack = Nothing; controller = transform.root.GetComponent <Controller>(); }
void Awake() { Debug.Log("Enemy Awake"); attackEvent = new AttackEvent(); enemyData = GetComponent <EnemyData>(); enemyView = GetComponent <EnemyView>(); }
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); }
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); }
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)); }
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); } }
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; } }
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); }
public void RegisterEvent(AttackEvent finishedEvent, AttackEvent avalibleEvent) { if (finishedEvent != null) { WeaponFinishedEvent += finishedEvent; } if (avalibleEvent != null) { WeaponAvalibleEvent += avalibleEvent; } }
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); }
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)); } }
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); } }
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); }