public DMKCurveProperty(float v1, float v2) { value = v1; curve = DMKUtil.NewCurve(v1, v2); currentVal = value; }
public DMKCurveProperty(float v = 0) { value = v; curve = DMKUtil.NewCurve(v, v); currentVal = value; }
void DisplayShooterGraphMenu() { GenericMenu menu = new GenericMenu(); 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 Shooter/" + DMKUtil.GetTypeClassName(type)), false, OnAddShooterClicked, type); } } } foreach (System.Reflection.Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type type in asm.GetTypes()) { if (type.BaseType == typeof(DMKShooterModifier)) { menu.AddItem(new GUIContent("New Modifier/" + DMKUtil.GetTypeClassName(type)), false, OnAddModifierClicked, type); } } } menu.ShowAsContext(); }
public static DMKCurveProperty Copy(DMKCurveProperty p) { DMKCurveProperty n = new DMKCurveProperty(); n.value = p.value; n.type = p.type; n.curve = DMKUtil.CopyCurve(p.curve); n.valEnd = p.valEnd; n.Update(0, true); return(n); }
public static DMKCurveProperty Copy(DMKCurveProperty p, float x) { DMKCurveProperty n = new DMKCurveProperty(); n.value = p.value * x; n.valEnd = p.valEnd * x; n.type = p.type; n.curve = DMKUtil.CopyCurve(p.curve, v => { return(v * x); }); n.currentVal = p.currentVal * x; return(n); }
public void CopyFrom(DMKBulletInfo prototype, float speedMultiplier = 1f) { this.bulletSprite = prototype.bulletSprite; this.damage = prototype.damage; this.speed = DMKCurveProperty.Copy(prototype.speed, speedMultiplier); this.accel = DMKCurveProperty.Copy(prototype.accel); this.angularAccel = DMKCurveProperty.Copy(prototype.angularAccel); this.bulletColor = prototype.bulletColor; this.died = false; this.useScaleCurve = prototype.useScaleCurve; this.scaleCurveX = DMKUtil.CopyCurve(prototype.scaleCurveX); this.scaleCurveY = DMKUtil.CopyCurve(prototype.scaleCurveY); this.collisionRect = prototype.collisionRect; this.maxLifetime = prototype.maxLifetime; this.lifeFrame = 0; }
public override void OnShoot(int frame) { float start = _currentAngle; float t = (float)frame / 60f; if (this.startAngle.type != DMKCurvePropertyType.Constant) { _currentAngle = this.startAngle.Update(t, true); } else { _currentAngle += _acceleration; _acceleration += accel2; if (_currentAngle > 360) { _currentAngle -= 360; } } if (trackTarget && targetObject != null) { start = DMKUtil.GetDgrBetweenObjects(this.parentController.gameObject, targetObject); } for (int i = 0; i < bulletCount; ++i) { float angle = angleRange.Update(t) / bulletCount * i + start; Vector3 diff = Vector3.zero; if (radius.Update(t) != 0f) { diff = new Vector3(Mathf.Cos(angle * Mathf.Deg2Rad) * radius.get(), Mathf.Sin(angle * Mathf.Deg2Rad) * radius.get(), 0); } this.ShootBullet(diff, angle); } }
public DMKBulletInfo() { scaleCurveX = DMKUtil.NewCurve(1, 1); scaleCurveY = DMKUtil.NewCurve(1, 1); }
public static void SettingsGUI() { GUILayout.BeginVertical(); GUI.skin.label.wordWrap = false; EditorGUILayout.HelpBox("DanmukuX Ver " + DMKSettings.Version + " by Robert Bu ([email protected])", MessageType.None); EditorGUILayout.Space(); DMKSettings settings = DMKSettings.instance; settings.targetFPS = EditorGUILayout.IntField("Target FPS", settings.targetFPS); settings.pixelPerUnit = EditorGUILayout.IntField("Pixel To Units", settings.pixelPerUnit); settings.unitPerPixel = 1f / settings.pixelPerUnit; settings.frameInterval = 1f / settings.targetFPS; EditorGUILayout.HelpBox("Global max number of bullets. Can be changed in individual danmakus.", MessageType.None); settings.MaxNumBullets = EditorGUILayout.IntField("Max N-Bullets", settings.MaxNumBullets); EditorGUILayout.Space(); settings.sortingLayerIndex = EditorGUILayout.Popup("Sorting Layer", settings.sortingLayerIndex, DMKUtil.GetSortingLayerNames()); settings.sortingOrder = EditorGUILayout.IntField("Sorting Order", settings.sortingOrder); EditorGUILayout.HelpBox("If bullets are stored by controller, then bullets will die when the controller dies", MessageType.None); settings.bulletStorePolicy = (DMKBulletStorePolicy)EditorGUILayout.EnumPopup("Bullet Store Policy", settings.bulletStorePolicy); EditorGUILayout.HelpBox("Orthographic Size and Offset are measured in units, see Pixel To Units to convert to pixels", MessageType.None); settings.mainCamera = (Camera)EditorGUILayout.ObjectField("Camera", settings.mainCamera, typeof(Camera), true); if (settings.mainCamera && !settings.mainCamera.isOrthoGraphic) { Debug.LogError("DMKSettings: Main Camera must be orthigraphic"); settings.mainCamera = null; } bool customOrthoSize = EditorGUILayout.Toggle("Custom Ortho Size", settings.useCustomOrthoSize); if (customOrthoSize && !settings.useCustomOrthoSize) { Camera camera = settings.mainCamera == null ? Camera.main : settings.mainCamera; settings.orthoSizeVertical = camera.orthographicSize; settings.orthoSizeHorizontal = camera.orthographicSize * camera.aspect; } settings.useCustomOrthoSize = customOrthoSize; if (settings.useCustomOrthoSize) { EditorGUI.BeginChangeCheck(); settings.centerOffsetX = EditorGUILayout.FloatField("Center Offset X", settings.centerOffsetX); settings.centerOffsetY = EditorGUILayout.FloatField("Center Offset Y", settings.centerOffsetY); settings.orthoSizeHorizontal = EditorGUILayout.FloatField("Horizontal Ortho Size", settings.orthoSizeHorizontal); settings.orthoSizeVertical = EditorGUILayout.FloatField("Vertical Ortho Size", settings.orthoSizeVertical); if (EditorGUI.EndChangeCheck()) { SceneView.RepaintAll(); } } GUI.skin.label.wordWrap = true; GUILayout.EndVertical(); }
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(); }