-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 377b5f1
Showing
19 changed files
with
568 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* | ||
|
||
!.gitignore | ||
!*/ | ||
!/Assets/Scripts/* | ||
!/Assets/Resources/*.shader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) | ||
|
||
// Simplified Diffuse shader. Differences from regular Diffuse one: | ||
// - no Main Color | ||
// - fully supports only 1 directional light. Other lights can affect it, but it will be per-vertex/SH. | ||
|
||
Shader "Custom/GroundShader" { | ||
Properties { | ||
_MainTex ("Base (RGB)", 2D) = "white" {} | ||
} | ||
SubShader { | ||
Tags { "RenderType"="Opaque" } | ||
LOD 200 | ||
|
||
CGPROGRAM | ||
#pragma surface surf Lambert | ||
|
||
sampler2D _MainTex; | ||
|
||
struct Input { | ||
float2 uv_MainTex; | ||
}; | ||
|
||
void surf (Input IN, inout SurfaceOutput o) { | ||
fixed4 c = tex2D(_MainTex, IN.uv_MainTex); | ||
|
||
clip(c.a - 0.5f); | ||
|
||
o.Albedo = c.rgb; | ||
o.Alpha = c.a; | ||
} | ||
ENDCG | ||
} | ||
|
||
Fallback "Mobile/VertexLit" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) | ||
|
||
// Simplified Diffuse shader. Differences from regular Diffuse one: | ||
// - no Main Color | ||
// - fully supports only 1 directional light. Other lights can affect it, but it will be per-vertex/SH. | ||
|
||
Shader "Custom/ModelShader" { | ||
Properties{ | ||
_MainTex("Base (RGB)", 2D) = "white" {} | ||
} | ||
SubShader{ | ||
Tags{ "RenderType" = "Opaque" "Queue" = "Transparent" } | ||
LOD 200 | ||
|
||
|
||
CGPROGRAM | ||
#pragma surface surf Lambert | ||
|
||
sampler2D _MainTex; | ||
|
||
struct Input { | ||
float2 uv_MainTex; | ||
}; | ||
|
||
void surf(Input IN, inout SurfaceOutput o) { | ||
half4 c = tex2D(_MainTex, IN.uv_MainTex); | ||
|
||
clip(c.a - 0.5f); | ||
|
||
o.Albedo = c.rgb; | ||
o.Alpha = c.a; | ||
} | ||
ENDCG | ||
} | ||
|
||
Fallback "Mobile/VertexLit" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) | ||
|
||
// Simplified Diffuse shader. Differences from regular Diffuse one: | ||
// - no Main Color | ||
// - fully supports only 1 directional light. Other lights can affect it, but it will be per-vertex/SH. | ||
|
||
Shader "Custom/ModelShader2Sided" { | ||
Properties{ | ||
_MainTex("Base (RGB)", 2D) = "white" {} | ||
} | ||
SubShader{ | ||
Tags{ "Queue" = "Transparent" "RenderType" = "TransparentCutout" "IgnoreProjector" = "True" } | ||
LOD 200 | ||
Cull Off | ||
|
||
CGPROGRAM | ||
#pragma surface surf Lambert | ||
|
||
sampler2D _MainTex; | ||
|
||
struct Input { | ||
float2 uv_MainTex; | ||
}; | ||
|
||
void surf(Input IN, inout SurfaceOutput o) { | ||
half4 c = tex2D(_MainTex, IN.uv_MainTex); | ||
|
||
clip(c.a - 0.5f); | ||
|
||
o.Albedo = c.rgb; | ||
o.Alpha = c.a; | ||
} | ||
ENDCG | ||
} | ||
|
||
Fallback "Mobile/VertexLit" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
Shader "Custom/WaterShader" | ||
{ | ||
Properties | ||
{ | ||
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {} | ||
_WaterOffset("Water Offset", Float) = 0 | ||
_WaveAmplitude("Wave Amplitude", Float) = 0.19 | ||
_WaveSpeed("Wave Speed", Float) = 0.016 | ||
_WaveLenght("Wave Lenght", Float) = 0.5 | ||
_Color("Tint", Color) = (1,1,1,1) | ||
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0 | ||
} | ||
|
||
SubShader | ||
{ | ||
Tags | ||
{ | ||
"Queue" = "Transparent" | ||
"IgnoreProjector" = "True" | ||
"RenderType" = "Transparent" | ||
"PreviewType" = "Plane" | ||
"CanUseSpriteAtlas" = "True" | ||
} | ||
|
||
Cull Back | ||
Lighting Off | ||
ZWrite Off | ||
Blend One OneMinusSrcAlpha | ||
|
||
Pass | ||
{ | ||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
#pragma multi_compile _ PIXELSNAP_ON | ||
#include "UnityCG.cginc" | ||
|
||
struct appdata_t | ||
{ | ||
float4 vertex : POSITION; | ||
float4 color : COLOR; | ||
float2 texcoord : TEXCOORD0; | ||
}; | ||
|
||
struct v2f | ||
{ | ||
float4 vertex : SV_POSITION; | ||
fixed4 color : COLOR; | ||
float2 texcoord : TEXCOORD0; | ||
}; | ||
|
||
fixed4 _Color; | ||
float _WaterOffset; | ||
float _WaveAmplitude; | ||
float _WaveSpeed; | ||
float _WaveLenght; | ||
|
||
v2f vert(appdata_t IN) | ||
{ | ||
IN.vertex.y += _WaveAmplitude * sin(IN.vertex.x * _WaveLenght + _WaterOffset * _WaveSpeed); | ||
|
||
v2f OUT; | ||
OUT.vertex = UnityObjectToClipPos(IN.vertex); | ||
|
||
OUT.texcoord = IN.texcoord; | ||
OUT.color = IN.color * _Color; | ||
#ifdef PIXELSNAP_ON | ||
OUT.vertex = UnityPixelSnap(OUT.vertex); | ||
#endif | ||
|
||
return OUT; | ||
} | ||
|
||
sampler2D _MainTex; | ||
sampler2D _AlphaTex; | ||
float _AlphaSplitEnabled; | ||
|
||
fixed4 SampleSpriteTexture(float2 uv) | ||
{ | ||
fixed4 color = tex2D(_MainTex, uv); | ||
|
||
#if UNITY_TEXTURE_ALPHASPLIT_ALLOWED | ||
if (_AlphaSplitEnabled) | ||
color.a = tex2D(_AlphaTex, uv).r; | ||
#endif //UNITY_TEXTURE_ALPHASPLIT_ALLOWED | ||
|
||
return color; | ||
} | ||
|
||
fixed4 frag(v2f IN) : SV_Target | ||
{ | ||
fixed4 c = SampleSpriteTexture(IN.texcoord) * IN.color; | ||
c.rgb *= c.a; | ||
return c; | ||
} | ||
ENDCG | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections; | ||
using System.IO; | ||
using System.Text; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class Core : MonoBehaviour { | ||
private const string defaultcfg = "map=prontera\n"; | ||
private MapRenderer mapRenderer = new MapRenderer(); | ||
public string mapName; | ||
public Dropdown mapDropdown; | ||
private Hashtable configs = new Hashtable(); | ||
private static string CFG_NAME = "config.txt"; | ||
|
||
void Start() { | ||
string cfgTxt = FileManager.Load("config.txt") as string; | ||
if(cfgTxt == null) { | ||
FileStream stream = File.Open(Application.dataPath + "/" + CFG_NAME, FileMode.Create); | ||
stream.Write(Encoding.UTF8.GetBytes(defaultcfg), 0, defaultcfg.Length); | ||
stream.Close(); | ||
cfgTxt = defaultcfg; | ||
} | ||
|
||
foreach(string s in cfgTxt.Split('\n')) { | ||
string[] properties = s.Split('='); | ||
if(properties.Length == 2) { | ||
configs.Add(properties[0], properties[1]); | ||
} | ||
} | ||
|
||
if(string.IsNullOrEmpty(mapName)) { | ||
mapName = configs["map"] as string; | ||
} | ||
|
||
string grfPath; | ||
if(configs.Contains("grf")) { | ||
grfPath = configs["grf"] as string; | ||
} else { | ||
grfPath = Application.dataPath + "/data.grf"; | ||
} | ||
|
||
Grf grf = Grf.grf_callback_open(grfPath, "r", null); | ||
FileManager.setGrf(grf); | ||
|
||
MapSelector selector = new MapSelector(grf, mapRenderer); | ||
selector.buildDropdown(mapDropdown); | ||
} | ||
|
||
void Update() { | ||
mapDropdown.gameObject.SetActive(Cursor.lockState != CursorLockMode.Locked); | ||
} | ||
|
||
public void OnPostRender() { | ||
mapRenderer.Render(); | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class FPSDisplay : MonoBehaviour | ||
{ | ||
float deltaTime = 0.0f; | ||
|
||
void Update() { | ||
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f; | ||
} | ||
|
||
void OnGUI() { | ||
int w = Screen.width, h = Screen.height; | ||
|
||
GUIStyle style = new GUIStyle(); | ||
|
||
Rect rect = new Rect(0, 0, w, h * 2 / 100); | ||
style.alignment = TextAnchor.UpperLeft; | ||
style.fontSize = h * 2 / 100; | ||
style.normal.textColor = new Color(0.0f, 0.0f, 0.5f, 1.0f); | ||
float msec = deltaTime * 1000.0f; | ||
float fps = 1.0f / deltaTime; | ||
string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps); | ||
GUI.Label(rect, text, style); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.