예제 #1
0
	public void CreateRegionAndWarp(Creature creature)
	{
		// Get duration
		var time = 5;
		if (IsEnabled("ShortSheepProtection"))
			time = 3;

		time *= Minute;

		// Create region
		var region = new DynamicRegion(118);
		ChannelServer.Instance.World.AddRegion(region);

		var rnd = RandomProvider.Get();
		var sheepAmount = SheepAmount;

		// After x ms (success)
		var timer = SetTimeout(time, () =>
		{
			// Unofficial, I think the msg also depends on how well you did.
			// Official >10: Thanks to my dilligent supervision, over 10 sheep are safe.
			Send.Notice(creature, NoticeType.MiddleSystem, L("The time is over, you did it."));
			Send.RemoveQuestTimer(creature);
			creature.Keywords.Give("TirChonaill_Tutorial_Thinking");
			creature.Warp(1, 27622, 42125);
		});

		// Spawn sheep
		for (int i = 0; i < sheepAmount; ++i)
		{
			var pos = Center.GetRandomInRect(6000, 4000, rnd);

			var npc = new NPC(40001); // Sheep
			npc.Death += (killed, killer) =>
			{
				sheepAmount--;

				// Cancel if success is not possible anymore.
				if (sheepAmount < SheepMinAmount)
				{
					Send.Notice(creature, NoticeType.MiddleSystem, L("You've failed to save the sheep."));
					Send.RemoveQuestTimer(creature);
					StopTimer(timer);
					creature.Warp(1, 27622, 42125);
					return;
				}

				Send.UpdateQuestTimer(creature, L("Remaining sheep: {0}"), sheepAmount);
			};
			npc.Spawn(region.Id, pos.X, pos.Y);
		}

		// Spawn wolves
		for (int i = 0; i < WolfAmount; ++i)
			SpawnWolf(region.Id, rnd);

		// Warp to region and start visible timer
		creature.Warp(region.Id, 60000, 58000);
		Send.SetQuestTimer(creature, time, L("Protect the sheep from wolves"), L("Deadline: {0}"), L("Remaining sheep: {0}"), sheepAmount);
	}
예제 #2
0
    public void CreateRegionAndWarp(Creature creature)
    {
        var region = new DynamicRegion(118);

        ChannelServer.Instance.World.AddRegion(region);

        var rnd         = RandomProvider.Get();
        var sheepAmount = SheepAmount;

        // After x ms (success)
        var timer = SetTimeout(Time, () =>
        {
            // Unofficial, I think the msg also depends on how well you did.
            // Official >10: Thanks to my dilligent supervision, over 10 sheep are safe.
            Send.Notice(creature, NoticeType.MiddleSystem, L("The time is over, you did it."));
            Send.RemoveQuestTimer(creature);
            creature.Keywords.Give("TirChonaill_Tutorial_Thinking");
            creature.Warp(1, 27622, 42125);
        });

        // Spawn sheep
        for (int i = 0; i < sheepAmount; ++i)
        {
            var pos = Center.GetRandomInRect(6000, 4000, rnd);

            var npc = new NPC(40001);             // Sheep
            npc.Death += (killed, killer) =>
            {
                sheepAmount--;

                // Cancel if success is not possible anymore.
                if (sheepAmount < SheepMinAmount)
                {
                    Send.Notice(creature, NoticeType.MiddleSystem, L("You've failed to save the sheep."));
                    Send.RemoveQuestTimer(creature);
                    StopTimer(timer);
                    creature.Warp(1, 27622, 42125);
                    return;
                }

                Send.UpdateQuestTimerCounter(creature, L("Remaining sheep: {0}"), sheepAmount);
            };
            npc.Spawn(region.Id, pos.X, pos.Y);
        }

        // Spawn wolves
        for (int i = 0; i < WolfAmount; ++i)
        {
            SpawnWolf(region.Id, rnd);
        }

        // Warp to region and start visible timer
        creature.Warp(region.Id, 60000, 58000);
        Send.SetQuestTimer(creature, Time, L("Protect the sheep from wolves"), L("Deadline: {0}"), L("Remaining sheep: {0}"), sheepAmount);
    }
예제 #3
0
        // ---------------
        public override void OnInspectorGUI()
        {
            DynamicRegion c = (DynamicRegion)this.target;

            GUILayout.Box(GUIContent.none, CFEditorStyles.Inst.headerDynamicRegion, GUILayout.ExpandWidth(true));

            this.DrawWarnings(c);

            DynamicTouchControl tc = c.GetTargetControl();

            if (tc == null)
            {
                EditorGUILayout.HelpBox("There's no control linked to this Dynamic Region!", MessageType.Warning);
            }
            else
            {
                EditorGUILayout.HelpBox("Region linked to [" + tc.name + "]!", MessageType.Info);
            }

            this.DrawTouchContolGUI(c);
        }
예제 #4
0
        // ----------------------
        static public DynamicTouchControl CreateDynamicControlWithRegion(
            System.Type controlType,
            TouchControlPanel panel,
            string name,
            float size,
            //Sprite				sprite,
            Rect regionRect,
            float regionDepth,
            float controlDepth)
        {
            DynamicRegion region = (DynamicRegion)CreateStretchyRectTr(typeof(DynamicRegion), panel.transform, name + "-Region", regionRect, regionDepth);

            region.InvalidateHierarchy();

            DynamicTouchControl c = (DynamicTouchControl)CreateConstSizeRectTr(controlType, region.transform, name, new Vector2(0.5f, 0.5f),
                                                                               Vector2.zero, Vector2.one * size, (controlDepth - regionDepth));

            c.InvalidateHierarchy();

            c.SetTargetDynamicRegion(region);
            region.SetTargetControl(c);

            return(c);
        }
예제 #5
0
        // -----------------
        public void DrawDynamicTouchControlGUI(DynamicTouchControl c)
        {
            // Draw basic TouchControl GUI...

            this.DrawTouchContolGUI(c);


            // Dynamic-only GUI...

            bool
                fadeOutWhenReleased = c.fadeOutWhenReleased,
                startFadedOut       = c.startFadedOut;
            float
                fadeOutTargetAlpha = c.fadeOutTargetAlpha,
                fadeInDuration     = c.fadeInDuration,
                fadeOutDelay       = c.fadeOutDelay,
                fadeOutDuration    = c.fadeOutDuration;

            bool
                centerOnDirectTouch   = c.centerOnDirectTouch,
                centerOnIndirectTouch = c.centerOnIndirectTouch,
                centerWhenFollowing   = c.centerWhenFollowing,

                stickyMode        = c.stickyMode,
                clampInsideRegion = c.clampInsideRegion,
                clampInsideCanvas = c.clampInsideCanvas,

                returnToStartingPosition = c.returnToStartingPosition;

            Vector2
                directInitialVector   = c.directInitialVector,
                indirectInitialVector = c.indirectInitialVector;
            float
                originSmoothTime = c.originSmoothTime,
                touchSmoothing   = c.touchSmoothing;
            DynamicRegion
                targetDynamicRegion = c.targetDynamicRegion;


            // GUI...



            InspectorUtils.BeginIndentedSection(new GUIContent("Dynamic Control Settings"));

            if (targetDynamicRegion == null)
            {
                EditorGUILayout.HelpBox("Connect this control to a Dynamic Region to make it dynamic.", MessageType.Info);
            }
            //else
            //	{
            //	GUI.enabled = false;
            targetDynamicRegion = (DynamicRegion)CFGUI.ObjectField(new GUIContent("Region", "Control's Dynamic Region.\n\nWARNING: Only one control can be assigned to a dynamic region!"),
                                                                   targetDynamicRegion, typeof(DynamicRegion), LABEL_WIDTH);
            //	GUI.enabled = true;
            //	}

            EditorGUILayout.Space();

            if (targetDynamicRegion != null)
            {
                if ((fadeOutWhenReleased = EditorGUILayout.ToggleLeft(new GUIContent("Fade-out when released", "Fade-out control when released (Dynamic mode ONLY)."),
                                                                      fadeOutWhenReleased)))
                {
                    CFGUI.BeginIndentedVertical();

                    startFadedOut = EditorGUILayout.ToggleLeft(new GUIContent("Start faded out", "This tontrol will start invisible at the begining."),
                                                               startFadedOut);

                    fadeOutTargetAlpha = CFGUI.Slider(new GUIContent("F.O. Alpha", "Fade-Out Target Alpha. Default value is ZERO (completely invisible)."),
                                                      fadeOutTargetAlpha, 0, 1, LABEL_WIDTH);

                    EditorGUILayout.Space();

                    fadeInDuration = CFGUI.FloatFieldEx(new GUIContent("Fade-In Dur.", "Fade-In duration (ms) : 0 = instant fade-in."),
                                                        fadeInDuration, 0, 2, 1000, true, 100);
                    fadeOutDuration = CFGUI.FloatFieldEx(new GUIContent("Fade-Out Dur.", "Fade-Out duration (ms) : 0 = instant fade-out."),
                                                         fadeOutDuration, 0, 2, 1000, true, 100);

                    fadeOutDelay = CFGUI.FloatFieldEx(new GUIContent("Fade-Out Delay.", "Fade-Out delay (ms)."),
                                                      fadeOutDelay, 0, 2, 1000, true, 100);

                    CFGUI.EndIndentedVertical();

                    EditorGUILayout.Space();
                }
            }


            if (targetDynamicRegion != null)
            {
                centerOnDirectTouch = EditorGUILayout.ToggleLeft(new GUIContent("Center On Direct Touch"),
                                                                 centerOnDirectTouch);
                centerOnIndirectTouch = EditorGUILayout.ToggleLeft(new GUIContent("Center On Indirect Touch"),
                                                                   centerOnIndirectTouch);

                if (centerOnIndirectTouch)
                {
                    const string initialPosTooltip =
                        "Normalized position that the control will center itself after being activated by a touch.\n" +
                        "Default if (0,0) (center).";

                    EditorGUILayout.LabelField(new GUIContent("Direct Touch Initial Pos", initialPosTooltip));
                    CFGUI.BeginIndentedVertical();
                    directInitialVector.x = CFGUI.Slider(new GUIContent("X", initialPosTooltip), directInitialVector.x, -1, 1, 20);
                    directInitialVector.y = CFGUI.Slider(new GUIContent("Y", initialPosTooltip), directInitialVector.y, -1, 1, 20);
                    CFGUI.EndIndentedVertical();

                    EditorGUILayout.LabelField(new GUIContent("Indirect Touch Initial Pos", initialPosTooltip));
                    CFGUI.BeginIndentedVertical();
                    indirectInitialVector.x = CFGUI.Slider(new GUIContent("X", initialPosTooltip), indirectInitialVector.x, -1, 1, 20);
                    indirectInitialVector.y = CFGUI.Slider(new GUIContent("Y", initialPosTooltip), indirectInitialVector.y, -1, 1, 20);
                    CFGUI.EndIndentedVertical();
                }

                EditorGUILayout.Space();
            }



            //GUI.enabled = (c.swipeOffMode == TouchControl.SwipeOffMode.Disabled);
            GUI.enabled = (c.swipeOffMode != TouchControl.SwipeOffMode.Enabled);


            stickyMode = EditorGUILayout.ToggleLeft(new GUIContent("Sticky Mode", "Control will follow the finger is it goes out of control bounds. This option will be disabled if control's Swipe Off Mode is det to Enabled!"),
                                                    stickyMode);

            if (stickyMode)
            {
                CFGUI.BeginIndentedVertical();
                centerWhenFollowing = EditorGUILayout.ToggleLeft(new GUIContent("Center when following.", "WARNING! Don't use this option on Joysticks or Steering Wheels - it will make them unusable!"),
                                                                 centerWhenFollowing);
                CFGUI.EndIndentedVertical();
            }

            GUI.enabled = true;

            EditorGUILayout.Space();


            clampInsideRegion = EditorGUILayout.ToggleLeft(new GUIContent("Clamp Inside Region", "Control will be clamped inside Dynamic Region when in Sticky Mode or when started by indirect touch."),
                                                           clampInsideRegion);

            clampInsideCanvas = EditorGUILayout.ToggleLeft(new GUIContent("Clamp Inside Canvas", "Control will be clamped inside parent canvas when in Sticky Mode or when started by indirect touch."),
                                                           clampInsideCanvas);


            EditorGUILayout.Space();

            if (targetDynamicRegion != null)
            {
                returnToStartingPosition = EditorGUILayout.ToggleLeft(new GUIContent("Return to start position", "Control will return to starting position after being released (Dynamic Mode)"),
                                                                      returnToStartingPosition);

                EditorGUILayout.Space();
            }


            originSmoothTime = CFGUI.Slider(new GUIContent("Move. smoothing", "Movement smoothing time (sticky mode, dynamic mode).\n\n0.0 = no smoothing/no animation.\n1.0 = slow movement."),
                                            originSmoothTime, 0, 1, 110);

            touchSmoothing = CFGUI.Slider(new GUIContent("Touch smoothing", "Amount of smoothing applied to controlling touch position. "),
                                          touchSmoothing, 0, 1, 110);


            InspectorUtils.EndIndentedSection();



            // Register Undo...

            if ((fadeOutWhenReleased != c.fadeOutWhenReleased) ||
                (startFadedOut != c.startFadedOut) ||
                (fadeOutTargetAlpha != c.fadeOutTargetAlpha) ||
                (fadeInDuration != c.fadeInDuration) ||
                (fadeOutDelay != c.fadeOutDelay) ||
                (fadeOutDuration != c.fadeOutDuration) ||
                (centerOnDirectTouch != c.centerOnDirectTouch) ||
                (centerOnIndirectTouch != c.centerOnIndirectTouch) ||
                (stickyMode != c.stickyMode) ||
                (clampInsideRegion != c.clampInsideRegion) ||
                (clampInsideCanvas != c.clampInsideCanvas) ||
                (targetDynamicRegion != c.targetDynamicRegion) ||
                (returnToStartingPosition != c.returnToStartingPosition) ||
                (directInitialVector != c.directInitialVector) ||
                (indirectInitialVector != c.indirectInitialVector) ||
                (touchSmoothing != c.touchSmoothing) ||
                (originSmoothTime != c.originSmoothTime))
            {
                CFGUI.CreateUndo("Dynamic Touch Control modification.", c);

                c.fadeOutWhenReleased      = fadeOutWhenReleased;
                c.startFadedOut            = startFadedOut;
                c.fadeOutTargetAlpha       = fadeOutTargetAlpha;
                c.fadeInDuration           = fadeInDuration;
                c.fadeOutDelay             = fadeOutDelay;
                c.fadeOutDuration          = fadeOutDuration;
                c.centerOnDirectTouch      = centerOnDirectTouch;
                c.centerOnIndirectTouch    = centerOnIndirectTouch;
                c.stickyMode               = stickyMode;
                c.clampInsideRegion        = clampInsideRegion;
                c.clampInsideCanvas        = clampInsideCanvas;
                c.returnToStartingPosition = returnToStartingPosition;
                c.directInitialVector      = directInitialVector;
                c.indirectInitialVector    = indirectInitialVector;
                c.originSmoothTime         = originSmoothTime;

                if (c.touchSmoothing != touchSmoothing)
                {
                    c.SetTouchSmoothing(touchSmoothing);
                }

                if (targetDynamicRegion != c.targetDynamicRegion)
                {
                    c.SetTargetDynamicRegion(targetDynamicRegion);
                }

                CFGUI.EndUndo(c);
            }
        }