コード例 #1
0
        private void MoveStep(Step step, int direction)
        {
            direction = Math.Sign(direction);

            var startIndex = Targets.IndexOf(step);

            if (startIndex == -1)
            {
                return;
            }


            var newIndex = startIndex + direction;

            if (newIndex == Targets.Count)
            {
                return;
            }

            if (newIndex == -1)
            {
                return;
            }


            Targets.RemoveAt(startIndex);
            Targets.Insert(newIndex, step);

            TargetOrderChanged();
        }
コード例 #2
0
 // Called when a trackable is destroyed in the scene
 protected virtual void OnTrackableUnregistered(Trackable trackable)
 {
     if (trackingStatesByID[trackable.TrackableID] != TrackingState.NotTracked)
     {
         int index = Targets.IndexOf(trackable);
         if (index != -1)
         {
             Targets.RemoveAt(index);
             OnStoppedTracking(trackable);
         }
     }
 }
コード例 #3
0
ファイル: Message.cs プロジェクト: sdercolin/ciphervitx-unity
 public bool RemoveTarget(Card target)
 {
     if (Targets.Contains(target))
     {
         int index = Targets.IndexOf(target);
         ToFrontFieldList.RemoveAt(index);
         ActionedList.RemoveAt(index);
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #4
0
ファイル: Simulation.cs プロジェクト: muyangren499/UAVBCI
        /// <summary>
        /// Run this instance of the simulation.
        /// </summary>
        public void Run(bool verbose)
        {
            State.MoveDrone(StartLocation, new Vector2D(0, 0), 0);
            State.CurrentTarget = Targets[0];

            while (!IsFinished && CurrentEpoch < (double)MaxEpochs)
            {
                Vector2D optimal_dir = State.CurrentTarget - State.DroneLocation;
                optimal_dir = optimal_dir.GetNormalized();

                // Compute input movement direction.
                Vector2D dir_input = InputGenerator.ComputeNewDirection(State);

                // Send state to INTELLIGENCE, receive alternate movement vector.
                Vector2D dir_intelligence = Intelligence.ComputeCommand(State, dir_input);

                // Combine movement vectors.
                double x = dir_intelligence.X * IntelligenceFactor + dir_input.X * (1 - IntelligenceFactor);
                double y = dir_intelligence.Y * IntelligenceFactor + dir_input.Y * (1 - IntelligenceFactor);

                // Apply command.
                Vector2D newPos = State.DroneLocation + new Vector2D(x, y);

                // Go to next step.
                CurrentEpoch++;
                State.MoveDrone(newPos, dir_input, CurrentEpoch);

                // Print some debugging information.
                if (verbose)
                {
                    Console.WriteLine("\nEpoch #{0}", CurrentEpoch);
                    Console.WriteLine("Location: {0}, Target: {1}", State.DroneLocation, State.CurrentTarget);
                    Console.WriteLine("Input: {0}", dir_input);
                    Console.WriteLine("Intelligence: {0}", dir_intelligence);
                    Console.WriteLine("Final: {0}", new Vector2D(x, y));
                }

                // Advance to next target if required.
                if (AtTarget())
                {
                    if (!IsFinished)
                    {
                        State.CurrentTarget = Targets[Targets.IndexOf(State.CurrentTarget) + 1];
                    }
                }
            }
        }
コード例 #5
0
        private void DeleteTarget()
        {
            var vm = m_targetCv.CurrentItem as TargetViewModel;

            if (vm != null)
            {
                int currentIndex = Targets.IndexOf(vm);
                Targets.Remove(vm);

                // Select next item in the list
                currentIndex = Math.Min(currentIndex, Targets.Count - 1);
                if (currentIndex > 0)
                {
                    Targets[currentIndex].IsSelected = true;
                }
            }
        }
コード例 #6
0
        private void HandleStepReplacementRequested(Step oldStep, Step newStep)
        {
            // TODO: Get old step index, move new one to there.

            var oldIndex = Targets.IndexOf(oldStep);

            AddTarget(newStep);

            RemoveTarget(oldStep);

            var newIndex = Targets.IndexOf(newStep);

            var moveCount = oldIndex - newIndex;
            var direction = Math.Sign(moveCount);

            for (var i = 0; i < moveCount * direction; i++)
            {
                MoveStep(newStep, Math.Sign(moveCount));
            }
        }
コード例 #7
0
ファイル: Message.cs プロジェクト: sdercolin/ciphervitx-unity
 public override void Do()
 {
     foreach (Card card in Targets)
     {
         if (Reason == null)
         {
             card.Controller.DeployAndCCCostCount += card.DeployCost;
         }
         Area toArea;
         if (ToFrontFieldList[Targets.IndexOf(card)])
         {
             toArea = card.Controller.FrontField;
         }
         else
         {
             toArea = card.Controller.BackField;
         }
         card.MoveTo(toArea);
         card.IsHorizontal = ActionedList[Targets.IndexOf(card)];
     }
 }