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

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

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

            SetPosition(position);
            SetRotation(rotation);
            CalculateCurve();
            SetPrevPointPosOnFirstCurvePointOnConnection(prevCurve);
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 8
0
        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
                    );
            }
        }
Exemplo n.º 9
0
        /* Cycling */
        void ConnectWaypointCurveSequence()
        {
            IWaypointCurve prevWaypointCurve = null;

            foreach (IWaypointCurve curve in thisCurveSequence)
            {
                if (prevWaypointCurve == null)
                {
                    ConnectCurveToInitialTransform(curve);
                }
                else
                {
                    curve.Connect(prevWaypointCurve);
                }
                prevWaypointCurve = curve;
            }
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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();
     }
 }
Exemplo n.º 16
0
 void UnreserveCurve(IWaypointCurve curve)
 {
     thisReservedCurves.Remove(curve);
     curve.OnUnreserve();
 }
Exemplo n.º 17
0
        void RemoveFirstWaypointCurveToReserve()
        {
            IWaypointCurve firstCurveInSequence = thisCurveSequence[0];

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

            return(this.GetNextCurve(currentCurve));
        }
Exemplo n.º 22
0
        public int GetCurrentCurveIDInSequence()
        {
            IWaypointCurve currentCurve = GetCurrentCurve();

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

            return(thisPCWaypointsManager.GetWaypointCurveIndex(group));
        }