Exemple #1
0
 private void ChangeAssignment(OpPosition pos, int userID)
 {
     // Only the FC can overwrite any position at any time
     // Users can move themselves only when freemove is on and the
     // position is empty
     if (isFC || (
             freeMove &&
             thisUser != null &&
             (userID == thisUser.profile.id || (
                  userID == -1 && pos.filledById == thisUser.profile.id
                  )) &&
             pos.filledByPointer == null
             ))
     {
         MessageRouter.Instance.Send(
             MessageRouter.Service.Ops,
             new ANWI.Messaging.Ops.AssignUser()
         {
             opUUID       = opUUID,
             positionUUID = pos.uuid,
             userId       = userID
         },
             null
             );
     }
 }
Exemple #2
0
        public void AddPosition(string unitUUID, List <int> roleID)
        {
            List <OpPosition> newPositions = new List <OpPosition>();

            foreach (int id in roleID)
            {
                OpPosition pos = new OpPosition()
                {
                    uuid            = ANWI.Utility.UUID.GenerateUUID(),
                    unitUUID        = unitUUID,
                    critical        = false,
                    filledById      = -1,
                    filledByPointer = null,
                    role            = OperationRole.FetchById(id)
                };

                fleet.AddPosition(pos);
                newPositions.Add(pos);
            }

            PushToAll(new ANWI.Messaging.Ops.UpdatePositions(
                          newPositions,
                          null,
                          null));
        }
Exemple #3
0
        private void PositionGrid_Drop(object sender, DragEventArgs e)
        {
            Grid          grid = sender as Grid;
            OpPosition    pos  = grid.DataContext as OpPosition;
            OpParticipant user = (draggedItem.DataContext as OpParticipant);

            ChangeAssignment(pos, user.profile.id);
        }
        private void Context_DeletePosition(object sender, RoutedEventArgs e)
        {
            OpPosition pos = (sender as MenuItem).DataContext as OpPosition;

            MessageRouter.Instance.Send(
                MessageRouter.Service.Ops,
                new ANWI.Messaging.Ops.DeletePosition()
            {
                opUUID  = opUUID,
                posUUID = pos.uuid
            },
                null);
        }
        private void Context_CriticalPosition(object sender, RoutedEventArgs e)
        {
            MenuItem   item = sender as MenuItem;
            OpPosition pos  = (item).DataContext as OpPosition;

            MessageRouter.Instance.Send(
                MessageRouter.Service.Ops,
                new ANWI.Messaging.Ops.SetPositionCritical()
            {
                opUUID   = opUUID,
                posUUID  = pos.uuid,
                critical = !item.IsChecked
            },
                null);
        }
        public void AddPositions()
        {
            //
            // Add a Skipper position to the Legend of Dave
            OpPosition one = new OpPosition()
            {
                uuid     = "2jrj2jsnn3kjnksnr",
                unitUUID = "klkj4rlkjlkj2-asd-ei2",
                critical = false,
                role     = new OperationRole()
                {
                    name = "Skipper"
                }
            };

            fleet.AddPosition(one);

            Assert.AreEqual(4, fleet.TotalPositions);
            Assert.AreEqual(3, fleet.TotalCriticalPositions);

            Ship dave = fleet.GetUnit("klkj4rlkjlkj2-asd-ei2") as Ship;

            Assert.AreEqual(2, dave.positions.Count);
            Assert.AreEqual("2jrj2jsnn3kjnksnr", dave.positions[1].uuid);

            //
            // Add a copilot position to Dickthunder 1
            OpPosition two = new OpPosition()
            {
                uuid     = "4832yufdjn45iua",
                unitUUID = "498osjblj4lksjlkaj",
                critical = false,
                role     = new OperationRole()
                {
                    name = "Co-Pilot"
                }
            };

            fleet.AddPosition(two);
            Assert.AreEqual(5, fleet.TotalPositions);
            Assert.AreEqual(3, fleet.TotalCriticalPositions);

            Boat d1 = fleet.GetUnit("498osjblj4lksjlkaj") as Boat;

            Assert.AreEqual("4832yufdjn45iua", d1.positions[1].uuid);
        }
Exemple #7
0
        public void SetPositionCritical(string uuid, bool crit)
        {
            OpPosition pos = fleet.GetPosition(uuid);

            if (pos != null)
            {
                pos.critical = crit;

                PushToAll(new ANWI.Messaging.Ops.UpdatePositions(
                              null,
                              new List <OpPosition>()
                {
                    pos
                },
                              null
                              ));
            }
        }
Exemple #8
0
        private void ProcessUpdatePositions(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.UpdatePositions up
                = p as ANWI.Messaging.Ops.UpdatePositions;

            if (up.added != null)
            {
                foreach (OpPosition pos in up.added)
                {
                    fleet.AddPosition(pos);
                }
            }

            if (up.changed != null)
            {
                foreach (OpPosition pos in up.changed)
                {
                    OpPosition old = fleet.GetPosition(pos.uuid);
                    if (old != null)
                    {
                        old.critical = pos.critical;
                    }
                }
            }

            if (up.removed != null)
            {
                foreach (string rem in up.removed)
                {
                    fleet.DeletePosition(rem);
                }
            }

            RebuildC2();

            NotifyPropertyChanged(string.Empty);
        }
        private void Context_Unassign(object sender, RoutedEventArgs e)
        {
            OpPosition pos = (sender as MenuItem).DataContext as OpPosition;

            ChangeAssignment(pos, -1);
        }
        private void Context_AssignSelf(object sender, RoutedEventArgs e)
        {
            OpPosition pos = (sender as MenuItem).DataContext as OpPosition;

            ChangeAssignment(pos, thisUser.profile.id);
        }
Exemple #11
0
        List_WingCrew_DoubleClick(object sender, RoutedEventArgs e)
        {
            OpPosition pos = (sender as ContentControl).DataContext as OpPosition;

            ChangeAssignment(pos, thisUser.profile.id);
        }
Exemple #12
0
        List_Positions_DoubleClick(object sender, RoutedEventArgs e)
        {
            OpPosition pos = (sender as ListBoxItem).DataContext as OpPosition;

            ChangeAssignment(pos, thisUser.profile.id);
        }