Example #1
0
 void AddCurveToSequence(
     IWaypointCurve newCurveToAdd
     )
 {
     thisCurveSequence.Add(newCurveToAdd);
     UnreserveCurve(newCurveToAdd);
 }
Example #2
0
        public void AppendWaypointCurveToSequence(IWaypointCurve curve)
        {
            IWaypointCurve lastWaypointCurve = thisCurveSequence[thisCurveSequence.Count - 1];

            // IWaypointCurve newCurveToAdd = GetNewWaypointCurveToAddToSequence();
            curve.Connect(lastWaypointCurve);
            AddCurveToSequence(curve);
        }
Example #3
0
        void SetPrevPointPosOnFirstCurvePointOnConnection(
            IWaypointCurve prevCurve
            )
        {
            Vector3     prevCurveLastCurvePointPrevPosition = prevCurve.GetLastCurvePointPrevPosition();
            ICurvePoint firstPointOfThisCurve = thisCurvePoints[0];

            firstPointOfThisCurve.SetPrevPointPosition(prevCurveLastCurvePointPrevPosition);
        }
Example #4
0
        /* Curve other */
        public void Connect(IWaypointCurve prevCurve)
        {
            Vector3    position = prevCurve.GetConnectionPosition();
            Quaternion rotation = prevCurve.GetConnectionRotation();

            SetPosition(position);
            SetRotation(rotation);
            CalculateCurve();
            SetPrevPointPosOnFirstCurvePointOnConnection(prevCurve);
        }
Example #5
0
        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;
        }
Example #7
0
 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
                    );
            }
        }
Example #9
0
        /* Cycling */
        void ConnectWaypointCurveSequence()
        {
            IWaypointCurve prevWaypointCurve = null;

            foreach (IWaypointCurve curve in thisCurveSequence)
            {
                if (prevWaypointCurve == null)
                {
                    ConnectCurveToInitialTransform(curve);
                }
                else
                {
                    curve.Connect(prevWaypointCurve);
                }
                prevWaypointCurve = curve;
            }
        }
Example #10
0
 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);
 }
Example #11
0
        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);
        }
Example #12
0
        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);
        }
Example #13
0
            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));
        }
Example #15
0
 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();
     }
 }
Example #16
0
 void UnreserveCurve(IWaypointCurve curve)
 {
     thisReservedCurves.Remove(curve);
     curve.OnUnreserve();
 }
Example #17
0
        void RemoveFirstWaypointCurveToReserve()
        {
            IWaypointCurve firstCurveInSequence = thisCurveSequence[0];

            RemoveWaypointCurveToReserve(firstCurveInSequence);
        }
Example #18
0
 public void SetWaypointCurve(IWaypointCurve curve)
 {
     thisCurrentWaypointCurve = curve;
 }
Example #19
0
 void ConnectCurveToInitialTransform(IWaypointCurve curve)
 {
     curve.SetLocalPosition(thisInitialCurvePosition);
     curve.SetLocalRotation(thisInitialCurveRotation);
     curve.CalculateCurve();
 }
Example #20
0
 void ReserveCurve(IWaypointCurve curve)
 {
     curve.SetPosition(thisReservePosition);
     thisReservedCurves.Add(curve);
     curve.OnReserve();
 }
Example #21
0
        public IWaypointCurve GetNextCurve()
        {
            IWaypointCurve currentCurve = GetCurrentCurve();

            return(this.GetNextCurve(currentCurve));
        }
Example #22
0
        public int GetCurrentCurveIDInSequence()
        {
            IWaypointCurve currentCurve = GetCurrentCurve();

            return(thisCurveSequence.IndexOf(currentCurve));
        }
Example #23
0
 public int GetWaypointCurveIndex(IWaypointCurve curve)
 {
     return(thisWaypointCurves.IndexOf(curve));
 }
        /* weird debug */
        public int GetCurrentWaypointGroupIndex()
        {
            IWaypointCurve group = thisPlayerCharacterWaypointsFollower.GetCurrentWaypointCurve();

            return(thisPCWaypointsManager.GetWaypointCurveIndex(group));
        }