public bool Play() { if (this.routeInfo.route.Count <= 1) { return(false); } this.Stop(false); Transform transform = this.listPoint[0].objectItem.get_transform(); this.childRoot.SetPositionAndRotation(transform.get_position(), transform.get_rotation()); int _index = 0; StudioTween _tween = this.SetPath((StudioTween)null, ref _index); while (_index < this.listPoint.Count) { this.SetPath(_tween, ref _index); if (!this.routeInfo.loop && _index == this.listPoint.Count - 1) { break; } } _tween.loopType = !this.routeInfo.loop ? StudioTween.LoopType.none : StudioTween.LoopType.loop; if (!this.routeInfo.loop) { _tween.onComplete += (StudioTween.CompleteFunction)(() => { this.routeInfo.active = false; Singleton <Studio.Studio> .Instance.routeControl.SetState(this.objectInfo, RouteNode.State.End); return(true); }); } this.routeInfo.active = true; return(true); }
public void Stop(bool _copy = true) { StudioTween.Stop(((Component)this.childRoot).get_gameObject()); if (this.disposable != null) { this.disposable.Dispose(); this.disposable = (SingleAssignmentDisposable)null; } if (!this.listPoint.IsNullOrEmpty <OCIRoutePoint>() && _copy) { this.disposable = new SingleAssignmentDisposable(); this.disposable.set_Disposable((IDisposable)DisposableExtensions.AddTo <IDisposable>((M0)ObservableExtensions.Subscribe <long>((IObservable <M0>)Observable.EveryLateUpdate(), (Action <M0>)(_ => { Transform transform = this.listPoint[0].objectItem.get_transform(); this.childRoot.SetPositionAndRotation(transform.get_position(), transform.get_rotation()); })), (Component)this.childRoot)); } this.nowIndex = 0; this.routeInfo.active = false; }
private StudioTween SetPath(StudioTween _tween, ref int _index) { if (!this.routeInfo.loop && _index == this.listPoint.Count - 1) { return(_tween); } int count = _index++; Hashtable args = new Hashtable(); switch (this.listPoint[count].connection) { case OIRoutePointInfo.Connection.Line: Transform[] transformArray; if (count == this.listPoint.Count - 1) { transformArray = new Transform[2] { this.listPoint[this.listPoint.Count - 1].objectItem.get_transform(), this.listPoint[0].objectItem.get_transform() } } ; else { transformArray = this.listPoint.Skip <OCIRoutePoint>(count).Take <OCIRoutePoint>(2).Select <OCIRoutePoint, Transform>((Func <OCIRoutePoint, Transform>)(v => v.objectItem.get_transform())).ToArray <Transform>(); } args.Add((object)"path", (object)transformArray); break; case OIRoutePointInfo.Connection.Curve: List <Transform> list = ((IEnumerable <Transform>) this.listPoint[count].transform).ToList <Transform>(); while (_index < this.listPoint.Count && (this.routeInfo.loop || _index != this.listPoint.Count - 1) && this.listPoint[_index].isLink) { list.AddRange((IEnumerable <Transform>) this.listPoint[_index].transform); ++_index; } if (_index >= this.listPoint.Count) { list.Add(this.listPoint[0].objectItem.get_transform()); } else { list.Add(this.listPoint[_index].objectItem.get_transform()); } args.Add((object)"path", (object)list.ToArray()); break; } args.Add((object)"speed", (object)(float)((double)this.listPoint[count].routePointInfo.speed * 10.0)); args.Add((object)"easetype", (object)this.listPoint[count].routePointInfo.easeType); switch (this.routeInfo.orient) { case OIRouteInfo.Orient.XY: args.Add((object)"orienttopath", (object)true); break; case OIRouteInfo.Orient.Y: args.Add((object)"orienttopath", (object)true); args.Add((object)"axis", (object)"y"); break; } if (!Object.op_Inequality((Object)_tween, (Object)null)) { return(StudioTween.MoveTo(((Component)this.childRoot).get_gameObject(), args)); } _tween.MoveTo(args); return(_tween); }
private bool Move() { StudioTween.Stop(((Component)this.childRoot).get_gameObject()); if (this.routeInfo.loop) { if (this.nowIndex >= this.listPoint.Count) { this.nowIndex = 0; } } else if (this.nowIndex >= this.listPoint.Count - 1) { this.routeInfo.active = false; Singleton <Studio.Studio> .Instance.routeControl.SetState(this.objectInfo, RouteNode.State.End); return(false); } Hashtable args = new Hashtable(); switch (this.listPoint[this.nowIndex].connection) { case OIRoutePointInfo.Connection.Line: Transform[] transformArray; if (this.nowIndex == this.listPoint.Count - 1) { transformArray = new Transform[2] { this.listPoint[this.listPoint.Count - 1].objectItem.get_transform(), this.listPoint[0].objectItem.get_transform() } } ; else { transformArray = this.listPoint.Skip <OCIRoutePoint>(this.nowIndex).Take <OCIRoutePoint>(2).Select <OCIRoutePoint, Transform>((Func <OCIRoutePoint, Transform>)(v => v.objectItem.get_transform())).ToArray <Transform>(); } args.Add((object)"path", (object)transformArray); break; case OIRoutePointInfo.Connection.Curve: List <Transform> list = ((IEnumerable <Transform>) this.listPoint[this.nowIndex].transform).ToList <Transform>(); if (this.nowIndex + 1 >= this.listPoint.Count) { list.Add(this.listPoint[0].objectItem.get_transform()); } else { list.Add(this.listPoint[this.nowIndex + 1].objectItem.get_transform()); } args.Add((object)"path", (object)list.ToArray()); break; } args.Add((object)"speed", (object)(float)((double)this.listPoint[this.nowIndex].routePointInfo.speed * 10.0)); args.Add((object)"easetype", (object)this.listPoint[this.nowIndex].routePointInfo.easeType); args.Add((object)"looptype", (object)StudioTween.LoopType.none); switch (this.routeInfo.orient) { case OIRouteInfo.Orient.XY: args.Add((object)"orienttopath", (object)true); break; case OIRouteInfo.Orient.Y: args.Add((object)"orienttopath", (object)true); args.Add((object)"axis", (object)"y"); break; } StudioTween.MoveTo(((Component)this.childRoot).get_gameObject(), args).onComplete += new StudioTween.CompleteFunction(this.Move); ++this.nowIndex; return(true); }