Example #1
0
 public void RemoveModifier(DMKShooterModifier modifier)
 {
     this.modifiers.Remove(modifier);
     foreach (DMKShooterModifier m in this.modifiers)
     {
         if (m.next == modifier)
         {
             m.next = null;
         }
     }
     foreach (DMKBulletShooterController shooterController in this.shooters)
     {
         if (shooterController.shooter.modifier == modifier)
         {
             shooterController.shooter.modifier = null;
         }
         DMKSubBulletShooterController subController = shooterController.subController;
         if (subController != null)
         {
             while (subController != null)
             {
                 if (subController.internalController.shooter.modifier == modifier)
                 {
                     subController.internalController.shooter.modifier = null;
                 }
                 subController = subController.internalController.subController;
             }
         }
     }
 }
Example #2
0
        public void CopyFrom(DMKDanmaku danmaku)
        {
            this.playMode         = danmaku.playMode;
            this.playInterval     = danmaku.playInterval;
            this.parentController = danmaku.parentController;

            this.shooters.Clear();
            foreach (DMKBulletShooterController shooterController in danmaku.shooters)
            {
                DMKBulletShooterController newController = (DMKBulletShooterController)ScriptableObject.CreateInstance <DMKBulletShooterController>();
                newController.CopyFrom(shooterController);
                this.shooters.Add(newController);
            }

            this.modifiers.Clear();
            foreach (DMKShooterModifier modifier in danmaku.modifiers)
            {
                DMKShooterModifier newModifier = (DMKShooterModifier)ScriptableObject.CreateInstance(modifier.GetType());
                newModifier.CopyFrom(modifier);
                this.modifiers.Add(newModifier);
            }

            this.triggers.Clear();
            foreach (DMKTrigger trigger in danmaku.triggers)
            {
                DMKTrigger newTrigger = (DMKTrigger)ScriptableObject.CreateInstance(trigger.GetType());
                newTrigger.CopyFrom(trigger);
                this.triggers.Add(newTrigger);
            }
        }
Example #3
0
        void DisplayModifierToolsMenu()
        {
            GenericMenu menu = new GenericMenu();

            DMKShooterModifier modifier = selectedGraphObject as DMKShooterModifier;

            if (!modifier)
            {
                return;
            }

            menu.AddItem(new GUIContent("Link Modifier"), false, OnModifierMenuCreateLinkClicked);
            menu.AddSeparator("");

            menu.AddItem(new GUIContent("Copy"), false, OnModifierMenuCopyClicked);
            if (copiedModifier != null &&
                copiedModifier != selectedGraphObject)
            {
                menu.AddItem(new GUIContent("Paste"), false, OnModifierMenuPasteClicked);
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Paste"));
            }
            menu.AddSeparator("");

            menu.AddItem(new GUIContent("Remove"), false, OnModifierMenuRemoveClicked);
            menu.ShowAsContext();
        }
Example #4
0
        void OnAddModifierClicked(object userData)
        {
            DMKShooterModifier modifier = ScriptableObject.CreateInstance(userData as Type) as DMKShooterModifier;

            selectedDanmaku.AddModifier(modifier);
            // to do
            //selectedShooter.shooter.AddModifier(modifier);
        }
Example #5
0
        void OnModifierMenuCreateLinkClicked()
        {
            DMKShooterModifier modifier = selectedGraphObject as DMKShooterModifier;

            creatingLink   = true;
            linkSourceType = typeof(DMKShooterModifier);
            linkStartPos   = modifier.editorWindowRect;
            modifier.next  = null;
        }
Example #6
0
        void OnShooterModifierWindow(DMKShooterModifier modifier)
        {
            GUIStyle s = new GUIStyle(GUI.skin.label);

            s.fontSize         = 12;
            s.normal.textColor = new Color(255, 255, 255, 1);
            s.alignment        = TextAnchor.MiddleCenter;
            GUI.Label(new Rect(6, 0, ModifierNodeWindowWidth, ModifierNodeWindowHeight),
                      modifier.DMKName(),
                      s);

            modifier.editorEnabled = EditorGUI.Toggle(new Rect(0, ModifierNodeWindowHeight / 2 - 8, 16, 16), modifier.editorEnabled);


            if ((Event.current.button == 0 || Event.current.button == 1))
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    if (!creatingLink)
                    {
                        selectedGraphObject = modifier;
                        GUI.FocusControl("");
                    }
                    Event.current.Use();
                }
                else if (Event.current.type == EventType.MouseUp)
                {
                    if (Event.current.button == 0 && creatingLink)
                    {
                        if (linkSourceType == typeof(DMKBulletShooterController))
                        {
                            (selectedGraphObject as DMKBulletShooterController).shooter.modifier = modifier;
                        }
                        else if (linkSourceType == typeof(DMKShooterModifier) &&
                                 !HasModifierLoop(modifier, selectedGraphObject as DMKShooterModifier))
                        {
                            (selectedGraphObject as DMKShooterModifier).next = modifier;
                        }
                        creatingLink = false;
                    }
                    else if (Event.current.button == 1)
                    {
                        if (creatingLink)
                        {
                            creatingLink = false;
                        }
                        else
                        {
                            this.DisplayModifierToolsMenu();
                        }
                    }
                    Event.current.Use();
                }
            }
        }
Example #7
0
        public override void CopyFrom(DMKShooterModifier rhs)
        {
            if (rhs.GetType() == typeof(DMKLineModifier))
            {
                DMKLineModifier lm = rhs as DMKLineModifier;
                this.count            = lm.count;
                this.speedAttenuation = lm.speedAttenuation;
            }

            base.CopyFrom(rhs);
        }
Example #8
0
        bool HasModifierLoop(DMKShooterModifier src, DMKShooterModifier target)
        {
            DMKShooterModifier m = src.next;

            while (m != null)
            {
                if (m == target)
                {
                    return(true);
                }
                m = m.next;
            }
            return(false);
        }
Example #9
0
 public void AddModifier(DMKShooterModifier modifier)
 {
     this.modifiers.Add(modifier);
 }
Example #10
0
 public virtual void CopyFrom(DMKShooterModifier rhs)
 {
     this.next = rhs.next;
 }
Example #11
0
        void ShooterGraphGUI()
        {
            if (selectedDanmaku != null)
            {
                Rect graphWindowRect = new Rect(0, 0, this.position.width - InspectorWidth, this.position.height);
                Rect nodeWindowRect  = new Rect(0, 0, TriggerNodeWindowWidth, TriggerNodeWindowHeight);

                int triggerWidthRequired = selectedDanmaku.triggers.Count * (TriggerNodeWindowWidth + 40) - 40;
                int shooterWidthRequired = selectedDanmaku.shooters.Count * (ShooterNodeWindowWidth + 40) - 40;
                int widthRequired        = Mathf.Max(triggerWidthRequired, shooterWidthRequired);

                shooterGraphScrollPosition = GUI.BeginScrollView(graphWindowRect,
                                                                 shooterGraphScrollPosition,
                                                                 new Rect(0, 0, widthRequired + 40, shooterGraphHeight));
                GUI.Box(new Rect(shooterGraphScrollPosition.x,
                                 shooterGraphScrollPosition.y,
                                 this.position.width - InspectorWidth,
                                 this.position.height),
                        "",
                        (GUIStyle)"flow background");
                //	shooterGraphScrollPosition =  GUILayout.BeginScrollView(shooterGraphScrollPosition, (GUIStyle)"flow background");

                float startY = nodeWindowRect.y + DanmakuListWindowHeight + 40;
                if (shooterGraphHeight < this.position.height)
                {
                    startY = this.position.height / 2 - (shooterGraphHeight - DanmakuListWindowHeight) / 2;
                }
                nodeWindowRect = new Rect(Mathf.Clamp((this.position.width - InspectorWidth) / 2 - shooterWidthRequired / 2, 20, 9999),
                                          startY,
                                          ShooterNodeWindowWidth,
                                          ShooterNodeWindowHeight);

                float bottomY = nodeWindowRect.y;
                foreach (DMKBulletShooterController controller in selectedDanmaku.shooters)
                {
                    GUIStyle shooterStyle = (GUIStyle)"flow node 0";
                    if (selectedGraphObject == controller)
                    {
                        shooterStyle = (GUIStyle)"flow node 0 on";
                    }

                    GUILayout.BeginArea(nodeWindowRect, shooterStyle);
                    this.OnShooterWindow(controller, nodeWindowRect);
                    GUILayout.EndArea();

                    controller.editorWindowRect = nodeWindowRect;

                    if (controller.shooter == null)
                    {
                        continue;
                    }

                    if (controller.shooter.modifier != null)
                    {
                        DMKShooterModifier modifier = controller.shooter.modifier;
                        this.DrawVerticalBezier(new Vector3(nodeWindowRect.x + nodeWindowRect.width / 2,
                                                            nodeWindowRect.y + nodeWindowRect.height),
                                                new Vector3(modifier.editorWindowRect.x + modifier.editorWindowRect.width / 2,
                                                            modifier.editorWindowRect.y),
                                                true);
                    }

                    if (controller.subController != null)
                    {
                        bottomY = Mathf.Max(this.DrawSubControllerNode(controller.subController, nodeWindowRect), bottomY);
                    }
                    else
                    {
                        bottomY = Mathf.Max(nodeWindowRect.y, bottomY);
                    }

                    nodeWindowRect.x += (ShooterNodeWindowWidth + 40);
                }

                nodeWindowRect = new Rect(Mathf.Max(widthRequired, this.position.width - InspectorWidth) / 2 - ModifierNodeWindowWidth / 2,
                                          bottomY + 52 + ShooterNodeWindowHeight,
                                          ModifierNodeWindowWidth,
                                          ModifierNodeWindowHeight);

                foreach (DMKShooterModifier modifier in selectedDanmaku.modifiers)
                {
                    GUIStyle modifierStyle = (GUIStyle)"flow node 1";
                    if (selectedGraphObject == modifier ||
                        (creatingLink &&
                         (linkSourceType == typeof(DMKBulletShooterController) || linkSourceType == typeof(DMKShooterModifier)) &&
                         nodeWindowRect.Contains(Event.current.mousePosition) &&
                         !HasModifierLoop(modifier, selectedGraphObject as DMKShooterModifier)))
                    {
                        modifierStyle = (GUIStyle)"flow node 1 on";
                    }

                    GUILayout.BeginArea(nodeWindowRect, modifierStyle);
                    this.OnShooterModifierWindow(modifier);
                    GUILayout.EndArea();

                    if (modifier.next != null)
                    {
                        DMKShooterModifier next = modifier.next;
                        if (next.editorWindowRect.y > modifier.editorWindowRect.y)
                        {
                            this.DrawVerticalBezier(new Vector3(nodeWindowRect.x + nodeWindowRect.width / 2,
                                                                nodeWindowRect.y + nodeWindowRect.height),
                                                    new Vector3(next.editorWindowRect.x + next.editorWindowRect.width / 2,
                                                                next.editorWindowRect.y),
                                                    true);
                        }
                        else
                        {
                            this.DrawVerticalBezier(new Vector3(nodeWindowRect.x + nodeWindowRect.width / 2,
                                                                nodeWindowRect.y),
                                                    new Vector3(next.editorWindowRect.x + next.editorWindowRect.width / 2,
                                                                next.editorWindowRect.y + next.editorWindowRect.height),
                                                    true);
                        }
                    }
                    modifier.editorWindowRect = nodeWindowRect;

                    nodeWindowRect.y += ModifierNodeWindowHeight + 40;
                }

                shooterGraphHeight = nodeWindowRect.y;

                if (creatingLink)
                {
                    Vector3 end = Event.current.mousePosition;
                    Vector3 start;
                    if (end.y > linkStartPos.y + linkStartPos.height / 2)
                    {
                        start = new Vector3(linkStartPos.x + linkStartPos.width / 2,
                                            linkStartPos.y + linkStartPos.height);
                    }
                    else
                    {
                        start = new Vector3(linkStartPos.x + linkStartPos.width / 2,
                                            linkStartPos.y);
                    }
                    this.DrawVerticalBezier(start,
                                            Event.current.mousePosition,
                                            false);

                    this.Repaint();
                }

                //	GUILayout.EndArea();
                GUI.EndScrollView();

                if ((Event.current.button == 0 || Event.current.button == 1) &&
                    graphWindowRect.Contains(Event.current.mousePosition))
                {
                    if ((Event.current.type == EventType.mouseUp))
                    {
                        if (creatingLink)
                        {
                            if (linkSourceType == typeof(DMKBulletShooterController))
                            {
                                (selectedGraphObject as DMKBulletShooterController).shooter.modifier = null;
                            }
                            else if (linkSourceType == typeof(DMKShooterModifier))
                            {
                                (selectedGraphObject as DMKShooterModifier).next = null;
                            }

                            creatingLink = false;
                        }
                        else
                        {
                            if (Event.current.button == 1 && !creatingLink)
                            {
                                this.DisplayShooterGraphMenu();
                            }
                            else
                            {
                                selectedGraphObject = null;
                            }
                        }
                    }


                    this.Repaint();
                }
            }
            else
            {
                GUI.Box(new Rect(0,
                                 0,
                                 this.position.width - InspectorWidth,
                                 this.position.height),
                        "",
                        (GUIStyle)"flow background");
            }
        }
Example #12
0
        float DrawSubControllerNode(DMKSubBulletShooterController controller, Rect windowRect, bool isSecondaryLevel = false)
        {
            if (controller.internalController == null)
            {
                return(windowRect.y + windowRect.height);
            }

            Rect nodeWindowRect;

            if (isSecondaryLevel)
            {
                nodeWindowRect = new Rect(windowRect.x,
                                          windowRect.y + 40 + ShooterNodeWindowHeight,
                                          windowRect.width,
                                          windowRect.height);
            }
            else
            {
                nodeWindowRect = new Rect(windowRect.x + 5,
                                          windowRect.y + 40 + ShooterNodeWindowHeight,
                                          windowRect.width - 10,
                                          windowRect.height - 10);
            }


            this.DrawVerticalBezier(new Vector3(windowRect.x + windowRect.width / 2,
                                                windowRect.y + windowRect.height),
                                    new Vector3(nodeWindowRect.x + nodeWindowRect.width / 2,
                                                nodeWindowRect.y),
                                    true);


            GUIStyle shooterStyle = (GUIStyle)"flow node 0";

            if (selectedGraphObject == controller.internalController)
            {
                shooterStyle = (GUIStyle)"flow node 0 on";
            }

            GUILayout.BeginArea(nodeWindowRect, shooterStyle);
            this.OnShooterWindow(controller.internalController, nodeWindowRect, true);
            GUILayout.EndArea();

            controller.editorWindowRect = controller.internalController.editorWindowRect = nodeWindowRect;

            if (controller.internalController.shooter.modifier != null)
            {
                DMKShooterModifier modifier = controller.internalController.shooter.modifier;
                this.DrawVerticalBezier(new Vector3(nodeWindowRect.x + nodeWindowRect.width / 2,
                                                    nodeWindowRect.y + nodeWindowRect.height),
                                        new Vector3(modifier.editorWindowRect.x + modifier.editorWindowRect.width / 2,
                                                    modifier.editorWindowRect.y),
                                        true);
            }

            DMKSubBulletShooterController next = controller.internalController.subController;

            while (next != null)
            {
                nodeWindowRect.y = this.DrawSubControllerNode(next, nodeWindowRect, true);

                next = next.internalController.subController;
            }
            return(nodeWindowRect.y);
        }
Example #13
0
 void OnModifierMenuCopyClicked()
 {
     copiedModifier = selectedGraphObject as DMKShooterModifier;
 }