Skip to content

Commit

Permalink
2.5D Demo Project for Mono C#
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen Agbete (Steph155) <bgsteph15@mail.com>
  • Loading branch information
aaronfranke and Stephen Agbete (Steph155) committed Jun 19, 2019
1 parent 0db440b commit f9c629d
Show file tree
Hide file tree
Showing 76 changed files with 2,924 additions and 0 deletions.
64 changes: 64 additions & 0 deletions mono/2.5d/2.5D Demo (Mono C#).csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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>{5CA791DB-5050-44D0-989B-41D559AB1D50}</ProjectGuid>
<OutputType>Library</OutputType>
<OutputPath>.mono/temp/bin/$(Configuration)</OutputPath>
<RootNamespace>Empty.DMono</RootNamespace>
<AssemblyName>2.5D Demo (Mono C#)</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>portable</DebugType>
<Optimize>false</Optimize>
<DefineConstants>$(GodotDefineConstants);GODOT;DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Tools|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<DefineConstants>$(GodotDefineConstants);GODOT;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="addons\node25d-cs\Basis25D.cs" />
<Compile Include="addons\node25d-cs\Node25D.cs" />
<Compile Include="addons\node25d-cs\ShadowMath25D.cs" />
<Compile Include="addons\node25d-cs\Transform25D.cs" />
<Compile Include="addons\node25d-cs\YSort25D.cs" />
<Compile Include="Assets\Cube\CubeMath.cs" />
<Compile Include="Assets\Player\PlayerMath25D.cs" />
<Compile Include="Assets\Player\PlayerSprite.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
19 changes: 19 additions & 0 deletions mono/2.5d/2.5D Demo (Mono C#).sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2.5D Demo (Mono C#)", "2.5D Demo (Mono C#).csproj", "{5CA791DB-5050-44D0-989B-41D559AB1D50}"
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
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Release|Any CPU.Build.0 = Release|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
{5CA791DB-5050-44D0-989B-41D559AB1D50}.Tools|Any CPU.Build.0 = Tools|Any CPU
EndGlobalSection
EndGlobal
20 changes: 20 additions & 0 deletions mono/2.5d/Assets/Cube.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[gd_scene load_steps=5 format=2]

[ext_resource path="res://addons/node25d-cs/YSort25D.cs" type="Script" id=1]
[ext_resource path="res://addons/node25d-cs/icons/ysort25d_icon.png" type="Texture" id=2]
[ext_resource path="res://Assets/UI/OverlayCube.tscn" type="PackedScene" id=3]
[ext_resource path="res://Assets/Cube/CubeMath.cs" type="Script" id=4]

[node name="Cube" type="Node2D"]
script = ExtResource( 1 )
__meta__ = {
"_editor_icon": ExtResource( 2 )
}

[node name="Overlay" parent="." instance=ExtResource( 3 )]

[node name="Camera2D" type="Camera2D" parent="."]
current = true

[node name="CubeMath" type="Spatial" parent="."]
script = ExtResource( 4 )
68 changes: 68 additions & 0 deletions mono/2.5d/Assets/Cube/CubeMath.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Godot;
using System;

public class CubeMath : Spatial
{
private static PackedScene cubePointScene = ResourceLoader.Load<PackedScene>("res://Assets/Cube/CubePoint.tscn");

private bool isParentReady = false;
private Node2D parent;
private Spatial[] cubePointsMath = new Spatial[27]; // The math node of each 2.5D cube point
private Spatial[] cubeMathSpatials = new Spatial[27]; // The CubeMath children that find position.

public override void _Ready()
{
parent = GetParent<Node2D>();

// Initialize the cube
for (int i = 0; i < 27; i++)
{
int a = (i / 9) - 1;
int b = (i / 3) % 3 - 1;
int c = (i % 3) - 1;
Vector3 spatialPosition = 5 * (a * Vector3.Right + b * Vector3.Up + c * Vector3.Back);

cubeMathSpatials[i] = new Spatial();
cubeMathSpatials[i].Translation = spatialPosition;
cubeMathSpatials[i].Name = "CubeMath #" + i + ", " + a + " " + b + " " + c;
AddChild(cubeMathSpatials[i]);
}
}

public override void _Process(float delta)
{
if (Input.IsActionJustPressed("ViewCubeDemo"))
{
GetTree().ChangeScene("res://Assets/DemoScene.tscn");
return;
}

if (isParentReady)
{
RotateX(delta * (Input.GetActionStrength("MoveBackward") - Input.GetActionStrength("MoveForward")));
RotateY(delta * (Input.GetActionStrength("MoveRight") - Input.GetActionStrength("MoveLeft")));
RotateZ(delta * (Input.GetActionStrength("MoveCounterclockwise") - Input.GetActionStrength("MoveClockwise")));
if (Input.IsActionJustPressed("ResetPosition"))
{
Transform = Transform.Identity;
}
for (int i = 0; i < 27; i++)
{
cubePointsMath[i].GlobalTransform = cubeMathSpatials[i].GlobalTransform;
}
}
else
{
// This code block will be run only once. It's not in _Ready() because the parent isn't set up there.
for (int i = 0; i < 27; i++)
{
PackedScene myCubePointScene = cubePointScene.Duplicate(true) as PackedScene;
Node25D cubePoint = myCubePointScene.Instance() as Node25D;
cubePoint.Name = "CubePoint #" + i;
cubePointsMath[i] = cubePoint.GetChild<Spatial>(0);
parent.AddChild(cubePoint);
}
isParentReady = true;
}
}
}
16 changes: 16 additions & 0 deletions mono/2.5d/Assets/Cube/CubePoint.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://addons/node25d-cs/Node25D.cs" type="Script" id=1]
[ext_resource path="res://addons/node25d-cs/icons/node25d_icon.png" type="Texture" id=2]
[ext_resource path="res://Assets/Cube/godot.png" type="Texture" id=3]

[node name="CubePoint" type="Node2D"]
script = ExtResource( 1 )
__meta__ = {
"_editor_icon": ExtResource( 2 )
}

[node name="CubePointMath" type="Spatial" parent="."]

[node name="CubePointSprite" type="Sprite" parent="."]
texture = ExtResource( 3 )
Binary file added mono/2.5d/Assets/Cube/godot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions mono/2.5d/Assets/Cube/godot.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/godot.png-3e601e6c27d3d4bf4c56687ed358139e.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Assets/Cube/godot.png"
dest_files=[ "res://.import/godot.png-3e601e6c27d3d4bf4c56687ed358139e.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=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
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Loading

0 comments on commit f9c629d

Please sign in to comment.