예제 #1
0
        private void objectiveTeleport(Client player, ObjectiveInfo objInfo)
        {
            Mission mission = API.getEntityData(player, "Mission");

            mission.teleportAllPlayers(objInfo.Location);
            objInfo.Status = true;
        }
예제 #2
0
 /*************************************************
  *                OBJECTIVE TYPES
  * **********************************************/
 private void objectiveLocation(Client player, ObjectiveInfo objInfo)
 {
     if (player.position.DistanceTo(objInfo.Location) <= 5)
     {
         objInfo.Status = true;
     }
 }
예제 #3
0
        /**
         * Setup a new objective.
         * */
        public void setupObjective(Vector3 location, ObjectiveTypes type, Vector3 direction = null)
        {
            ObjectiveInfo objInfo = new ObjectiveInfo();

            objInfo.Location = location;
            objInfo.Type     = type;
            objInfo.Progress = 0;
            objectives.Add(objInfo);

            if (direction != null)
            {
                objInfo.Direction = direction;
            }
        }
예제 #4
0
        /*********************************************
         * Verify based on objective type.
         * ******************************************/
        /*
         * private Tuple<bool, int, Vector3> checkForCompletion(Client player, Vector3 location, ObjectiveTypes type)
         * {
         * switch (type)
         * {
         *     case ObjectiveTypes.Location:
         *         return objectiveLocation(player);
         *     case ObjectiveTypes.Teleport:
         *         return objectiveTeleport(player, location);
         *     case ObjectiveTypes.Capture:
         *         return objectiveCapture(player, location);
         * }
         *
         * return Tuple.Create(false, 0, new Vector3());
         * }
         */

        private void checkForCompletion(Client player, ObjectiveInfo objInfo)
        {
            switch (objInfo.Type)
            {
            case ObjectiveTypes.Location:
                objectiveLocation(player, objInfo);
                return;

            case ObjectiveTypes.Teleport:
                objectiveTeleport(player, objInfo);
                return;

            case ObjectiveTypes.Capture:
                objectiveCapture(player, objInfo);
                return;
            }
        }
예제 #5
0
 private void objectiveCapture(Client player, ObjectiveInfo objInfo)
 {
     if (player.position.DistanceTo(objInfo.Location) <= 8)
     {
         double sinceWhen = objectiveCooldown.TimeOfDay.TotalSeconds;
         double timeNow   = DateTime.UtcNow.TimeOfDay.TotalSeconds;
         if (sinceWhen + 3 > timeNow)
         {
             return;
         }
         objectiveCooldown = DateTime.UtcNow;
         objInfo.Progress += 5;
         updateObjectiveProgression(player, objInfo.Location, objInfo.Progress);
         if (objInfo.Progress > 100)
         {
             objInfo.Status = true;
         }
     }
 }
예제 #6
0
        public void verifyObjective(Client player)
        {
            // Used to determine if another player is attempting to verify this objective. */
            if (checkingObjective)
            {
                return;
            }

            checkingObjective = true;

            // Just to prevent an error from occuring where too many requests get sent. */
            if (objectives.Count <= 0)
            {
                checkingObjective = false;
                return;
            }

            // Get the closest objective to the player.
            ObjectiveInfo closestObjective = null;

            foreach (ObjectiveInfo objInfo in objectives)
            {
                if (player.position.DistanceTo(objInfo.Location) <= 5)
                {
                    closestObjective = objInfo;
                    break;
                }

                if (objInfo.Type == ObjectiveTypes.Teleport)
                {
                    closestObjective = objInfo;
                    break;
                }
            }

            // If our closestObjective doesn't seem to exist, we'll just return.
            if (closestObjective == null)
            {
                checkingObjective = false;
                return;
            }

            // Send our objective information out, and wait for it to finish or hit a dead end.
            Thread thread = new Thread(() =>
            {
                checkForCompletion(player, closestObjective);
            });

            thread.Start();
            thread.Join();

            // Check if our tuple returned false.
            if (!closestObjective.Status)
            {
                checkingObjective = false;
                return;
            }

            // Get the players mission instance.
            Mission mission = API.getEntityData(player, "Mission");

            mission.removeObjectiveForAll(closestObjective.Location);

            API.triggerClientEvent(player, "Mission_Head_Notification", "~b~Minor Objective Complete", "Objective");

            // Remove dead objectives.
            objectives.Remove(closestObjective);

            // Check if all of our objectives are complete.
            if (objectives.Count >= 1)
            {
                checkingObjective = false;
                return;
            }

            mission.goToNextObjective();

            pauseState        = false;
            checkingObjective = false;
        }