public override void Reset(Vector2 position, Vector2 direction, float damage, float[] effects, string explosionSound) { mTarget = null; rectTransform.localRotation = Quaternion.identity; DOTween.To(() => speed, _ => speed = _, effects[0], 1f).SetEase(Ease.InQuart).SetDelay(0.5f); base.Reset(position, direction, damage, effects, explosionSound); }
public void SetData(VirusData v) { this.v = v; title.text = v.name; if (v.prefabPath != mLastPrefabPath) { if (mVirus != null) { DestroyImmediate(mVirus.gameObject); } var prefab = ResourceUtil.Load <VirusBase>(v.prefabPath); if (mVirus == null && prefab != null) { mVirus = Instantiate(prefab); if (mVirus != null) { mVirus.rectTransform.SetParent(modelRoot, false); mVirus.GetComponent <Collider2D>().enabled = false; mVirus.stunEffect.gameObject.SetActive(false); mVirus.cureEffect.gameObject.SetActive(false); mColorIndex = UnityEngine.Random.Range(0, 6); mVirus.SetColor(mColorIndex); } } mLastPrefabPath = v.prefabPath; } if (mVirus != null) { mVirus.stunEffect.Stop(true); } if (v.isMax) { fill.value = 1f; } else { fill.value = v.progress; } if (v.isUnlock) { if (v.isReceivable) { radioState.Radio(2); } else { radioState.Radio(1); } } else { radioState.Radio(0); } }
public static EventBullet Get(Action action, VirusBase target, float damage) { if (sIns == null) { sIns = new EventBullet(); } sIns.action = action; sIns.target = target; sIns.damage = damage; return(sIns); }
private void OnItemCollider(int index, VirusBase virus) { base.OnUnitFire(index); units[index].SetReady(false); Vector2 cDir = virus.position - units[index].position; Vector2 dir = (cDir + virus.direction).normalized; virus.SetDirection(dir); Unibus.Dispatch(EventBullet.Get(EventBullet.Action.HIT, virus, damage)); ExplosionWeaponCoverItem.Create().Reset(units[index].position, table.explosionSound); }
public static EventVirus Get(Action action, VirusBase virus, float value) { if (sIns == null) { sIns = new EventVirus(); } sIns.action = action; sIns.virus = virus; sIns.value = value; return(sIns); }
protected override void OnHit(VirusBase virus) { base.OnHit(virus); var hitPos = position + direction * 50; AreaHit(hitPos, effects[1] * 0.5f, (_vv) => { Unibus.Dispatch(EventBullet.Get(EventBullet.Action.HIT, _vv, damage)); }); ExplosionWeaponMissileBullet.Create().Reset(hitPos, effects[1], explosionSound); ForceRecycle(); }
protected override void OnHit(VirusBase virus) { base.OnHit(virus); if (virus.isAlive && !virus.isInvincible) { Vector2 cDir = virus.position - position; Vector2 dir = (cDir + virus.direction).normalized; virus.SetDirection(dir); Unibus.Dispatch(EventBullet.Get(EventBullet.Action.HIT, virus, damage)); } mHitCount--; if (mHitCount <= 0) { ForceRecycle(); AudioManager.PlaySound(explosionSound); } }
private void Refresh() { if (v.prefabPath != mLastPrefabPath) { if (mVirus != null) { DestroyImmediate(mVirus.gameObject); } var prefab = ResourceUtil.Load <VirusBase>(v.prefabPath); if (mVirus == null && prefab != null) { mVirus = Instantiate(prefab); if (mVirus != null) { mVirus.rectTransform.SetParent(modelRoot, false); mVirus.SetColor(ColorIndex); } } mLastPrefabPath = v.prefabPath; } if (mVirus != null) { mVirus.stunEffect.Stop(true); } if (v.isMax) { fill.value = 1f; fillText.text = ""; receiveBtn.SetData(LTKey.COLLECT_FINISH.LT(), true, false); } else { fill.value = v.progress; fillText.text = $"{v.collectCount - v.startCount}/{v.endCount - v.startCount}"; receiveBtn.SetData(LTKey.RECEIVE.LT(), !v.isReceivable, false); } diamondCount.text = "x" + D.I.GetBookDiamond(v.id); title.text = v.name; tips.text = v.tips; description.text = v.description; adReceiveRadio.Radio(!D.I.noAd && v.needPlayAd); }
void UpdateDirection() { if (mTarget == null) { mTarget = EntityManager.GetAll <VirusBase>().Min(a => (a as VirusBase).hp) as VirusBase; return; } if (!mTarget.isAlive) { return; } var fromRot = Quaternion.FromToRotation(Vector3.up, direction); var toRot = Quaternion.FromToRotation(Vector3.up, (mTarget.position - position).normalized); var maxAngle = effects[2] * Time.deltaTime * GlobalData.slowDownFactor; var tarRot = Quaternion.RotateTowards(fromRot, toRot, maxAngle); direction = tarRot * Vector3.up; rectTransform.localRotation = tarRot; }
protected float GetDist(VirusBase virus) { return(Mathf.Max(0, (position - virus.position).magnitude - radius - virus.radius)); }
protected float GetDist(Vector2 hitPos, VirusBase virus) { return(Mathf.Max(0, (hitPos - virus.position).magnitude - virus.radius)); }
protected virtual void OnHit(VirusBase virus) { }