commit 4ea63b7d501a028927eb37927044f9dee52c5a31 Author: teascade Date: Tue Nov 21 19:33:48 2017 +0200 Initial commit diff --git a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex new file mode 100644 index 0000000..1f08a3c Binary files /dev/null and b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex differ diff --git a/.vs/TicTacToe/v15/.suo b/.vs/TicTacToe/v15/.suo new file mode 100644 index 0000000..d4d5bb6 Binary files /dev/null and b/.vs/TicTacToe/v15/.suo differ diff --git a/.vs/TicTacToe/v15/sqlite3/storage.ide b/.vs/TicTacToe/v15/sqlite3/storage.ide new file mode 100644 index 0000000..3bfe1a0 Binary files /dev/null and b/.vs/TicTacToe/v15/sqlite3/storage.ide differ diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..48b5364 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,25 @@ +using System.Reflection; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle("TicTacToe")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] diff --git a/TicTacToe.csproj b/TicTacToe.csproj new file mode 100644 index 0000000..da1a8a9 --- /dev/null +++ b/TicTacToe.csproj @@ -0,0 +1,61 @@ + + + + Debug + AnyCPU + {41EC1A8B-1B05-43BC-B84A-A5BFD755B0F7} + Library + .mono\temp\bin\$(Configuration) + TicTacToe + TicTacToe + v4.5 + .mono\temp\obj + $(BaseIntermediateOutputPath)\$(Configuration) + + + true + full + false + DEBUG; + prompt + 4 + false + + + full + true + prompt + 4 + false + + + true + full + false + DEBUG;TOOLS; + prompt + 4 + false + + + + $(ProjectDir)\.mono\assemblies\GodotSharp.dll + False + + + $(ProjectDir)\.mono\assemblies\GodotSharpEditor.dll + False + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TicTacToe.sln b/TicTacToe.sln new file mode 100644 index 0000000..b8dea7c --- /dev/null +++ b/TicTacToe.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TicTacToe", "TicTacToe.csproj", "{41EC1A8B-1B05-43BC-B84A-A5BFD755B0F7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + Tools|Any CPU = Tools|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {41EC1A8B-1B05-43BC-B84A-A5BFD755B0F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {41EC1A8B-1B05-43BC-B84A-A5BFD755B0F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {41EC1A8B-1B05-43BC-B84A-A5BFD755B0F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {41EC1A8B-1B05-43BC-B84A-A5BFD755B0F7}.Release|Any CPU.Build.0 = Release|Any CPU + {41EC1A8B-1B05-43BC-B84A-A5BFD755B0F7}.Tools|Any CPU.ActiveCfg = Tools|Any CPU + {41EC1A8B-1B05-43BC-B84A-A5BFD755B0F7}.Tools|Any CPU.Build.0 = Tools|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2416B7D3-E503-4AAE-84FB-D22C08EEF32E} + EndGlobalSection +EndGlobal diff --git a/default_env.tres b/default_env.tres new file mode 100644 index 0000000..ad86b72 --- /dev/null +++ b/default_env.tres @@ -0,0 +1,101 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +radiance_size = 4 +sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 ) +sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 ) +sky_curve = 0.25 +sky_energy = 1.0 +ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 ) +ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 ) +ground_curve = 0.01 +ground_energy = 1.0 +sun_color = Color( 1, 1, 1, 1 ) +sun_latitude = 35.0 +sun_longitude = 0.0 +sun_angle_min = 1.0 +sun_angle_max = 100.0 +sun_curve = 0.05 +sun_energy = 16.0 +texture_size = 2 + +[resource] + +background_mode = 2 +background_sky = SubResource( 1 ) +background_sky_custom_fov = 0.0 +background_color = Color( 0, 0, 0, 1 ) +background_energy = 1.0 +background_canvas_max_layer = 0 +ambient_light_color = Color( 0, 0, 0, 1 ) +ambient_light_energy = 1.0 +ambient_light_sky_contribution = 1.0 +fog_enabled = false +fog_color = Color( 0.5, 0.6, 0.7, 1 ) +fog_sun_color = Color( 1, 0.9, 0.7, 1 ) +fog_sun_amount = 0.0 +fog_depth_enabled = true +fog_depth_begin = 10.0 +fog_depth_curve = 1.0 +fog_transmit_enabled = false +fog_transmit_curve = 1.0 +fog_height_enabled = false +fog_height_min = 0.0 +fog_height_max = 100.0 +fog_height_curve = 1.0 +tonemap_mode = 0 +tonemap_exposure = 1.0 +tonemap_white = 1.0 +auto_exposure_enabled = false +auto_exposure_scale = 0.4 +auto_exposure_min_luma = 0.05 +auto_exposure_max_luma = 8.0 +auto_exposure_speed = 0.5 +ss_reflections_enabled = false +ss_reflections_max_steps = 64 +ss_reflections_fade_in = 0.15 +ss_reflections_fade_out = 2.0 +ss_reflections_depth_tolerance = 0.2 +ss_reflections_roughness = true +ssao_enabled = false +ssao_radius = 1.0 +ssao_intensity = 1.0 +ssao_radius2 = 0.0 +ssao_intensity2 = 1.0 +ssao_bias = 0.01 +ssao_light_affect = 0.0 +ssao_color = Color( 0, 0, 0, 1 ) +ssao_quality = 0 +ssao_blur = 3 +ssao_edge_sharpness = 4.0 +dof_blur_far_enabled = false +dof_blur_far_distance = 10.0 +dof_blur_far_transition = 5.0 +dof_blur_far_amount = 0.1 +dof_blur_far_quality = 1 +dof_blur_near_enabled = false +dof_blur_near_distance = 2.0 +dof_blur_near_transition = 1.0 +dof_blur_near_amount = 0.1 +dof_blur_near_quality = 1 +glow_enabled = false +glow_levels/1 = false +glow_levels/2 = false +glow_levels/3 = true +glow_levels/4 = false +glow_levels/5 = true +glow_levels/6 = false +glow_levels/7 = false +glow_intensity = 0.8 +glow_strength = 1.0 +glow_bloom = 0.0 +glow_blend_mode = 2 +glow_hdr_threshold = 1.0 +glow_hdr_scale = 2.0 +glow_bicubic_upscale = false +adjustment_enabled = false +adjustment_brightness = 1.0 +adjustment_contrast = 1.0 +adjustment_saturation = 1.0 + diff --git a/dist/321.exe b/dist/321.exe new file mode 100644 index 0000000..ffbc894 Binary files /dev/null and b/dist/321.exe differ diff --git a/dist/321.pck b/dist/321.pck new file mode 100644 index 0000000..18f083b Binary files /dev/null and b/dist/321.pck differ diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..daff3c1 --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,19 @@ +[preset.0] + +custom_features="" +exclude_filter="" +export_filter="all_resources" +include_filter="" +name="Windows Desktop" +patch_list=PoolStringArray( ) +platform="Windows Desktop" +runnable=true + +[preset.0.options] + +binary_format/64_bits=true +custom_template/debug="" +custom_template/release="" +texture_format/etc=false +texture_format/etc2=false +texture_format/s3tc=true diff --git a/fonts/DynamicFonts/Regular.tres b/fonts/DynamicFonts/Regular.tres new file mode 100644 index 0000000..8cd1716 --- /dev/null +++ b/fonts/DynamicFonts/Regular.tres @@ -0,0 +1,12 @@ +[gd_resource type="DynamicFont" load_steps=2 format=2] + +[ext_resource path="res://fonts/Roboto.ttf" type="DynamicFontData" id=1] + +[resource] + +size = 16 +use_mipmaps = false +use_filter = true +font_data = ExtResource( 1 ) +_sections_unfolded = [ "Font", "Settings" ] + diff --git a/fonts/DynamicFonts/Title.tres b/fonts/DynamicFonts/Title.tres new file mode 100644 index 0000000..120fb9a --- /dev/null +++ b/fonts/DynamicFonts/Title.tres @@ -0,0 +1,12 @@ +[gd_resource type="DynamicFont" load_steps=2 format=2] + +[ext_resource path="res://fonts/Roboto.ttf" type="DynamicFontData" id=1] + +[resource] + +size = 30 +use_mipmaps = false +use_filter = true +font_data = ExtResource( 1 ) +_sections_unfolded = [ "Font", "Settings" ] + diff --git a/fonts/Roboto.ttf b/fonts/Roboto.ttf new file mode 100644 index 0000000..2c97eea Binary files /dev/null and b/fonts/Roboto.ttf differ diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..a0b64ee Binary files /dev/null and b/icon.png differ diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..42e94a3 --- /dev/null +++ b/icon.png.import @@ -0,0 +1,24 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..1775ea3 --- /dev/null +++ b/project.godot @@ -0,0 +1,27 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=3 + +[application] + +config/name="TicTacToe" +run/main_scene="res://scenes/MainMenu.tscn" +config/icon="res://icon.png" + +[autoload] + +Net="*res://scripts/Net.cs" + +[gdnative] + +singletons=[ ] + +[rendering] + +environment/default_environment="res://default_env.tres" diff --git a/scenes/MainMenu.tscn b/scenes/MainMenu.tscn new file mode 100644 index 0000000..9755ac0 --- /dev/null +++ b/scenes/MainMenu.tscn @@ -0,0 +1,192 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://scripts/MainMenu.cs" type="Script" id=1] +[ext_resource path="res://fonts/DynamicFonts/Title.tres" type="DynamicFont" id=2] +[ext_resource path="res://fonts/DynamicFonts/Regular.tres" type="DynamicFont" id=3] + +[node name="Root" type="Node"] + +[node name="Panel" type="Panel" parent="."] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 99.0 +margin_top = 101.0 +margin_right = -101.0 +margin_bottom = -99.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +script = ExtResource( 1 ) +_sections_unfolded = [ "Margin" ] + +[node name="Title" type="Label" parent="Panel"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 1.0 +anchor_bottom = 0.0 +margin_bottom = 36.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 2 +size_flags_horizontal = 1 +size_flags_vertical = 4 +custom_fonts/font = ExtResource( 2 ) +text = "Tic Tac Toe" +align = 1 +valign = 1 +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 +_sections_unfolded = [ "BBCode", "Rect", "custom_fonts" ] + +[node name="LaunchServer" type="Button" parent="Panel"] + +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -150.0 +margin_top = 99.0 +margin_right = -37.0 +margin_bottom = 124.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +custom_fonts/font = ExtResource( 3 ) +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null +text = "Launch Server" +flat = false +_sections_unfolded = [ "Margin", "custom_fonts" ] + +[node name="LaunchClient" type="Button" parent="Panel"] + +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = 40.0 +margin_top = 98.0 +margin_right = 149.0 +margin_bottom = 123.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +custom_fonts/font = ExtResource( 3 ) +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null +text = "Launch Client" +flat = false +_sections_unfolded = [ "Margin", "custom_fonts" ] + +[node name="IPLabel" type="Label" parent="Panel"] + +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -75.0 +margin_top = -121.0 +margin_right = 74.0 +margin_bottom = -102.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 2 +size_flags_horizontal = 1 +size_flags_vertical = 4 +custom_fonts/font = ExtResource( 3 ) +text = "IP Address" +align = 1 +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 +_sections_unfolded = [ "Margin", "custom_fonts" ] + +[node name="PortLabel" type="Label" parent="Panel"] + +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -75.0 +margin_top = -65.0 +margin_right = 74.0 +margin_bottom = -46.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 2 +size_flags_horizontal = 1 +size_flags_vertical = 4 +custom_fonts/font = ExtResource( 3 ) +text = "Port" +align = 1 +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 +_sections_unfolded = [ "Margin", "custom_fonts" ] + +[node name="IPAddress" type="LineEdit" parent="Panel"] + +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -84.0 +margin_top = -95.0 +margin_right = 83.0 +margin_bottom = -71.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +expand_to_len = false +focus_mode = 2 +placeholder_text = "localhost / *" +placeholder_alpha = 0.6 +caret_blink = false +caret_blink_speed = 0.65 +_sections_unfolded = [ "Placeholder" ] + +[node name="Port" type="LineEdit" parent="Panel"] + +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -84.0 +margin_top = -39.0 +margin_right = 83.0 +margin_bottom = -15.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +expand_to_len = false +focus_mode = 2 +placeholder_text = "8080" +placeholder_alpha = 0.6 +caret_blink = false +caret_blink_speed = 0.65 +_sections_unfolded = [ "Placeholder" ] + +[connection signal="pressed" from="Panel/LaunchServer" to="Panel" method="OnLaunchServer"] + +[connection signal="pressed" from="Panel/LaunchClient" to="Panel" method="OnLaunchClient"] + + diff --git a/scripts/Client.cs b/scripts/Client.cs new file mode 100644 index 0000000..4171520 --- /dev/null +++ b/scripts/Client.cs @@ -0,0 +1,24 @@ +using Godot; + +public class Client : Peer { + + private PacketPeerUDP PacketPeer; + + private Connection ServerConn; + + private byte[] TempBuffer = {1}; + + public Client(PacketPeerUDP packetPeer) : base(packetPeer) { + PacketPeer = packetPeer; + } + + public override void Initialize(string address, int port) { + GD.print("Start client."); + ServerConn = new Connection(address, port); + } + + public override void Update(float delta) { + GD.print("Update client."); + SendBuffer(TempBuffer, ServerConn); + } +} \ No newline at end of file diff --git a/scripts/Connection.cs b/scripts/Connection.cs new file mode 100644 index 0000000..a28b8cf --- /dev/null +++ b/scripts/Connection.cs @@ -0,0 +1,13 @@ + +public class Connection { + + private static int IDCounter = 0; + public readonly int ID = IDCounter++; + public string Address; + public int Port; + + public Connection(string address, int port) { + Address = address; + Port = port; + } +} \ No newline at end of file diff --git a/scripts/MainMenu.cs b/scripts/MainMenu.cs new file mode 100644 index 0000000..f11c9a6 --- /dev/null +++ b/scripts/MainMenu.cs @@ -0,0 +1,22 @@ +using Godot; +using System; + +public class MainMenu : Panel { + + private Net Net; + + public override void _Ready() { + Net = (Net) GetNode("/root/Net"); + } + + private void OnLaunchServer() { + GD.print("Launch Server!"); + Net.StartServer(); + } + + + private void OnLaunchClient() { + GD.print("Launch Client!"); + Net.StartClient(); + } +} diff --git a/scripts/Net.cs b/scripts/Net.cs new file mode 100644 index 0000000..8c9bd36 --- /dev/null +++ b/scripts/Net.cs @@ -0,0 +1,37 @@ +using Godot; + +public class Net : Node { + + private PacketPeerUDP PacketPeer; + private Client Client; + private Server Server; + + public override void _Ready() { + PacketPeer = new PacketPeerUDP(); + } + + public override void _Process(float delta) { + if (IsServer()) { Server.Update(delta); } + if (IsClient()) { Client.Update(delta); } + } + + public void StartClient() { + //if (IsClient() || IsServer()) { return; } + Client = new Client(PacketPeer); + Client.Initialize("localhost", 8080); + } + + public void StartServer() { + //if (IsClient() || IsServer()) { return; } + Server = new Server(PacketPeer); + Server.Initialize("*", 8080); + } + + public bool IsClient() { + return Client != null; + } + + public bool IsServer() { + return Server != null; + } +} diff --git a/scripts/Peer.cs b/scripts/Peer.cs new file mode 100644 index 0000000..3434652 --- /dev/null +++ b/scripts/Peer.cs @@ -0,0 +1,22 @@ +using Godot; + +public abstract class Peer : Object { + + private PacketPeerUDP PacketPeer; + + private int LastConnectionSended = -1; + + public Peer(PacketPeerUDP packetPeer) { + PacketPeer = packetPeer; + } + + public abstract void Initialize(string address, int port); + public abstract void Update(float delta); + + public void SendBuffer(byte[] buffer, Connection to) { + GD.print("Putting stuff to " + to.Address + ":" + to.Port); + PacketPeer.SetDestAddress(to.Address, to.Port); + PacketPeer.PutPacket(buffer); + } + +} \ No newline at end of file diff --git a/scripts/Server.cs b/scripts/Server.cs new file mode 100644 index 0000000..873f3e6 --- /dev/null +++ b/scripts/Server.cs @@ -0,0 +1,31 @@ +using Godot; +using System.Threading; + +public class Server : Peer { + + private static PacketPeerUDP PacketPeer; + + public Server(PacketPeerUDP packetPeer) : base(packetPeer) { + PacketPeer = packetPeer; + } + + public override void Initialize(string address, int port) { + PacketPeer.Listen(port, address); + ThreadStart childref = new ThreadStart(ListenerThread); + System.Threading.Thread thread = new System.Threading.Thread(childref); + thread.Start(); + GD.print("Server initialization finished."); + } + + public override void Update(float delta) { + } + + public static void ListenerThread() { + GD.print("Started Listener Thread."); + while (true) { + PacketPeer.Wait(); + GD.print("Received stuff from " + PacketPeer.GetPacketIp() + " : " + PacketPeer.GetPacketPort() + " :"); + GD.print(PacketPeer.GetPacket()[0]); + } + } +} \ No newline at end of file