void MakeExplosion() { GameObject go = SimplePool.Spawn(ExplosionPrefab, _transform.position, Quaternion.identity); WeaponCannon wc = weapon as WeaponCannon; Collider2D[] colliders = new Collider2D[25]; // TODO: could be replaced with ellipse collider // damage in center int count = Physics2D.OverlapCircleNonAlloc(_transform.position, wc.FullDamageRange, colliders); for (int i = 0; i < count; i++) { ITargetable t = colliders[i].GetComponent <ITargetable>(); if (t != null) { LeanTween.delayedCall(DamageDelay, () => t.Damage(wc.Damage)); } colliders[i] = null; } // damage in full range count = Physics2D.OverlapCircleNonAlloc(_transform.position, wc.SplashDamageRange, colliders); for (int i = 0; i < count; i++) { ITargetable t = colliders[i].GetComponent <ITargetable>(); if (t != null) { LeanTween.delayedCall(DamageDelay, () => t.Damage((int)(wc.Damage * wc.SplashDamageFactor))); } } SimplePool.Despawn(gameObject); }
// public Hero target; // TODO // remove public virtual bool Play(ITargetable target = null) { if (!Card.OwnerCanPlay()) { return(false); } target.Damage(damage); Card.owner.hero.TappedMana += Card.manaCost; return(true); }
protected virtual void CheckHit() { if (target.Collider.bounds.Contains(_transform.position)) { target.Damage(weapon); SimplePool.Despawn(gameObject); } else { LeanTween.delayedCall(1f, () => SimplePool.Despawn(gameObject)); } }
protected virtual void Attack() { if (Target == null) { return; } if (Ranged) { ReleaseProjectile(); } else { Target.Damage(this); } }
private void Update() { DirectionVector = DestinationVector - transform.position; if ((Vector2)transform.position == (Vector2)DestinationVector) { if (!Target.IsDied) { Target.Damage(Weapon); } else { Weapon.Target = null; Weapon.HasTarget = false; } Destroy(gameObject); } Move(); }
public void SpawnHitscan(Hitscan temp, Vector3 position, Vector3 direction, Unit from, Status onHit, ITargetable goal) { Hitscan scan = new Hitscan(temp); scan.startPosition = position; scan.direction = direction; scan.SetFrom(from); scan.SetStatus(onHit); //hitscans.Add(scan); int index = IndexFromHitscanType(temp.GetHitscanType()); bool noGoal = IsNull(goal); // Raycast or do damage immediately. Use actual distance / hit information to inform visuals Vector3 dif = noGoal ? Vector3.zero : (position - goal.GetPosition()); float length = noGoal ? Raycast(scan) : dif.magnitude; if (!noGoal) // Has goal, do damage manually { goal.Damage(scan.GetDamage(), length, scan.GetDamageType()); vfx.SpawnEffect(VFXType.Hit_Near, position + direction * length, direction, scan.GetFrom().GetTeam()); } Vector3 size = new Vector3(pS[index].main.startSizeX.constant, length, 1); EmitParams param = new EmitParams() { position = position, velocity = direction * directionMult, startSize3D = size, //startColor = Random.value * Color.red + Random.value * Color.green + Random.value * Color.blue, startLifetime = scan.GetLifetime() // 2x just in case. Particles dying prematurely is the worst thing that could happen to this system }; pS[index].Emit(param, 1); }
protected override void Tick() { base.Tick(); TargetUnit.Damage(Damage); }