private void Update() { if (!this.m_bActive) { return; } this.m_bActive = false; for (int i = 0; i < this.m_SthList.Count; i++) { XSth xSth = this.m_SthList[i]; if (xSth.bEnable) { this.m_bActive = true; if (!xSth.Update(Time.deltaTime) && this.m_SthArrivedEventHandler != null) { this.m_SthArrivedEventHandler(this.m_ArrivedCount++); } if (xSth.DelayTime <= 0f) { xSth.Acceleration = this._GetAcceleration(xSth, Time.deltaTime); } } } if (!this.m_bActive && this.m_CollectFinishEventHandler != null) { this.m_CollectFinishEventHandler(); } }
private Vector3 _GetAcceleration(XSth sth, float t) { Vector3 localPosition = sth.Go.transform.localPosition; Vector3 vector = Vector3.zero; Vector3 normalized = (this.Des - localPosition).normalized; if (sth.State == XSth.SthState.FLAME_OUT) { vector += normalized * this.DesAcceleration; } Vector3 normalized2 = (this.Src - localPosition).normalized; if (sth.State == XSth.SthState.IDLE) { vector += normalized2 * this.SrcAcceleration; } if (sth.State == XSth.SthState.DIRECTION_ADJUSTING) { float num = normalized.x * sth.Speed.y - normalized.y * sth.Speed.x; Vector3 b = new Vector3(-sth.Speed.y, sth.Speed.x, sth.Speed.z); if ((b.x * sth.Speed.y - b.y * sth.Speed.x) * num < 0f) { b.x = -b.x; b.y = -b.y; } b = b.normalized * this.SthAcceleration; vector += b; } return(vector); }
private void _GenerateSth() { if (this.m_SthList.Count != this.Count) { this.m_CurSthGo.SetActive(true); for (int i = this.m_SthList.Count; i < this.Count; i++) { XSth xSth = new XSth(); GameObject gameObject = UnityEngine.Object.Instantiate(this.m_CurSthGo) as GameObject; gameObject.transform.parent = base.transform; gameObject.transform.localScale = Vector3.one; xSth.Go = gameObject; gameObject.SetActive(false); this.m_SthList.Add(xSth); } this.m_CurSthGo.SetActive(false); for (int j = this.m_SthList.Count - 1; j >= this.Count; j--) { this.m_SthList[j].Destroy(); this.m_SthList.RemoveAt(j); } } for (int k = 0; k < this.m_SthList.Count; k++) { this.m_SthList[k].bEnable = false; } }
public void SetSth(List <GameObject> goes) { for (int i = this.m_ExternalSthList.Count; i < goes.Count; i++) { XSth item = new XSth(); this.m_ExternalSthList.Add(item); } for (int j = this.m_ExternalSthList.Count - 1; j >= goes.Count; j--) { this.m_ExternalSthList.RemoveAt(j); } this.m_SthList = this.m_ExternalSthList; for (int k = 0; k < this.m_ExternalSthList.Count; k++) { this.m_SthList[k].Go = goes[k]; goes[k].SetActive(false); this.m_SthList[k].bEnable = false; } }
public void Emit() { float num = 0f; int i = 0; while (i < this.m_SthList.Count) { XSth xSth = this.m_SthList[i]; xSth.DelayTime = num; xSth.Speed = XSingleton <XCommon> .singleton.RandomFloat(this.MinEmitSpeed, this.MaxEmitSpeed) * this._RandEmitDir(); xSth.StartFindDesTime = XSingleton <XCommon> .singleton.RandomFloat(this.MinStartFindDesTime, this.MaxStartFindDesTime); xSth.Time = 0f; xSth.MinIdleSpeed = this.MinIdleSpeed; xSth.Go.transform.localPosition = this.Src; xSth.Des = this.Des; xSth.bEnable = true; i++; num += this.EmitInterval; } this.m_bActive = true; this.m_ArrivedCount = 0; }