コード例 #1
0
        /// <summary>
        /// Carries out checks to see if they need to be warped by a warplate
        /// </summary>
        /// <param name="warpplateName">The warpplate to check against</param>
        private void CheckAndUseWarpplate(string warpplateName)
        {
            var warpplate = Manager.GetWarpplateByName(warpplateName);

            switch (warpplate.Type)
            {
            case 0:
                var destinationWarpplate = Manager.GetWarpplateByName(warpplate.Destination);
                CheckAndUseDestinationWarpplate(warpplate, destinationWarpplate);
                break;

            case 1:
                CheckAndUseDimensionWarpplate(warpplate);
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Updates or gives a warpplate a delay
        /// </summary>
        /// <param name="args">The command arguments</param>
        public async void SetWarpplateDelay(CommandArgs args)
        {
            // Use the given warpplate name or find the warpplate they are standing in
            string region = "";

            if (args.Parameters.Count == 3)
            {
                region = args.Parameters[1];
            }
            else if (args.Parameters.Count == 2)
            {
                region = Manager.InAreaWarpplateName(args.Player.TileX, args.Player.TileY);
            }
            else
            {
                args.Player.SendErrorMessage("Invalid syntax! Proper synatx: /wp delay [<warpplate name>] <delay in seconds>");
                args.Player.SendErrorMessage("Set 0 for immediate warp");
                return;
            }

            // Check if the warpplate exists
            Warpplate warpplate = Manager.GetWarpplateByName(region);

            if (warpplate == null)
            {
                args.Player.SendErrorMessage("No such warpplate");
                return;
            }

            // Update the delay of the given warpplate
            int Delay;

            if (int.TryParse(args.Parameters[args.Parameters.Count - 1], out Delay))
            {
                warpplate.Delay = Delay + 1;
                if (await Manager.UpdateWarpplate(warpplate.Name))
                {
                    args.Player.SendSuccessMessage("Set delay of {0} to {1} seconds", warpplate.Name, Delay);
                }
                else
                {
                    args.Player.SendErrorMessage("Something went wrong");
                }
            }
            else
            {
                args.Player.SendErrorMessage("Bad number specified");
            }
        }