コード例 #1
0
        public void AssigningUsers()
        {
            //
            // Assign Mazer as the Dave's skipper
            // Assign Timmy as the Dave's pilot
            fleet.AssignPosition("2jrj2jsnn3kjnksnr", roster[0]);
            fleet.AssignPosition("409ueomnllknqlknlkn", roster[1]);

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

            Assert.AreEqual(roster[0], dave.positions[1].filledByPointer);
            Assert.AreEqual(roster[1], dave.positions[0].filledByPointer);

            //
            // Assign Karen as the Dickthunder 1 Pilot
            fleet.AssignPosition("4uvlkjlkj3qrlkj", roster[2]);

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

            Assert.AreEqual(roster[2], d1.positions[0].filledByPointer);

            //
            // Replace Karen with Sinai
            fleet.AssignPosition("4uvlkjlkj3qrlkj", roster[3]);
            Assert.AreEqual(roster[3], d1.positions[0].filledByPointer);
            Assert.IsNull(roster[2].position);

            //
            // Assign Karen to Dickthunder 1 Co-Pilot
            fleet.AssignPosition("4832yufdjn45iua", roster[2]);
            Assert.AreEqual(roster[2], d1.positions[1].filledByPointer);
        }
コード例 #2
0
        ChangeAssignment(string posUUID, int userID)
        {
            if (posUUID == "" && userID != -1)
            {
                OpParticipant user = GetParticipant(userID);
                if (user == null)
                {
                    return;
                }

                // Unassign this user
                if (user.position != null)
                {
                    fleet.ClearPosition(user.position.uuid);

                    PushToAll(new ANWI.Messaging.Ops.UpdateAssignments(
                                  null,
                                  new List <int>()
                    {
                        userID
                    },
                                  null));
                }
            }
            else if (userID == -1 && posUUID != "")
            {
                // Unassign this position
                fleet.ClearPosition(posUUID);

                PushToAll(new ANWI.Messaging.Ops.UpdateAssignments(
                              null,
                              null,
                              new List <string>()
                {
                    posUUID
                }));
            }
            else
            {
                OpParticipant user = GetParticipant(userID);
                if (user == null)
                {
                    return;
                }

                // Assign user to this position
                fleet.AssignPosition(posUUID, user);

                PushToAll(new ANWI.Messaging.Ops.UpdateAssignments(
                              new List <System.Tuple <int, string> >()
                {
                    new System.Tuple <int, string>(userID, posUUID),
                },
                              null, null));
            }
        }
コード例 #3
0
        private void ProcessUpdateAssignments(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Ops.UpdateAssignments au
                = p as ANWI.Messaging.Ops.UpdateAssignments;

            if (au.added != null)
            {
                foreach (Tuple <int, string> add in au.added)
                {
                    OpParticipant member = GetParticipant(add.Item1);
                    if (member != null)
                    {
                        fleet.AssignPosition(add.Item2, member);
                    }
                }
            }

            if (au.removedByUser != null)
            {
                foreach (int rem in au.removedByUser)
                {
                    OpParticipant member = GetParticipant(rem);
                    if (member != null && member.position != null)
                    {
                        fleet.ClearPosition(member.position.uuid);
                    }
                }
            }

            if (au.removedByUUID != null)
            {
                foreach (string rem in au.removedByUUID)
                {
                    fleet.ClearPosition(rem);
                }
            }

            RebuildC2();

            NotifyPropertyChanged(string.Empty);
        }