public void Update() { m_time_counter += Time.deltaTime; m_totol_time_counter += Time.deltaTime; if (FlyMode == FlyModeType.Linear) { Vector3 curt = CalcPos(m_time_counter); UpdateRotation(curt); transform.localPosition = curt; } if (m_time_counter >= m_curt_fly_time) { if (PrefabFxEnd != null) { FxBase fb = FxPool.Instance.Alloc(PrefabFxEnd, null); fb.transform.localPosition = CurtEnd; } } if (m_totol_time_counter >= FlyTime) { m_active_in_pool = false; BulletViewPool.Instance.Free(this); } else if (m_time_counter >= m_curt_fly_time) { ++m_end_index; m_time_counter = 0; m_curt_fly_time = Vector3.Distance(m_end[m_end_index], m_end[m_end_index - 1]) / Speed; if (FlyMode == FlyModeType.Laser) { transform.localPosition = CurtStart; UpdateRotation(CurtEnd); if (m_fb != null) { FxPool.Instance.Free(m_fb); m_fb = null; } if (PrefabFxFly != null) { m_fb = FxPool.Instance.Alloc(PrefabFxFly, null); m_fb.transform.localPosition = CurtStart; m_fb.transform.localRotation = transform.localRotation; m_fb.ScaleBody(Vector3.Distance(CurtStart, CurtEnd)); } } if (OnReachTarget != null) { OnReachTarget(this, m_end_index); } } }
public void Inactive() { if (m_fb != null) { FxPool.Instance.Free(m_fb); m_fb = null; } m_active_in_pool = false; gameObject.SetActive(false); }
public void Free(FxBase fb) { if (fb.FreeDelay > 0 && fb.CurtLife < 0) { fb.CountDown(); } else { fb.ActiveInPool = false; fb.transform.SetParent(m_fx_root.transform); } }
protected override void ActiveInternal(Creature target) { base.ActiveInternal(target); CreatureView cv = Owner.Owner.FCtrllerView.GetCreatureView(target); if (PrefabFxTarget != null) { FxBase fb = FxPool.Instance.Alloc(PrefabFxTarget); fb.transform.localPosition = cv.transform.localPosition; } }
public void Cache(string k, int count) { List <FxBase> fbs = new List <FxBase>(); for (int i = 0; i < count; ++i) { FxBase fb = Alloc(k, m_fx_root); fbs.Add(fb); } for (int i = 0; i < count; ++i) { Free(fbs[i]); } }
public void Active(Vector3 s, Creature[] targets) { m_active_in_pool = true; gameObject.SetActive(true); m_start = s; m_end = GetTargetPos(targets); m_end_index = 0; m_time_counter = 0; m_totol_time_counter = 0; m_fly_time = 0; Vector3 prev = s; for (int i = 0; i < m_end.Length; ++i) { m_fly_time += Vector3.Distance(prev, m_end[i]) / Speed; prev = m_end[i]; } m_curt_fly_time = Vector3.Distance(s, m_end[0]) / Speed; transform.localPosition = s; if (FlyMode == FlyModeType.Laser) { UpdateRotation(CurtEnd); if (PrefabFxFly != null) { m_fb = FxPool.Instance.Alloc(PrefabFxFly, null); m_fb.transform.localPosition = transform.localPosition; m_fb.transform.localRotation = transform.localRotation; m_fb.ScaleBody(Vector3.Distance(CurtStart, CurtEnd)); } } else if (FlyMode == FlyModeType.Linear) { Vector3 curt = CalcPos(0.02f); UpdateRotation(curt); if (PrefabFxFly != null) { m_fb = FxPool.Instance.Alloc(PrefabFxFly, gameObject); } } OnReachTarget = null; }
public FxBase Alloc(GameObject prefab, GameObject parent = null) { if (!m_pool.ContainsKey(prefab.name)) { m_pool[prefab.name] = new List <FxBase>(); } FxBase ret = null; foreach (FxBase m in m_pool[prefab.name]) { if (!m.ActiveInPool) { ret = m; break; } } if (ret == null) { FxBase new_m = Util.CreateGameObject(prefab, null).GetComponent <FxBase>(); new_m.Create(); ret = new_m; m_pool[prefab.name].Add(new_m); } ret.ActiveInPool = true; if (parent != null) { ret.transform.SetParent(parent.transform); } else { ret.transform.SetParent(m_fx_root.transform); } ret.transform.localPosition = Vector3.zero; ret.transform.localRotation = Quaternion.identity; ret.transform.localScale = Vector3.one; return(ret); }
public FxBase Alloc(string key, GameObject parent = null) { if (!m_pool.ContainsKey(key)) { m_pool[key] = new List <FxBase>(); } FxBase ret = null; foreach (FxBase m in m_pool[key]) { if (!m.ActiveInPool) { ret = m; break; } } if (ret == null) { FxBase new_m = ResMgr.Instance.CreateGameObject("Fx/" + key, null).GetComponent <FxBase>(); new_m.Create(); ret = new_m; m_pool[key].Add(new_m); } ret.ActiveInPool = true; if (parent != null) { ret.transform.SetParent(parent.transform); } else { ret.transform.SetParent(m_fx_root.transform); } ret.transform.localPosition = Vector3.zero; ret.transform.localRotation = Quaternion.identity; ret.transform.localScale = Vector3.one; return(ret); }
public iMACD(IFunction inData, int fast, int slow, int signalSMA) { _macdBase = new FxBase(inData, fast, slow); _macdSignal = new FxSignal(_macdBase, signalSMA); }
public FxSignal(FxBase macdBase, int period) : base(macdBase, period, FxMAMethod.Simple) { }
public void Free(FxBase fb) { if (fb.FreeDelay > 0 && fb.CurtLife < 0) { fb.CountDown(); } else { fb.ActiveInPool = false; fb.transform.parent = m_fx_root.transform; } }