Initial commit

This commit is contained in:
Sofia 2017-11-21 19:33:48 +02:00
commit 4ea63b7d50
23 changed files with 649 additions and 0 deletions

Binary file not shown.

BIN
.vs/TicTacToe/v15/.suo Normal file

Binary file not shown.

Binary file not shown.

View File

@ -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("")]

61
TicTacToe.csproj Normal file
View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{41EC1A8B-1B05-43BC-B84A-A5BFD755B0F7}</ProjectGuid>
<OutputType>Library</OutputType>
<OutputPath>.mono\temp\bin\$(Configuration)</OutputPath>
<RootNamespace>TicTacToe</RootNamespace>
<AssemblyName>TicTacToe</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<BaseIntermediateOutputPath>.mono\temp\obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)\$(Configuration)</IntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Tools|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TOOLS;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="GodotSharp">
<HintPath>$(ProjectDir)\.mono\assemblies\GodotSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Tools' ">
<HintPath>$(ProjectDir)\.mono\assemblies\GodotSharpEditor.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="scripts\Client.cs" />
<Compile Include="scripts\Connection.cs" />
<Compile Include="scripts\MainMenu.cs" />
<Compile Include="scripts\Net.cs" />
<Compile Include="scripts\Peer.cs" />
<Compile Include="scripts\Server.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

27
TicTacToe.sln Normal file
View File

@ -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

101
default_env.tres Normal file
View File

@ -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

BIN
dist/321.exe vendored Normal file

Binary file not shown.

BIN
dist/321.pck vendored Normal file

Binary file not shown.

19
export_presets.cfg Normal file
View File

@ -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

View File

@ -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" ]

View File

@ -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" ]

BIN
fonts/Roboto.ttf Normal file

Binary file not shown.

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

24
icon.png.import Normal file
View File

@ -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

27
project.godot Normal file
View File

@ -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"

192
scenes/MainMenu.tscn Normal file
View File

@ -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"]

24
scripts/Client.cs Normal file
View File

@ -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);
}
}

13
scripts/Connection.cs Normal file
View File

@ -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;
}
}

22
scripts/MainMenu.cs Normal file
View File

@ -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();
}
}

37
scripts/Net.cs Normal file
View File

@ -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;
}
}

22
scripts/Peer.cs Normal file
View File

@ -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);
}
}

31
scripts/Server.cs Normal file
View File

@ -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]);
}
}
}