void AddCurveToSequence( IWaypointCurve newCurveToAdd ) { thisCurveSequence.Add(newCurveToAdd); UnreserveCurve(newCurveToAdd); }
public void AppendWaypointCurveToSequence(IWaypointCurve curve) { IWaypointCurve lastWaypointCurve = thisCurveSequence[thisCurveSequence.Count - 1]; // IWaypointCurve newCurveToAdd = GetNewWaypointCurveToAddToSequence(); curve.Connect(lastWaypointCurve); AddCurveToSequence(curve); }
void SetPrevPointPosOnFirstCurvePointOnConnection( IWaypointCurve prevCurve ) { Vector3 prevCurveLastCurvePointPrevPosition = prevCurve.GetLastCurvePointPrevPosition(); ICurvePoint firstPointOfThisCurve = thisCurvePoints[0]; firstPointOfThisCurve.SetPrevPointPosition(prevCurveLastCurvePointPrevPosition); }
/* Curve other */ public void Connect(IWaypointCurve prevCurve) { Vector3 position = prevCurve.GetConnectionPosition(); Quaternion rotation = prevCurve.GetConnectionRotation(); SetPosition(position); SetRotation(rotation); CalculateCurve(); SetPrevPointPosOnFirstCurvePointOnConnection(prevCurve); }
public void RemoveWaypointCurveToReserve(IWaypointCurve curve) { if (thisCurveSequence.Contains(curve)) { curve.SetPosition(thisReservePosition); List <IWaypointCurve> reducedSequence = new List <IWaypointCurve>(thisCurveSequence); reducedSequence.Remove(curve); ReserveCurve(curve); thisCurveSequence = reducedSequence; } }
public void SetNewCurve(IWaypointCurve curve) { thisInitialEventPoint = 0f; thisCurrentCurve = curve; IWaypointEvent[] list = thisCurrentCurve.GetWaypointEvents(); Queue <IWaypointEvent> result = new Queue <IWaypointEvent>(); foreach (IWaypointEvent waypointEvent in list) { result.Enqueue(waypointEvent); waypointEvent.Reset(); } thisCurrentWaypontCurveEvents = result; }
public void CycleCurve() { /* move first group to reserve * get random one from reserve and place it */ if (ShouldCycle()) { RemoveFirstWaypointCurveToReserve(); // IWaypointCurve lastWaypointCurve = thisCurveSequence[thisCurveSequence.Count - 1]; IWaypointCurve newCurveToAdd = GetNewWaypointCurveToAddToSequence(); // newCurveToAdd.Connect(lastWaypointCurve); // AddCurveToSequence(newCurveToAdd); AppendWaypointCurveToSequence(newCurveToAdd); } }
void DrawWaypointEvents(Rect rect) { if (thisGameIsReady) { string result = ""; IWaypointsFollower follower = waypointsFollowerAdaptor.GetWaypointsFollower(); float normalizedPosOnCurve = follower.GetNormalizedPositionInCurve(); result += "normPos: " + normalizedPosOnCurve.ToString("N2") + "\n"; IWaypointCurveCycleManager curveManager = curveCycleManagerAdaptor.GetWaypointsManager(); int currentCurveIndex = gameManager.GetCurrentWaypointGroupIndex(); IWaypointCurve currentCurve = curveManager.GetAllWaypointCurves()[currentCurveIndex]; IWaypointEvent[] evnets = currentCurve.GetWaypointEvents(); result += "curve id: " + currentCurve.GetIndex().ToString() + "\n"; // foreach(IWaypointEvent wpEvent in evnets){ // string thisEventString = "\n"; // thisEventString += wpEvent.GetName() + ": " + wpEvent.GetEventPoint().ToString("N2"); // TargetType thisType = TargetType.Flyer; // bool isRare = false; // if(wpEvent is IShootingTargetSpawnWaypointEvent){ // IShootingTargetSpawnWaypointEvent spawnEvent = (IShootingTargetSpawnWaypointEvent)wpEvent; // isRare = spawnEvent.IsRare(); // thisType = spawnEvent.GetTargetType(); // IShootingTargetSpawnPoint spawnPoint = spawnEvent.GetSpawnPoint(); // thisEventString += ", sp: " + spawnPoint.GetName(); // IShootingTarget target = spawnPoint.GetSpawnedTarget(); // if(target != null) // thisEventString += ", tar: " + target.GetName(); // else // thisEventString += ", tar: null"; // } // Color col = GetStringColorForType(thisType, isRare); // thisEventString = DKUtility.DebugHelper.StringInColor(thisEventString, col); // result += thisEventString; // string executedString = ", "; // if(!wpEvent.IsExecuted()) // executedString += "pending"; // else // executedString += DKUtility.DebugHelper.RedString("executed"); // result += executedString; // } GUI.Label( rect, result ); } }
/* Cycling */ void ConnectWaypointCurveSequence() { IWaypointCurve prevWaypointCurve = null; foreach (IWaypointCurve curve in thisCurveSequence) { if (prevWaypointCurve == null) { ConnectCurveToInitialTransform(curve); } else { curve.Connect(prevWaypointCurve); } prevWaypointCurve = curve; } }
bool ShouldCycle() { if (thisCycleHasStarted) { return(true); } else { IWaypointCurve currentCurve = thisFollower.GetCurrentWaypointCurve(); int indexOfCurCurve = thisCurveSequence.IndexOf(currentCurve); if (indexOfCurCurve == thisIndexToStartCycle) { thisCycleHasStarted = true; return(true); } } return(false); }
void SetNewCurve( IWaypointCurve curve, float initialTime ) { thisCurrentCurve = curve; thisFollower.SetWaypointCurve(curve); thisRequiredTimeForCurrentCurve = curve.GetTotalDistance() / thisSpeed; thisTotalElapsedTimeOnCurrentCurve = initialTime; thisWaypointEventManager.SetNewCurve(curve); float initialEventPoint = 0f; if (initialTime != 0f) { initialEventPoint = initialTime / thisRequiredTimeForCurrentCurve; } thisWaypointEventManager.SetInitialEventPoint(initialEventPoint); }
public IWaypointCurve GetNextCurve(IWaypointCurve currentCurve) { if (!thisCurveSequence.Contains(currentCurve)) { throw new System.InvalidOperationException( "currentCurve is not in the sequence!" ); } int currentCurveIndexInSequence = thisCurveSequence.IndexOf(currentCurve); if (currentCurveIndexInSequence == thisCurveSequence.Count - 1) { return(null); } int newCurveIndexInSequence = currentCurveIndexInSequence + 1; IWaypointCurve result = thisCurveSequence[newCurveIndexInSequence]; return(result); }
public ConstArg( IProcessManager processManager, IWaypointsFollower follwer, float speed, int processOrder, IWaypointCurve initialCurve, IWaypointCurveCycleManager waypointsManager, float initialTime ) : base( processManager ) { thisFollower = follwer; thisSpeed = speed; thisProcessOrder = processOrder; thisInitialCurve = initialCurve; thisWaypointsManager = waypointsManager; thisInitialTime = initialTime; }
public IFollowWaypointProcess CreateFollowWaypointProcess( IWaypointsFollower follower, float speed, int processOrder, IWaypointCurve initialCurve, IWaypointCurveCycleManager waypointsManager, float initialTime ) { FollowWaypointProcess.IConstArg arg = new FollowWaypointProcess.ConstArg( thisProcessManager, follower, speed, processOrder, initialCurve, waypointsManager, initialTime ); return(new FollowWaypointProcess(arg)); }
protected override void UpdateProcessImple(float deltaT) { thisTotalElapsedTimeOnCurrentCurve += deltaT * thisTimeScale; if (RequiredTimeForCurrentCurveHasPassed()) { if (thisCycleManager != null) { IWaypointCurve nextCurve = thisCycleManager.GetNextCurve(thisCurrentCurve); if (nextCurve != null) { float residualTime = thisTotalElapsedTimeOnCurrentCurve - thisRequiredTimeForCurrentCurve; SetNewCurve( nextCurve, residualTime ); thisCycleManager.CycleCurve(); MoveFollower(); thisWaypointEventManager.ExecuteWaypointEventsUpTo( thisFollower, residualTime ); } else { Expire(); } } else { Expire(); } } else { MoveFollower(); } }
void UnreserveCurve(IWaypointCurve curve) { thisReservedCurves.Remove(curve); curve.OnUnreserve(); }
void RemoveFirstWaypointCurveToReserve() { IWaypointCurve firstCurveInSequence = thisCurveSequence[0]; RemoveWaypointCurveToReserve(firstCurveInSequence); }
public void SetWaypointCurve(IWaypointCurve curve) { thisCurrentWaypointCurve = curve; }
void ConnectCurveToInitialTransform(IWaypointCurve curve) { curve.SetLocalPosition(thisInitialCurvePosition); curve.SetLocalRotation(thisInitialCurveRotation); curve.CalculateCurve(); }
void ReserveCurve(IWaypointCurve curve) { curve.SetPosition(thisReservePosition); thisReservedCurves.Add(curve); curve.OnReserve(); }
public IWaypointCurve GetNextCurve() { IWaypointCurve currentCurve = GetCurrentCurve(); return(this.GetNextCurve(currentCurve)); }
public int GetCurrentCurveIDInSequence() { IWaypointCurve currentCurve = GetCurrentCurve(); return(thisCurveSequence.IndexOf(currentCurve)); }
public int GetWaypointCurveIndex(IWaypointCurve curve) { return(thisWaypointCurves.IndexOf(curve)); }
/* weird debug */ public int GetCurrentWaypointGroupIndex() { IWaypointCurve group = thisPlayerCharacterWaypointsFollower.GetCurrentWaypointCurve(); return(thisPCWaypointsManager.GetWaypointCurveIndex(group)); }