public override bool ShouldPickup(Effectable eff) { var res = eff.GetComponent <Resources>(); if (res != null) { return(true); } return(false); }
public override bool ShouldPickup(Effectable eff) { var res = eff.GetComponent <Entities.Character.Player>(); if (res != null) { return(true); } return(false); }
public override bool AddEffect(Effectable eff) { var res = eff.GetComponent <Entities.Character.Player>(); if (res != null) { var amount = GameManager.Instance.rand.RandomIntInRange(minMaxAmount.x, minMaxAmount.y); res.maxBombs += amount; } eff.effects.Remove(this); return(true); }
public override bool AddEffect(Effectable eff) { var res = eff.GetComponent <Resources>(); if (res != null) { var amount = GameManager.Instance.rand.RandomIntInRange(minMaxAmount.x, minMaxAmount.y); res.maxHealth += amount; res.Health = res.maxHealth; } eff.effects.Remove(this); return(true); }
public override bool PerTick(Effectable eff) { var dt = Time.deltaTime; foreach (Effect e in eff.effects) { e.ChangeTime(eff, ref dt); } time += dt; if (time < delayBetween) { return(false); } time = 0; var effectsToTransfer = eff.GetEffectSublist(1); effectsToTransfer.Remove(this); for (int i = effectsToTransfer.Count - 1; i >= 0; i--) { if (effectsToTransfer[i] is SpawnProjectileConstant) { effectsToTransfer.RemoveAt(i); } } for (int i = 0; i < number; i++) { var angle = Mathf.PI / 4 + (i / (float)number) * 2 * Mathf.PI; var velocity = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)); var spawned = Instantiate(spawnOnHit); var newProj = spawned.GetComponent <Projectile>(); if (newProj != null) { newProj.AddEffects(effectsToTransfer); newProj.doNotHit = eff.GetComponent <Resources>(); newProj.doNotHitLayers = eff.gameObject.layer; newProj.SetVelocity(velocity * speed); } spawned.transform.parent = GameManager.Instance.holder.transform; newProj.transform.position = eff.transform.position + new Vector3(velocity.x, velocity.y, 0) * 0.1f; } return(true); }
public void Hit(Effectable eff) { var effectsToTransfer = eff.GetEffectSublist(1); effectsToTransfer.Remove(this); var spawned = GameObject.Instantiate(spawnOnHit); var newEff = spawned.GetComponent <Effectable>(); if (newEff != null) { newEff.AddEffects(effectsToTransfer); newEff.doNotHit = eff.GetComponent <Resources>(); } spawned.transform.position = eff.transform.position; spawned.transform.parent = GameManager.Instance.holder.transform; }
public override bool PerTick(Effectable eff) { var dt = Time.deltaTime; foreach (Effect e in eff.effects) { e.ChangeTime(eff, ref dt); } time += dt; if (time > fireTime) { time = 0; var spawned = GameObject.Instantiate(firePrefab); spawned.transform.position = eff.transform.position; spawned.transform.parent = GameManager.Instance.holder.transform; var proj = spawned.GetComponent <Effectable>(); if (proj != null) { var effectsToTransfer = eff.GetEffectSublist(1); for (int i = effectsToTransfer.Count - 1; i >= 0; i--) { if (effectsToTransfer[i] is FireOnTick) { effectsToTransfer.RemoveAt(i); } } proj.AddEffects(eff.GetEffectSublist(1)); proj.doNotHit = eff.GetComponent <Resources>(); } return(true); } return(false); }
public override bool PerTick(Effectable eff) { if (collider == null) { collider = eff.GetComponent <Collider2D>(); } if (collider == null) { return(false); } var num = collider.OverlapCollider(filter, results); bool hasHit = false; for (int i = 0; i < num; i++) { if (results[i].gameObject.layer == eff.doNotHitLayers) { continue; } if (results[i].gameObject == eff.gameObject) { continue; } if (results[i].gameObject.transform.position.z > 1) { continue; } var res = results[i].GetComponent <Resources>(); if (res != null && res != eff.doNotHit) { float curDamage = damage; foreach (Effect e in eff.effects) { e.ChangeStrength(eff, ref curDamage); } if (res.Damage((int)curDamage)) { hasHit = true; if (eff is Projectile) { var proj = eff as Projectile; OnHitEffects(proj, -proj.GetVelocity(), res); } else { OnHitEffects(eff, res); } } } } if (hasHit && destroyOnTouch) { eff.Destroy(); } return(hasHit); }