├── .gitattributes ├── icon.png ├── addons └── DrunkBull.SuperLightning │ ├── addon_icon.png │ ├── assets │ ├── demo │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── addon_icon.png │ │ ├── 1.png.import │ │ ├── 2.png.import │ │ ├── 3.png.import │ │ ├── 4.png.import │ │ └── 5.png.import │ ├── art │ │ ├── spark_05_rotated.png │ │ ├── spark_06_rotated.png │ │ ├── spark_07_rotated.png │ │ ├── trace_01_rotated.png │ │ ├── trace_02_rotated.png │ │ ├── trace_03_rotated.png │ │ ├── trace_04_rotated.png │ │ ├── trace_05_rotated.png │ │ ├── trace_06_rotated.png │ │ ├── trace_07_rotated.png │ │ ├── spark_05_rotated.png.import │ │ ├── spark_06_rotated.png.import │ │ ├── spark_07_rotated.png.import │ │ ├── trace_01_rotated.png.import │ │ ├── trace_02_rotated.png.import │ │ ├── trace_03_rotated.png.import │ │ ├── trace_04_rotated.png.import │ │ ├── trace_05_rotated.png.import │ │ ├── trace_06_rotated.png.import │ │ └── trace_07_rotated.png.import │ └── resource │ │ ├── line_basic_gradient.tres │ │ ├── line_basic_curve.tres │ │ └── lightning_animation.tres │ ├── plugin.cfg │ ├── plugin.gd │ ├── src │ ├── main │ │ ├── BasicLightningLine2d.tscn │ │ ├── BasicLightningLine2d.gd │ │ └── SuperLightning.gd │ └── test │ │ ├── Demo.gd │ │ └── Demo.tscn │ └── addon_icon.png.import ├── default_env.tres ├── .gitignore ├── icon.png.import ├── README.md ├── project.godot └── LICENSE /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/icon.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/addon_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/addon_icon.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/demo/1.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/demo/2.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/demo/3.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/demo/4.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/demo/5.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/addon_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/demo/addon_icon.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/spark_05_rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/art/spark_05_rotated.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/spark_06_rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/art/spark_06_rotated.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/spark_07_rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/art/spark_07_rotated.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_01_rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/art/trace_01_rotated.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_02_rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/art/trace_02_rotated.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_03_rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/art/trace_03_rotated.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_04_rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/art/trace_04_rotated.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_05_rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/art/trace_05_rotated.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_06_rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/art/trace_06_rotated.png -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_07_rotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DeanNevan/Godot-2D-Super-Lightning/HEAD/addons/DrunkBull.SuperLightning/assets/art/trace_07_rotated.png -------------------------------------------------------------------------------- /default_env.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Environment" load_steps=2 format=2] 2 | 3 | [sub_resource type="ProceduralSky" id=1] 4 | 5 | [resource] 6 | background_mode = 2 7 | background_sky = SubResource( 1 ) 8 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/plugin.cfg: -------------------------------------------------------------------------------- 1 | [plugin] 2 | 3 | name="SuperLightning" 4 | description="A wonderful(maybe) thunder&lightning2D for godot. 5 | Highly-customized." 6 | author="DrunkBull" 7 | version="1.0" 8 | script="plugin.gd" 9 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/resource/line_basic_gradient.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Gradient" format=2] 2 | 3 | [resource] 4 | offsets = PoolRealArray( 0, 0.205714, 0.8, 0.931429 ) 5 | colors = PoolColorArray( 1, 1, 1, 0.588235, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.862745 ) 6 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/resource/line_basic_curve.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Curve" format=2] 2 | 3 | [resource] 4 | _data = [ Vector2( 0, 0.254545 ), 0.0, 0.0, 0, 0, Vector2( 0.277778, 0.572727 ), 1.10565, 1.10565, 0, 0, Vector2( 0.813131, 0.790909 ), 0.0, 0.0, 0, 0, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ] 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Godot 4+ specific ignores 2 | .godot/ 3 | 4 | # Godot-specific ignores 5 | .import/ 6 | export.cfg 7 | export_presets.cfg 8 | 9 | # Imported translations (automatically generated from CSV files) 10 | *.translation 11 | 12 | # Mono-specific ignores 13 | .mono/ 14 | data_*/ 15 | mono_crash.*.json 16 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/plugin.gd: -------------------------------------------------------------------------------- 1 | tool 2 | extends EditorPlugin 3 | 4 | func _enter_tree(): 5 | # Initialization of the plugin goes here. 6 | # Add the new type with a name, a parent type, a script and an icon. 7 | add_custom_type("SuperLightning", "Node2D", load("res://addons/DrunkBull.SuperLightning/src/main/SuperLightning.gd"), preload("addon_icon.png")) 8 | 9 | func _exit_tree(): 10 | # Clean-up of the plugin goes here. 11 | # Always remember to remove it from the engine when deactivated. 12 | remove_custom_type("SuperLightning") 13 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/resource/lightning_animation.tres: -------------------------------------------------------------------------------- 1 | [gd_resource type="Animation" format=2] 2 | 3 | [resource] 4 | resource_name = "lightning" 5 | tracks/0/type = "value" 6 | tracks/0/path = NodePath(".:modulate") 7 | tracks/0/interp = 1 8 | tracks/0/loop_wrap = true 9 | tracks/0/imported = false 10 | tracks/0/enabled = true 11 | tracks/0/keys = { 12 | "times": PoolRealArray( 0, 0.3, 0.4, 0.5, 0.9 ), 13 | "transitions": PoolRealArray( 2, 0.5, 0.5, 2, 1 ), 14 | "update": 0, 15 | "values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0.588235 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ] 16 | } 17 | -------------------------------------------------------------------------------- /icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://icon.png" 13 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/src/main/BasicLightningLine2d.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=5 format=2] 2 | 3 | [ext_resource path="res://addons/DrunkBull.SuperLightning/assets/resource/line_basic_curve.tres" type="Curve" id=1] 4 | [ext_resource path="res://addons/DrunkBull.SuperLightning/assets/resource/line_basic_gradient.tres" type="Gradient" id=2] 5 | [ext_resource path="res://addons/DrunkBull.SuperLightning/assets/art/spark_05_rotated.png" type="Texture" id=3] 6 | [ext_resource path="res://addons/DrunkBull.SuperLightning/src/main/BasicLightningLine2d.gd" type="Script" id=4] 7 | 8 | [node name="BasicLightningLine2d" type="Line2D"] 9 | use_parent_material = true 10 | width = 100.0 11 | width_curve = ExtResource( 1 ) 12 | gradient = ExtResource( 2 ) 13 | texture = ExtResource( 3 ) 14 | texture_mode = 2 15 | script = ExtResource( 4 ) 16 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/1.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/1.png-798a66319a8a4871d80beedd3e867d65.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/demo/1.png" 13 | dest_files=[ "res://.import/1.png-798a66319a8a4871d80beedd3e867d65.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/2.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/2.png-c6f5646398732fd7e0abe4b817765487.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/demo/2.png" 13 | dest_files=[ "res://.import/2.png-c6f5646398732fd7e0abe4b817765487.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/3.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/3.png-dd9da0d6a274f5ad221a54ec7ade55d5.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/demo/3.png" 13 | dest_files=[ "res://.import/3.png-dd9da0d6a274f5ad221a54ec7ade55d5.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/4.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/4.png-aeb2994dd26d303af8a83bb81c6e94d7.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/demo/4.png" 13 | dest_files=[ "res://.import/4.png-aeb2994dd26d303af8a83bb81c6e94d7.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/demo/5.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/5.png-17ff3f72b04840de04ce4587e6ce0ac9.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/demo/5.png" 13 | dest_files=[ "res://.import/5.png-17ff3f72b04840de04ce4587e6ce0ac9.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/addon_icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/addon_icon.png-2653294cf1c0ed6e496c7212b8f8e76e.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/addon_icon.png" 13 | dest_files=[ "res://.import/addon_icon.png-2653294cf1c0ed6e496c7212b8f8e76e.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/spark_05_rotated.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/spark_05_rotated.png-42a9463e5b0dbd23b7397ff4d92ed84a.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/art/spark_05_rotated.png" 13 | dest_files=[ "res://.import/spark_05_rotated.png-42a9463e5b0dbd23b7397ff4d92ed84a.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/spark_06_rotated.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/spark_06_rotated.png-afa9bd8b62d303984d90a26e50c18e37.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/art/spark_06_rotated.png" 13 | dest_files=[ "res://.import/spark_06_rotated.png-afa9bd8b62d303984d90a26e50c18e37.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/spark_07_rotated.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/spark_07_rotated.png-7941731e1f8e5eb4374e83f0b8376122.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/art/spark_07_rotated.png" 13 | dest_files=[ "res://.import/spark_07_rotated.png-7941731e1f8e5eb4374e83f0b8376122.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_01_rotated.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/trace_01_rotated.png-c869eb7ceddab304790994e063d6606b.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/art/trace_01_rotated.png" 13 | dest_files=[ "res://.import/trace_01_rotated.png-c869eb7ceddab304790994e063d6606b.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_02_rotated.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/trace_02_rotated.png-933575440442136e3dc5c81d2a7a50bc.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/art/trace_02_rotated.png" 13 | dest_files=[ "res://.import/trace_02_rotated.png-933575440442136e3dc5c81d2a7a50bc.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_03_rotated.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/trace_03_rotated.png-fbff1820c074a3ff945f8f561065d90a.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/art/trace_03_rotated.png" 13 | dest_files=[ "res://.import/trace_03_rotated.png-fbff1820c074a3ff945f8f561065d90a.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_04_rotated.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/trace_04_rotated.png-32f0cf5439a1338d38d118fe74ba252b.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/art/trace_04_rotated.png" 13 | dest_files=[ "res://.import/trace_04_rotated.png-32f0cf5439a1338d38d118fe74ba252b.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_05_rotated.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/trace_05_rotated.png-23a8fb29a56d0a81d9be6893d279c3cd.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/art/trace_05_rotated.png" 13 | dest_files=[ "res://.import/trace_05_rotated.png-23a8fb29a56d0a81d9be6893d279c3cd.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_06_rotated.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/trace_06_rotated.png-da82292fd6a0c75e659e2db849d4d6d2.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/art/trace_06_rotated.png" 13 | dest_files=[ "res://.import/trace_06_rotated.png-da82292fd6a0c75e659e2db849d4d6d2.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/assets/art/trace_07_rotated.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/trace_07_rotated.png-e11c5cdff0302d67b28c52807d959acf.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://addons/DrunkBull.SuperLightning/assets/art/trace_07_rotated.png" 13 | dest_files=[ "res://.import/trace_07_rotated.png-e11c5cdff0302d67b28c52807d959acf.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SuperLightning 2 | ---Description language:Chinese--- 3 | An addon for 2d thunder&lightning addon in godot game engine. 4 | godot的2d闪电插件 5 | there is a Demo.tscn in addon folder.please have a look. 6 | 在插件文件夹内有个Demo.tscn场景,建议看一下,右键增加必经点,按钮清空必经点,左键释放闪电。 7 | 函数主要是两个,一个spawn()一个lightning(),前者用于生成闪电,后者播放,一般连起来用。 8 | ![闪电1](https://github.com/DeanNevan/Godot-2D-Super-Lightning/blob/main/addons/DrunkBull.SuperLightning/assets/demo/1.png) 9 | 10 | ![闪电2](https://github.com/DeanNevan/Godot-2D-Super-Lightning/blob/main/addons/DrunkBull.SuperLightning/assets/demo/2.png) 11 | 12 | ![闪电3](https://github.com/DeanNevan/Godot-2D-Super-Lightning/blob/main/addons/DrunkBull.SuperLightning/assets/demo/3.png) 13 | 14 | ![闪电4](https://github.com/DeanNevan/Godot-2D-Super-Lightning/blob/main/addons/DrunkBull.SuperLightning/assets/demo/4.png) 15 | 16 | ![闪电5](https://github.com/DeanNevan/Godot-2D-Super-Lightning/blob/main/addons/DrunkBull.SuperLightning/assets/demo/5.png) 17 | -------------------------------------------------------------------------------- /project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | _global_script_classes=[ { 12 | "base": "Line2D", 13 | "class": "BasicLightningLine2d", 14 | "language": "GDScript", 15 | "path": "res://addons/DrunkBull.SuperLightning/src/main/BasicLightningLine2d.gd" 16 | } ] 17 | _global_script_class_icons={ 18 | "BasicLightningLine2d": "" 19 | } 20 | 21 | [application] 22 | 23 | config/name="SuperLightning" 24 | run/main_scene="res://addons/DrunkBull.SuperLightning/src/test/Demo.tscn" 25 | config/icon="res://icon.png" 26 | 27 | [editor_plugins] 28 | 29 | enabled=PoolStringArray( "res://addons/DrunkBull.SuperLightning/plugin.cfg" ) 30 | 31 | [physics] 32 | 33 | common/enable_pause_aware_picking=true 34 | 35 | [rendering] 36 | 37 | environment/default_environment="res://default_env.tres" 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 DeanNevan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/src/main/BasicLightningLine2d.gd: -------------------------------------------------------------------------------- 1 | extends Line2D 2 | 3 | class_name BasicLightningLine2d 4 | 5 | var lightning_points := PoolVector2Array() 6 | 7 | var points_size := -1 8 | 9 | var show_idx := -1 10 | var is_displaying := false 11 | 12 | # Called when the node enters the scene tree for the first time. 13 | func _ready() -> void: 14 | pass # Replace with function body. 15 | 16 | 17 | # Called every frame. 'delta' is the elapsed time since the previous frame. 18 | #func _process(delta: float) -> void: 19 | # pass 20 | 21 | func clear_lightning_points(): 22 | lightning_points = PoolVector2Array() 23 | 24 | func add_lightning_point(_point := Vector2()): 25 | lightning_points.append(_point) 26 | 27 | func spawn(_lightning_points := lightning_points) -> int: 28 | if _lightning_points.size() <=1: 29 | printerr("points size should > 1") 30 | return FAILED 31 | lightning_points = _lightning_points 32 | points_size = lightning_points.size() 33 | points = PoolVector2Array() 34 | show_idx = -1 35 | return OK 36 | 37 | 38 | 39 | func show_next() -> void: 40 | if lightning_points.size() == 0: 41 | return 42 | if show_idx == points_size - 1: 43 | return 44 | show_idx += 1 45 | add_point(lightning_points[show_idx]) 46 | pass 47 | 48 | func hide_first(): 49 | if lightning_points.size() == 0: 50 | return 51 | if points.size() == 0: 52 | return 53 | #print(hide_idx) 54 | remove_point(0) 55 | pass 56 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/src/test/Demo.gd: -------------------------------------------------------------------------------- 1 | extends Node2D 2 | 3 | onready var _SuperLightning = $SuperLightning 4 | onready var _PassPointsFlags = $PassPointsFlags 5 | 6 | var pass_point_flag_texture = preload("res://addons/DrunkBull.SuperLightning/addon_icon.png") 7 | 8 | # Called when the node enters the scene tree for the first time. 9 | func _ready() -> void: 10 | pass # Replace with function body. 11 | 12 | 13 | # Called every frame. 'delta' is the elapsed time since the previous frame. 14 | #func _process(delta: float) -> void: 15 | # pass 16 | 17 | func _unhandled_input(event: InputEvent) -> void: 18 | if event is InputEventMouseButton: 19 | if event.pressed: 20 | if event.button_index == 1: 21 | if !_SuperLightning.is_lightning: 22 | _SuperLightning.spawn(Vector2(), event.position, 1.5) 23 | _SuperLightning.lightning() 24 | elif event.button_index == 2: 25 | _SuperLightning.add_pass_point(event.position) 26 | update_pass_points_flags() 27 | pass 28 | 29 | func update_pass_points_flags(): 30 | for i in _PassPointsFlags.get_children(): 31 | i.queue_free() 32 | for i in _SuperLightning.pass_points: 33 | var sprite = Sprite.new() 34 | sprite.texture = pass_point_flag_texture 35 | sprite.position = i 36 | _PassPointsFlags.add_child(sprite) 37 | pass 38 | 39 | func _on_ButtonClearPassPoints_pressed() -> void: 40 | _SuperLightning.clear_pass_points() 41 | update_pass_points_flags() 42 | pass # Replace with function body. 43 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/src/test/Demo.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=6 format=2] 2 | 3 | [ext_resource path="res://addons/DrunkBull.SuperLightning/src/test/Demo.gd" type="Script" id=1] 4 | [ext_resource path="res://addons/DrunkBull.SuperLightning/src/main/SuperLightning.gd" type="Script" id=2] 5 | 6 | [sub_resource type="CanvasItemMaterial" id=3] 7 | blend_mode = 1 8 | 9 | [sub_resource type="Environment" id=1] 10 | background_mode = 4 11 | glow_enabled = true 12 | glow_bicubic_upscale = true 13 | 14 | [sub_resource type="CanvasItemMaterial" id=2] 15 | blend_mode = 1 16 | 17 | [node name="Demo" type="Node2D"] 18 | material = SubResource( 3 ) 19 | script = ExtResource( 1 ) 20 | 21 | [node name="WorldEnvironment" type="WorldEnvironment" parent="."] 22 | environment = SubResource( 1 ) 23 | 24 | [node name="SuperLightning" type="Node2D" parent="."] 25 | material = SubResource( 2 ) 26 | script = ExtResource( 2 ) 27 | 28 | [node name="LayerGUI" type="CanvasLayer" parent="."] 29 | 30 | [node name="VBoxContainer" type="VBoxContainer" parent="LayerGUI"] 31 | anchor_left = 1.0 32 | anchor_right = 1.0 33 | margin_left = -150.0 34 | margin_bottom = 68.0 35 | grow_horizontal = 0 36 | __meta__ = { 37 | "_edit_use_anchors_": false 38 | } 39 | 40 | [node name="ButtonClearPassPoints" type="Button" parent="LayerGUI/VBoxContainer"] 41 | margin_right = 264.0 42 | margin_bottom = 50.0 43 | rect_min_size = Vector2( 150, 50 ) 44 | text = "clear pass points" 45 | __meta__ = { 46 | "_edit_use_anchors_": false 47 | } 48 | 49 | [node name="Label" type="Label" parent="LayerGUI/VBoxContainer"] 50 | margin_top = 54.0 51 | margin_right = 264.0 52 | margin_bottom = 85.0 53 | grow_horizontal = 0 54 | grow_vertical = 0 55 | text = "use left mouse button to take lightning 56 | use right mouse button to add pass point" 57 | __meta__ = { 58 | "_edit_use_anchors_": false 59 | } 60 | 61 | [node name="PassPointsFlags" type="Node2D" parent="."] 62 | 63 | [connection signal="pressed" from="LayerGUI/VBoxContainer/ButtonClearPassPoints" to="." method="_on_ButtonClearPassPoints_pressed"] 64 | -------------------------------------------------------------------------------- /addons/DrunkBull.SuperLightning/src/main/SuperLightning.gd: -------------------------------------------------------------------------------- 1 | extends Node2D 2 | 3 | #闪电颜色 4 | export(Color) var LINE_BASIC_COLOR := Color.lightskyblue 5 | #闪电条数数量随机范围 6 | export(Vector2) var LINES_RANGE := Vector2(5, 7) 7 | #闪电每根线宽度曲线 8 | export(Curve) var LINE_BASIC_WIDTH_CURVE := preload("res://addons/DrunkBull.SuperLightning/assets/resource/line_basic_curve.tres") 9 | #闪电每根线宽度随机范围 10 | export(Vector2) var LINE_WIDTH_RANGE := Vector2(100, 200) 11 | #闪电每根线颜色梯度 12 | export(Gradient) var LINE_BASIC_GRADIENT := preload("res://addons/DrunkBull.SuperLightning/assets/resource/line_basic_gradient.tres") 13 | #闪电每根线一个点多少像素(数值越小,线points越多) 14 | export(int) var LINE_PIXELS_PER_POINT := 30 15 | #闪电每根线每个点随机位置范围(数值越大,线points偏离方向越厉害) 16 | export(Vector2) var MIDDLE_LINE_POINTS_FLOAT_RANGE := Vector2(-100, 100) 17 | #闪电每根线的每个点绕随机好的点再随机一次的乘积范围(数值越大,每根线的同一个地方的点越互相偏离) 18 | export(Vector2) var LINE_POINTS_FLOAT_SCALE_RANGE_MIDDLE_LINE := Vector2(-0.2, 0.2) 19 | #是否随机首点的位置 20 | export(bool) var RANDOM_FIRST_POINT_POSITION := false 21 | #是否随机末点的位置 22 | export(bool) var RANDOM_LAST_POINT_POSITION := false 23 | #点全部显示出来占总时间比值 24 | export(float) var LINE_POINTS_FULL_DISPLAY_TIME_PROPORTION := 0.97 25 | #已经显示多少比例的点后,点开始逐渐消失 26 | export(float) var LINE_START_TO_HIDE_POINT_WHEN_SHOWED_POINTS_PERCENT_REACH := 1.0 27 | #闪电动画 28 | export(Animation) var LIGHTNING_ANIMATION := preload("res://addons/DrunkBull.SuperLightning/assets/resource/lightning_animation.tres") 29 | 30 | var start_point := Vector2() 31 | var end_point := Vector2() 32 | var last_time := 1.5 33 | var is_lightning := false 34 | var pass_points := PoolVector2Array() 35 | 36 | var _direction := Vector2() 37 | var _normal_direction := Vector2() 38 | var _length := 0.0 39 | var _points_count := -1 40 | var _total_points_count := -1 41 | var _lines_count := -1 42 | var _showed_points_count := -1 43 | var _hiding_point := false 44 | var _points_full_display_time := 0.0 45 | var _points_gradually_show_period := 0.0 46 | var _had_points_full_display_wait := false 47 | 48 | var Scene_BasicLightningLine2d = preload("res://addons/DrunkBull.SuperLightning/src/main/BasicLightningLine2d.tscn") 49 | 50 | var lightning_textures := [ 51 | preload("res://addons/DrunkBull.SuperLightning/assets/art/spark_05_rotated.png"), 52 | preload("res://addons/DrunkBull.SuperLightning/assets/art/spark_06_rotated.png"), 53 | preload("res://addons/DrunkBull.SuperLightning/assets/art/spark_07_rotated.png"), 54 | preload("res://addons/DrunkBull.SuperLightning/assets/art/trace_01_rotated.png"), 55 | preload("res://addons/DrunkBull.SuperLightning/assets/art/trace_02_rotated.png"), 56 | preload("res://addons/DrunkBull.SuperLightning/assets/art/trace_03_rotated.png"), 57 | preload("res://addons/DrunkBull.SuperLightning/assets/art/trace_04_rotated.png"), 58 | preload("res://addons/DrunkBull.SuperLightning/assets/art/trace_05_rotated.png") 59 | ] 60 | 61 | var lines := [] 62 | 63 | onready var _TimerGraduallyShowHide = Timer.new() 64 | onready var _TimerLightning = Timer.new() 65 | onready var _Lines = Node2D.new() 66 | onready var _AnimationPlayer = AnimationPlayer.new() 67 | 68 | # Called when the node enters the scene tree for the first time. 69 | func _ready() -> void: 70 | add_child(_TimerGraduallyShowHide) 71 | _TimerGraduallyShowHide.connect("timeout", self, "_on_TimerGraduallyShowHide_timeout") 72 | _TimerGraduallyShowHide.one_shot = true 73 | add_child(_TimerLightning) 74 | _TimerLightning.connect("timeout", self, "_on_TimerLightning_timeout") 75 | _TimerLightning.one_shot = true 76 | add_child(_Lines) 77 | _Lines.use_parent_material = true 78 | 79 | add_child(_AnimationPlayer) 80 | _AnimationPlayer.root_node = ".." 81 | 82 | for i in LINES_RANGE.y: 83 | var new_line = Scene_BasicLightningLine2d.instance() 84 | _Lines.add_child(new_line) 85 | lines.append(new_line) 86 | pass # Replace with function body. 87 | 88 | func random_int_range(from : int, to : int, contain_to := true) -> int: 89 | if contain_to: 90 | return randi() % (1 + to - from) + from 91 | else: 92 | return randi() % (to - from) + from 93 | 94 | func add_pass_point(point : Vector2): 95 | pass_points.append(point) 96 | 97 | func clear_pass_points(): 98 | pass_points = PoolVector2Array() 99 | 100 | #last_time,闪电持续时间 101 | func spawn(_start_point := start_point, _end_point := end_point, _last_time : float = last_time) -> void: 102 | hide() 103 | start_point = _start_point 104 | end_point = _end_point 105 | last_time = _last_time 106 | 107 | _lines_count = random_int_range(LINES_RANGE.x, LINES_RANGE.y) 108 | 109 | for i in lines.size(): 110 | var lightning_line : BasicLightningLine2d = lines[i] 111 | lightning_line.clear_lightning_points() 112 | lightning_line.hide() 113 | 114 | lightning_line.texture = lightning_textures[randi() % lightning_textures.size()] 115 | lightning_line.width = rand_range(LINE_WIDTH_RANGE.x, LINE_WIDTH_RANGE.y) 116 | lightning_line.gradient = LINE_BASIC_GRADIENT 117 | lightning_line.modulate = LINE_BASIC_COLOR 118 | lightning_line.width_curve = LINE_BASIC_WIDTH_CURVE 119 | 120 | if pass_points.size() == 0: 121 | _direction = (end_point - start_point).normalized() 122 | _normal_direction = _direction.rotated(PI / 2) 123 | _length = (end_point - start_point).length() 124 | _points_count = _length / LINE_PIXELS_PER_POINT 125 | _total_points_count = _points_count 126 | assert(_points_count > 1) 127 | for i in _points_count: 128 | if i == 0: 129 | if !RANDOM_FIRST_POINT_POSITION: 130 | for j in _lines_count: 131 | lines[j].add_lightning_point(start_point) 132 | continue 133 | if i == _points_count - 1: 134 | if !RANDOM_LAST_POINT_POSITION: 135 | for j in _lines_count: 136 | lines[j].add_lightning_point(end_point) 137 | continue 138 | var basic_point : Vector2 = start_point + i * LINE_PIXELS_PER_POINT * _direction 139 | var random_vector : Vector2 = rand_range(MIDDLE_LINE_POINTS_FLOAT_RANGE.x, MIDDLE_LINE_POINTS_FLOAT_RANGE.y) * _normal_direction 140 | for j in _lines_count: 141 | var vector = random_vector * rand_range(LINE_POINTS_FLOAT_SCALE_RANGE_MIDDLE_LINE.x, LINE_POINTS_FLOAT_SCALE_RANGE_MIDDLE_LINE.y) 142 | var pos = basic_point + vector 143 | lines[j].add_lightning_point(pos) 144 | else: 145 | for i in pass_points.size() + 1: 146 | var _from_point := Vector2() 147 | if i == 0: 148 | _direction = (pass_points[0] - start_point).normalized() 149 | _normal_direction = _direction.rotated(PI / 2) 150 | _length = (pass_points[0] - start_point).length() 151 | _points_count = _length / LINE_PIXELS_PER_POINT 152 | _from_point = start_point 153 | elif i == pass_points.size(): 154 | _direction = (end_point - pass_points[i - 1]).normalized() 155 | _normal_direction = _direction.rotated(PI / 2) 156 | _length = (end_point - pass_points[i - 1]).length() 157 | _points_count = _length / LINE_PIXELS_PER_POINT 158 | _from_point = pass_points[i - 1] 159 | else: 160 | _direction = (pass_points[i] - pass_points[i - 1]).normalized() 161 | _normal_direction = _direction.rotated(PI / 2) 162 | _length = (pass_points[i] - pass_points[i - 1]).length() 163 | _points_count = _length / LINE_PIXELS_PER_POINT 164 | _from_point = pass_points[i - 1] 165 | if _points_count < 1: 166 | _points_count = 1 167 | _total_points_count += _points_count 168 | for j in _points_count: 169 | var basic_point : Vector2 = _from_point + j * LINE_PIXELS_PER_POINT * _direction 170 | var random_vector : Vector2 = rand_range(MIDDLE_LINE_POINTS_FLOAT_RANGE.x, MIDDLE_LINE_POINTS_FLOAT_RANGE.y) * _normal_direction 171 | for k in _lines_count: 172 | var vector = random_vector * rand_range(LINE_POINTS_FLOAT_SCALE_RANGE_MIDDLE_LINE.x, LINE_POINTS_FLOAT_SCALE_RANGE_MIDDLE_LINE.y) 173 | var pos = basic_point + vector 174 | lines[k].add_lightning_point(pos) 175 | pass 176 | 177 | func lightning(): 178 | _showed_points_count = 0 179 | _had_points_full_display_wait = false 180 | _hiding_point = false 181 | _points_full_display_time = last_time * LINE_POINTS_FULL_DISPLAY_TIME_PROPORTION 182 | _points_gradually_show_period = (last_time - _points_full_display_time) / _total_points_count 183 | for i in _lines_count: 184 | var lightning_line : BasicLightningLine2d = lines[i] 185 | lightning_line.spawn() 186 | lightning_line.show() 187 | show() 188 | #_TweenFade.interpolate_property(self, "modulate", modulate, Color(modulate.r, modulate.g, modulate.b, )) 189 | var ani_speed = 1.0 / last_time 190 | if !_AnimationPlayer.has_animation(LIGHTNING_ANIMATION.resource_name): 191 | _AnimationPlayer.add_animation(LIGHTNING_ANIMATION.resource_name, LIGHTNING_ANIMATION) 192 | _AnimationPlayer.playback_speed = ani_speed 193 | _AnimationPlayer.play(LIGHTNING_ANIMATION.resource_name) 194 | 195 | _TimerLightning.start(last_time) 196 | _TimerGraduallyShowHide.start(_points_gradually_show_period) 197 | _TimerGraduallyShowHide.paused = false 198 | 199 | is_lightning = true 200 | 201 | pass 202 | 203 | 204 | func _on_TimerLightning_timeout() -> void: 205 | hide() 206 | is_lightning = false 207 | _TimerGraduallyShowHide.paused = true 208 | pass # Replace with function body. 209 | 210 | 211 | func _on_TimerGraduallyShowHide_timeout() -> void: 212 | if is_lightning: 213 | if !_had_points_full_display_wait: 214 | if _showed_points_count == _total_points_count: 215 | yield(get_tree().create_timer(_points_full_display_time * 0.8), "timeout") 216 | _had_points_full_display_wait = true 217 | var showed_percent : float = float(_showed_points_count) / _total_points_count 218 | if !_hiding_point: 219 | if showed_percent >= LINE_START_TO_HIDE_POINT_WHEN_SHOWED_POINTS_PERCENT_REACH: 220 | _hiding_point = true 221 | for i in _lines_count: 222 | var lightning_line : BasicLightningLine2d = lines[i] 223 | if _hiding_point: 224 | lightning_line.hide_first() 225 | lightning_line.show_next() 226 | _showed_points_count += 1 227 | _TimerGraduallyShowHide.start(_points_gradually_show_period) 228 | pass # Replace with function body. 229 | --------------------------------------------------------------------------------