public bool Tick(GTime time) { if (lastTime < 0) { startTime = time.Time; lastTime = time.Time - 0.001f; return(false); } var old = lastTime - startTime; var now = time.Time - startTime; for (var i = 0; i < Line.Points.Count; i++) { var point = Line.Points [i]; if (point.Time > old && point.Time <= now) { var layout = Line.FindLayoutByGuid(point.GUID); LayoutBaseLogic.EnableLayout(layout, this); } } lastTime = time.Time; var result = now > Line.Time; isfinshed = result; totalTime = now; return(result); }
public void Update(GTime now) { foreach (var i in _AttachElements) { i.Value.Update(now); } }
public override void Execute(GTime time, GObject current) { var per = this.Perceptipn as BattlePerception; per.CreateReleaser( key, new ReleaseAtTarget(current as BattleCharacter, target), ReleaserType.Magic); }
public override GAction GetAction(GTime time, GObject current) { var character = current as BattleCharacter; if (character.AIRoot != null) { character.AIRoot.Tick(); } return(GAction.Empty); }
public override void Update(GTime time) { base.Update(time); if (CurrentPath == null || CurrentPath.Count == 0) { return; } UpdatePath(time); }
public static GTime Min(GTime a, GTime b) { if (a.day > b.day) { return(b); } if (a.day < b.day) { return(a); } if (a.time > b.time) { return(b); } return(a); }
private void CheckEmptyMarkedCoords() { GTime currentTime = TimeManager.GameTime; for (int i = 0; i < emptyCoordTimes.Count; i++) { if (GTime.SecondsBetween(emptyCoordTimes[i], currentTime) > emptyCoordWaitTime) { emptyCoords.RemoveAt(i); emptyCoordTimes.RemoveAt(i); i--; } else { return; } } }
public override GAction GetAction(GTime time, GObject current) { //var per = this.Perception as BattlePerception; var missile = current as BattleMissile; switch (missile.State) { case MissileState.NoStart: { var distance = UVector3.Distance( missile.Releaser.ReleaserTarget.Releaser.View.Transform.position, missile.Releaser.ReleaserTarget.ReleaserTarget.View.Transform.position); missile.TotalTime = distance / missile.Layout.speed; missile.TimeStart = time.Time; missile.State = MissileState.Moving; missile.Releaser.OnEvent(Layout.EventType.EVENT_MISSILE_CREATE); } break; case MissileState.Moving: { if ((time.Time - missile.TimeStart) >= missile.TotalTime) { missile.Releaser.OnEvent(Layout.EventType.EVENT_MISSILE_HIT); missile.State = MissileState.Hit; } } break; case MissileState.Hit: { missile.Releaser.OnEvent(Layout.EventType.EVENT_MISSILE_DEAD); missile.State = MissileState.Death; } break; case MissileState.Death: GObject.Destory(missile); break; } return(GAction.Empty); }
//... void UpdatePath(GTime time) { isMoving = false; if (nextWaypoint > finalWaypoint) { CurrentPath = null; return; } if (nextWaypoint > finalWaypoint) { return; } if (this.syncIndex != nextWaypoint) { this.syncIndex = nextWaypoint; var notify = new Proto.Notify_CharacterPosition { LastPosition = this.transform.position.ToV3(), TargetPosition = CurrentPath[nextWaypoint].ToV3(), Index = this.Index }; this.PerceptionView.AddNotify(notify); } isMoving = true; var fullPath = CurrentPath[nextWaypoint] - CurrentPath[lastWaypoint]; //defines the path between lastWaypoint and nextWaypoint as a Vector3 faction_of_path_traveled += speed * time.DeltaTime; //animate along the path if (faction_of_path_traveled > fullPath.magnitude) //move to next waypoint { lastWaypoint++; nextWaypoint++; faction_of_path_traveled = 0; UpdatePath(time); return; } //we COULD use Translate at this point, but it's simpler to just compute the current position var pos = (fullPath.normalized * faction_of_path_traveled) + CurrentPath[lastWaypoint]; transform.position = pos; }
public void TickTimeLines(GTime time) { var current = _players.First; while (current != null) { if (current.Value.Tick(time)) { _players.Remove(current); } current = current.Next; } foreach (var i in _objs) { if (i.Value.Element.IsAliveAble) { if (i.Value.HaveLeftTime) { i.Value.time -= time.DeltaTime; var character = i.Value.Element as BattleCharacter; if (character != null) { if (i.Value.time <= 0) { character.SubHP(character.MaxHP); } } } continue; } else { _removeTemp.Enqueue(i.Key); OnEvent(EventType.EVENT_UNIT_DEAD); } } }
public static float SecondsBetween(GTime a, GTime b) { float seconds = 0f; do { if (a.day == b.day) { seconds += b.time - a.time; return(seconds); } if (a.day < b.day) { a.day++; seconds += SecondsPerDay; } if (a.day > b.day) { a.day--; seconds -= SecondsPerDay; } } while (a.day != b.day); return(b.time - a.time); }
public virtual void Update(GTime time) { }
public override GAction GetAction(GTime time, GObject current) { var releaser = current as MagicReleaser; releaser.TickTimeLines(time); switch (releaser.State) { case ReleaserStates.NOStart: { releaser.OnEvent(Layout.EventType.EVENT_START); releaser.SetState(ReleaserStates.Releasing); //tick if (releaser.Magic.triggerDurationTime > 0) { releaser.LastTickTime = time.Time; releaser.tickStartTime = time.Time; releaser.OnEvent(Layout.EventType.EVENT_TRIGGER); } } break; case ReleaserStates.Releasing: { if (releaser.Magic.triggerTicksTime > 0) { if (releaser.tickStartTime + releaser.Magic.triggerDurationTime > time.Time) { if (releaser.LastTickTime + releaser.Magic.triggerTicksTime < time.Time) { releaser.LastTickTime = time.Time; releaser.OnEvent(Layout.EventType.EVENT_TRIGGER); } break; } } if (releaser.IsCompleted) { releaser.SetState(ReleaserStates.ToComplete); } } break; case ReleaserStates.ToComplete: { releaser.OnEvent(Layout.EventType.EVENT_END); releaser.SetState(ReleaserStates.Completing); } break; case ReleaserStates.Completing: { if (releaser.IsCompleted) { releaser.SetState(ReleaserStates.Ended); } } break; case ReleaserStates.Ended: { if (releaser.IsCompleted) { GObject.Destory(releaser); } } break; } return(GAction.Empty); }
public override GAction GetAction(GTime time, GObject current) { return(GAction.Empty); }