public virtual void CopyFrom(DMKBulletShooterController controller)
        {
            this.interval         = controller.interval;
            this.emissionCooldown = controller.emissionCooldown;
            this.emissionLength   = controller.emissionLength;
            this.positionOffset   = controller.positionOffset;
            this.bulletContainer  = controller.bulletContainer;
            this.gameObject       = controller.gameObject;
            this.tag                   = controller.tag;
            this.startFrame            = controller.startFrame;
            this.overallLength         = controller.overallLength;
            this.simulationCount       = controller.simulationCount;
            this.followParentDirection = controller.followParentDirection;
            this.groupId               = controller.groupId;

            if (controller.shooter != null)
            {
                this.shooter = (DMKBulletShooter)ScriptableObject.CreateInstance(controller.shooter.GetType());
                this.shooter.parentController = this;
                this.shooter.CopyFrom(controller.shooter);
            }
            else
            {
                this.shooter = null;
            }

            this.bulletInfo.CopyFrom(controller.bulletInfo);
        }
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 OnShooterMenuCreateLinkClicked()
        {
            DMKBulletShooterController shooterController = selectedGraphObject as DMKBulletShooterController;

            creatingLink   = true;
            linkSourceType = typeof(DMKBulletShooterController);
            linkStartPos   = shooterController.editorWindowRect;
            shooterController.shooter.modifier = null;
        }
Example #4
0
        public override void OnShootBullet(DMKBulletShooterController parentController, Vector3 pos, float direction, float speedMultiplier)
        {
            float sm = speedMultiplier;

            for (int i = 0; i < count; ++i)
            {
                this.DoShootBullet(parentController, pos, direction, sm);
                sm *= speedAttenuation;
            }
        }
Example #5
0
 public void DoShootBullet(DMKBulletShooterController parentShooter, Vector3 pos, float direction, float speedMultiplier)
 {
     if (next != null)
     {
         next.OnShootBullet(parentShooter, pos, direction, speedMultiplier);
     }
     else
     {
         parentShooter.CreateBullet(pos, direction, speedMultiplier);
     }
 }
        public static void OnEditorGUI(DMKBulletShooterController shooter)
        {
            EditorGUILayout.BeginVertical();
            {
                //shooter.identifier = EditorGUILayout.TextField("Identifier", shooter.identifier);
                //	shooter.bulletContainer = (GameObject)EditorGUILayout.ObjectField("Bullet Container", shooter.bulletContainer, typeof(GameObject), true);
                EditorGUI.BeginChangeCheck();
                shooter.groupId = EditorGUILayout.IntField("Group Id", shooter.groupId);
                if (EditorGUI.EndChangeCheck())
                {
                    shooter.parentController.RestartCurrentDanmaku();
                }

                EditorGUI.BeginChangeCheck();
                DMKGUIUtility.MakeCurveControl(ref shooter.emissionCooldown, "Emission CD");
                shooter.emissionLength = (int)Mathf.Clamp(EditorGUILayout.IntField("Emission Length", shooter.emissionLength), 0, 999999);
                shooter.interval       = (int)Mathf.Clamp(EditorGUILayout.IntField("Emission Interval", shooter.interval), 0, 999999);
                shooter.startFrame     = (int)Mathf.Clamp(EditorGUILayout.IntField("Start Frame", shooter.startFrame), 0, 999999);
                shooter.overallLength  = (int)Mathf.Clamp(EditorGUILayout.IntField("Overall Length", shooter.overallLength), 0, 999999);
                if (EditorGUI.EndChangeCheck())
                {
                    shooter.DMKInit();
                }

                shooter.simulationCount = (int)Mathf.Clamp(EditorGUILayout.IntField("Simulation Count", shooter.simulationCount), 1, 999999);

                EditorGUILayout.Space();
                shooter.tag = EditorGUILayout.TextField("Tag", shooter.tag);


                shooter.gameObject = (GameObject)EditorGUILayout.ObjectField("Parent Object", shooter.gameObject, typeof(GameObject), true);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Position Offset");
                    shooter.positionOffset.type = (DMKPositionOffsetType)EditorGUILayout.EnumPopup(shooter.positionOffset.type);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(20);
                    GUILayout.BeginVertical();

                    shooter.positionOffset.OnEditorGUI(false);
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
            }
            EditorGUILayout.Separator();
            EditorGUILayout.EndVertical();

            ShooterGUILowerPart(shooter);
        }
Example #7
0
        void OnShooterMenuPasteAsNewClicked()
        {
            DMKBulletShooterController shooterController = selectedGraphObject as DMKBulletShooterController;

            DMKBulletShooterController newController = (DMKBulletShooterController)ScriptableObject.CreateInstance <DMKBulletShooterController>();

            newController.CopyFrom(shooterController);

            newController.groupId = selectedDanmaku.shooters.Count;
            selectedDanmaku.shooters.Add(newController);
            selectedDanmaku.UpdateShooters();
        }
Example #8
0
        void OnShooterMenuAddSubShooterClicked(object userData)
        {
            DMKBulletShooterController shooterController = (DMKBulletShooterController)ScriptableObject.CreateInstance <DMKBulletShooterController>();

            shooterController.shooter = ScriptableObject.CreateInstance(userData as Type) as DMKBulletShooter;

            DMKBulletShooterController selectedController = (selectedGraphObject as DMKBulletShooterController);

            shooterController.editorExpanded        = true;
            shooterController.parentController      = selectedController.parentController;
            shooterController.gameObject            = null;
            shooterController.bulletContainer       = selectedController.bulletContainer;
            shooterController.overallLength         = 30;
            shooterController.gameObject            = selectedController.gameObject;
            shooterController.followParentDirection = true;

            DMKSubBulletShooterController subController = (DMKSubBulletShooterController)ScriptableObject.CreateInstance <DMKSubBulletShooterController>();

            subController.internalController = shooterController;
            selectedController.subController = subController;
            EditorUtility.SetDirty(this.selectedController.gameObject);
        }
        static void ShooterGUILowerPart_Shooter(DMKBulletShooterController shooter)
        {
            Rect rr = GUILayoutUtility.GetLastRect();

            GUI.Box(new Rect(0, rr.y + rr.height, rr.width, 2),
                    "");

            EditorGUILayout.BeginVertical();
            string shooterStr = "Shooter ";

            if (!shooter.editorShooterInfoExpanded)
            {
                shooterStr += shooter.DMKSummary();
            }
            shooter.editorShooterInfoExpanded = EditorGUILayout.Foldout(shooter.editorShooterInfoExpanded, shooterStr);
            if (shooter.editorShooterInfoExpanded)
            {
                shooter.followParentDirection = EditorGUILayout.Toggle("Parent Direction", shooter.followParentDirection);
                shooter.OnEditorGUI(false);
            }
            EditorGUILayout.EndVertical();
        }
Example #10
0
        void OnAddShooterClicked(object userData)
        {
            DMKBulletShooterController shooterController = (DMKBulletShooterController)ScriptableObject.CreateInstance <DMKBulletShooterController>();

            shooterController.shooter = ScriptableObject.CreateInstance(userData as Type) as DMKBulletShooter;

            shooterController.editorExpanded   = true;
            shooterController.parentController = selectedController;
            shooterController.gameObject       = selectedController.transform.gameObject;

            shooterController.groupId = selectedDanmaku.shooters.Count;

            if (selectedDanmaku.shooters.Count > 0)
            {
                shooterController.bulletContainer = selectedDanmaku.shooters[0].bulletContainer;
                shooterController.tag             = selectedDanmaku.shooters[0].tag;
            }
            selectedDanmaku.shooters.Add(shooterController);

            selectedDanmaku.UpdateShooters();
            EditorUtility.SetDirty(this.selectedController.gameObject);
        }
Example #11
0
        void OnShooterWindow(DMKBulletShooterController shooter, Rect windowRect, bool isSubShooter = false)
        {
            if (shooter == null)
            {
                return;
            }

            DrawShooterInfo(shooter, windowRect, isSubShooter);

            if ((Event.current.button == 0 || Event.current.button == 1))
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    if (!creatingLink)
                    {
                        selectedGraphObject = shooter;
                        GUI.FocusControl("");
                    }
                    Event.current.Use();
                }
                else if (Event.current.type == EventType.MouseUp)
                {
                    if (Event.current.button == 1)
                    {
                        if (!creatingLink)
                        {
                            this.DisplayShooterToolsMenu(isSubShooter);
                        }
                        else
                        {
                            creatingLink = false;
                        }
                    }
                    Event.current.Use();
                }
            }
        }
Example #12
0
        void DrawShooterInfo(DMKBulletShooterController shooter, Rect windowRect, bool isSubShooter)
        {
            GUI.skin.label.wordWrap = true;

            EditorGUI.BeginChangeCheck();
            shooter.editorEnabled = EditorGUI.Toggle(new Rect(0, windowRect.height / 2, 16, 16), shooter.editorEnabled);
            if (EditorGUI.EndChangeCheck())
            {
                selectedDanmaku.UpdateShooters();
            }

            GUI.Label(new Rect(2, 0, windowRect.width, 16), shooter.DMKName());
            GUI.skin.label.wordWrap = false;

            Sprite sprite = shooter.bulletInfo.bulletSprite;

            if (sprite != null)
            {
                Texture2D tex = sprite.texture;
                if (tex != null)
                {
                    int width  = (int)(Mathf.Clamp(sprite.rect.width, 0, windowRect.height - 16));
                    int height = (int)(Mathf.Clamp(sprite.rect.height, 0, windowRect.height - 16));
                    DMKGUIUtility.DrawTextureWithTexCoordsAndColor(new Rect(Mathf.Clamp((windowRect.width - width) / 2, 0, windowRect.width / 2),
                                                                            16 + Mathf.Clamp((windowRect.height - 16 - height) / 2, 0, windowRect.height / 2),
                                                                            width,
                                                                            height),
                                                                   tex,
                                                                   new Rect((float)sprite.rect.x / tex.width,
                                                                            (float)sprite.rect.y / tex.height,
                                                                            (float)sprite.rect.width / tex.width,
                                                                            (float)sprite.rect.height / tex.height),
                                                                   shooter.bulletInfo.bulletColor);
                }
            }
        }
Example #13
0
 public virtual void OnLinkedWith(DMKBulletShooterController shooter)
 {
 }
        static void ShooterGUILowerPart_BulletInfo(DMKBulletShooterController shooter)
        {
            Rect rr = GUILayoutUtility.GetLastRect();

            GUI.Box(new Rect(0, rr.y + rr.height, rr.width, 2),
                    "");
            EditorGUILayout.BeginVertical("");
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical();

                string bulletInfoStr = "Bullet";
                if (!shooter.editorBulletInfoExpanded)
                {
                    bulletInfoStr = String.Format("Bullet Info (Speed = {0}, Accel = {1})",
                                                  shooter.bulletInfo.speed.value,
                                                  shooter.bulletInfo.accel.value,
                                                  shooter.bulletInfo.maxLifetime);
                }
                shooter.editorBulletInfoExpanded = EditorGUILayout.Foldout(shooter.editorBulletInfoExpanded, bulletInfoStr);

                if (shooter.editorBulletInfoExpanded)
                {
                    {
                        EditorGUILayout.BeginVertical();
                        shooter.bulletInfo.bulletSprite = EditorGUILayout.ObjectField("Sprite", shooter.bulletInfo.bulletSprite, typeof(Sprite), false) as Sprite;
                        shooter.bulletInfo.bulletColor  = EditorGUILayout.ColorField("Color", shooter.bulletInfo.bulletColor);
                        EditorGUILayout.EndVertical();
                    }

                    EditorGUILayout.Separator();

                    DMKBulletInfo bulletInfo = shooter.bulletInfo;
                    DMKGUIUtility.MakeCurveControl(ref bulletInfo.speed, "Speed");
                    DMKGUIUtility.MakeCurveControl(ref bulletInfo.accel, "Acceleration");
                    DMKGUIUtility.MakeCurveControl(ref bulletInfo.angularAccel, "Angular Accel");

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Scale");
                        bulletInfo.useScaleCurve = DMKGUIUtility.MakeCurveToggle(bulletInfo.useScaleCurve);
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Space(32);
                        GUILayout.BeginVertical();

                        if (bulletInfo.useScaleCurve)
                        {
                            bulletInfo.scaleCurveX = EditorGUILayout.CurveField("Scale X", bulletInfo.scaleCurveX);
                            bulletInfo.scaleCurveY = EditorGUILayout.CurveField("Scale Y", bulletInfo.scaleCurveY);
                        }
                        else
                        {
                            bulletInfo.scale = EditorGUILayout.Vector2Field("", bulletInfo.scale);
                        }
                        GUILayout.EndVertical();
                    }
                    GUILayout.EndHorizontal();

                    shooter.bulletInfo.damage      = EditorGUILayout.IntField("Damage", shooter.bulletInfo.damage);
                    shooter.bulletInfo.maxLifetime = EditorGUILayout.IntField("Lifetime (Frame)", shooter.bulletInfo.maxLifetime);
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();
        }
 static void ShooterGUILowerPart(DMKBulletShooterController shooter)
 {
     ShooterGUILowerPart_BulletInfo(shooter);
     ShooterGUILowerPart_Shooter(shooter);
 }
Example #16
0
 public DMKSubBulletShooterController(DMKBulletShooterController internalController)
 {
     this.internalController = internalController;
 }
Example #17
0
        void DisplayShooterToolsMenu(bool isSubShooter)
        {
            GenericMenu menu = new GenericMenu();

            DMKBulletShooterController shooterController = selectedGraphObject as DMKBulletShooterController;

            if (!shooterController)
            {
                return;
            }

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

            if (shooterController.subController == null)
            {
                foreach (System.Reflection.Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
                {
                    foreach (Type type in asm.GetTypes())
                    {
                        if (type.BaseType == typeof(DMKBulletShooter))
                        {
                            menu.AddItem(new GUIContent("New Sub-Shooter/" + DMKUtil.GetTypeClassName(type)), false, OnShooterMenuAddSubShooterClicked, type);
                        }
                    }
                }
            }

            if (!isSubShooter)
            {
                foreach (System.Reflection.Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
                {
                    foreach (Type type in asm.GetTypes())
                    {
                        if (type.BaseType == typeof(DMKTrigger))
                        {
                            menu.AddItem(new GUIContent("New Trigger/" + DMKUtil.GetTypeClassName(type)), false, OnAddTriggerClicked, type);
                        }
                    }
                }
            }

            menu.AddSeparator("");


            menu.AddItem(new GUIContent("Copy"), false, OnShooterMenuCopyClicked);
            if (copiedShooter != null &&
                copiedShooter != selectedGraphObject)
            {
                menu.AddItem(new GUIContent("Paste"), false, OnShooterMenuPasteClicked);
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Paste"));
            }
            if (copiedShooter != null)
            {
                menu.AddItem(new GUIContent("Paste as New"), false, OnShooterMenuPasteAsNewClicked);
            }
            menu.AddSeparator("");


            menu.AddItem(new GUIContent("Remove"), false, OnShooterMenuRemoveClicked, isSubShooter.ToString());
            menu.ShowAsContext();
        }
Example #18
0
 public virtual void OnShootBullet(DMKBulletShooterController parentShooter, Vector3 pos, float direction, float speedMultiplier)
 {
     this.DoShootBullet(parentShooter, pos, direction, speedMultiplier);
 }
Example #19
0
 void OnShooterMenuCopyClicked()
 {
     copiedShooter = selectedGraphObject as DMKBulletShooterController;
 }