Skip to content

Commit

Permalink
WIP2 v0.603
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonexo3 committed Jul 8, 2018
1 parent 31de9df commit c78e8d6
Show file tree
Hide file tree
Showing 12 changed files with 359 additions and 57 deletions.
95 changes: 62 additions & 33 deletions Assets/MapEditor.unity
Original file line number Diff line number Diff line change
Expand Up @@ -39733,7 +39733,7 @@ Camera:
serializedVersion: 2
m_Bits: 2560
m_RenderingPath: 1
m_TargetTexture: {fileID: 1650333357}
m_TargetTexture: {fileID: 1384490039}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
Expand Down Expand Up @@ -50967,7 +50967,7 @@ MonoBehaviour:
TerrainMaterial: {fileID: 2100000, guid: 869424636fdf59642bae55582eca31d9, type: 2}
PropMaterial: {fileID: 2100000, guid: 7e0dcd483a119b0439d572104f720f3f, type: 2}
UnitMaterial: {fileID: 2100000, guid: 45d596c0e62a2ba44b276b336c2b1a8b, type: 2}
NoPropMesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
NoPropMesh: {fileID: 4300000, guid: cec6c7026bd5dab479ab7875f0fc87e0, type: 3}
NoPropMaterial: {fileID: 2100000, guid: 9c1501c902f369f46af3de859e898238, type: 2}
Invert: 0
LoadingProps: 0
Expand Down Expand Up @@ -84524,6 +84524,12 @@ MonoBehaviour:
type: 2}
m_PrefabInternal: {fileID: 1180596069}
m_Script: {fileID: -2061169968, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
--- !u!114 &1181951586 stripped
MonoBehaviour:
m_PrefabParentObject: {fileID: 114659475374214984, guid: b68527975f2edce489c9336fa9650c39,
type: 2}
m_PrefabInternal: {fileID: 1597750314}
m_Script: {fileID: 2109663825, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
--- !u!1001 &1182109234
Prefab:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -100627,6 +100633,37 @@ RectTransform:
m_PrefabParentObject: {fileID: 224077777350642360, guid: ac95df46b11bff845bd7247ddbab7227,
type: 2}
m_PrefabInternal: {fileID: 1382992340}
--- !u!84 &1384490039
RenderTexture:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_Width: 256
m_Height: 256
m_AntiAliasing: 1
m_DepthFormat: 1
m_ColorFormat: 0
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 0
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!1 &1385165962
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -103106,6 +103143,11 @@ MonoBehaviour:
BrushListObject: {fileID: 156696, guid: cde0d706d2cdd694f9743c77040d0663, type: 2}
BrushListPivot: {fileID: 796678062}
TerrainMaterial: {fileID: 2100000, guid: 869424636fdf59642bae55582eca31d9, type: 2}
BrushTypes:
- {fileID: 1181951586}
- {fileID: 2116804369}
- {fileID: 2140200930}
- {fileID: 1538567026}
TerrainMask:
serializedVersion: 2
m_Bits: 256
Expand Down Expand Up @@ -110494,6 +110536,12 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1537465954}
--- !u!114 &1538567026 stripped
MonoBehaviour:
m_PrefabParentObject: {fileID: 114659475374214984, guid: b68527975f2edce489c9336fa9650c39,
type: 2}
m_PrefabInternal: {fileID: 1085175420}
m_Script: {fileID: 2109663825, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
--- !u!1 &1539898745
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -119205,37 +119253,6 @@ MonoBehaviour:
m_FlexibleWidth: -1
m_FlexibleHeight: -1
m_LayoutPriority: 1
--- !u!84 &1650333357
RenderTexture:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_Width: 256
m_Height: 256
m_AntiAliasing: 1
m_DepthFormat: 1
m_ColorFormat: 0
m_MipMap: 0
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_BindMS: 0
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 0
m_MipBias: 0
m_WrapU: 1
m_WrapV: 1
m_WrapW: 1
m_Dimension: 2
m_VolumeDepth: 1
--- !u!1 &1652382937
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -148525,6 +148542,12 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2113941614}
--- !u!114 &2116804369 stripped
MonoBehaviour:
m_PrefabParentObject: {fileID: 114659475374214984, guid: b68527975f2edce489c9336fa9650c39,
type: 2}
m_PrefabInternal: {fileID: 679521753}
m_Script: {fileID: 2109663825, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
--- !u!1 &2117893653
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -150327,6 +150350,12 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2139803068}
--- !u!114 &2140200930 stripped
MonoBehaviour:
m_PrefabParentObject: {fileID: 114659475374214984, guid: b68527975f2edce489c9336fa9650c39,
type: 2}
m_PrefabInternal: {fileID: 145289807}
m_Script: {fileID: 2109663825, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
--- !u!1001 &2140658695
Prefab:
m_ObjectHideFlags: 0
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/Input.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions Assets/Scripts/Input/KeyboardManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using UnityEngine;

public class KeyboardManager {

//public static KeyCode BrushStrength = KeyCode.V;
//public static KeyCode BrushSize = KeyCode.B;

public static bool BrushStrengthDown(){
return Input.GetKeyDown(KeyCode.V) || Input.GetKeyDown(KeyCode.S);
}

public static bool BrushStrengthHold()
{
return Input.GetKey(KeyCode.V) || Input.GetKey(KeyCode.S);
}

public static bool BrushSizeDown()
{
return Input.GetKeyDown(KeyCode.B) || Input.GetKeyDown(KeyCode.W);
}

public static bool BrushSizeHold()
{
return Input.GetKey(KeyCode.B) || Input.GetKey(KeyCode.W);
}

public static bool SwitchTypeNext()
{
return Input.GetKeyDown(KeyCode.Tab);
}

public static bool SwitchType1()
{
return Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Keypad1);
}

public static bool SwitchType2()
{
return Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Keypad2);
}

public static bool SwitchType3()
{
return Input.GetKeyDown(KeyCode.Alpha3) || Input.GetKeyDown(KeyCode.Keypad3);
}

public static bool SwitchType4()
{
return Input.GetKeyDown(KeyCode.Alpha4) || Input.GetKeyDown(KeyCode.Keypad4);
}

const float ClickDownOffset = 0.5f;
const float ClickOffset = 0.1f;

static float LastClickTime = 0;
public static bool IncreaseTarget()
{
if(Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.Plus) || Input.GetKeyDown(KeyCode.Equals) || Input.GetKeyDown(KeyCode.KeypadPlus))
{
LastClickTime = Time.realtimeSinceStartup + ClickDownOffset;
return true;
}
else if(Input.GetKey(KeyCode.Q) || Input.GetKey(KeyCode.Plus) || Input.GetKey(KeyCode.Equals) || Input.GetKey(KeyCode.KeypadPlus))
{
if(Time.realtimeSinceStartup > LastClickTime)
{
LastClickTime = Time.realtimeSinceStartup + ClickOffset;
return true;
}
}
return false;
}

public static bool DecreaseTarget()
{
if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.Minus) || Input.GetKeyDown(KeyCode.KeypadMinus))
{
LastClickTime = Time.realtimeSinceStartup + ClickDownOffset;
return true;
}
else if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.Minus) || Input.GetKey(KeyCode.KeypadMinus))
{
if (Time.realtimeSinceStartup > LastClickTime)
{
LastClickTime = Time.realtimeSinceStartup + ClickOffset;
return true;
}
}
return false;
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Input/KeyboardManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class PropObject

public PropGameObject CreatePropGameObject(Vector3 position, Quaternion rotation, Vector3 scale, bool AllowFarLod = true)
{
//Reset scale, because it's not supported anyway
scale = Vector3.one;

PropGameObject NewProp = GameObject.Instantiate(PropsInfo.Current.PropObjectPrefab, PropsInfo.Current.PropsParent).GetComponent<PropGameObject>();
NewProp.gameObject.name = BP.Name;
Expand Down Expand Up @@ -217,7 +219,7 @@ public static PropObject LoadProp(string scd, string LocalPath)
}
catch (NLua.Exceptions.LuaException e)
{
Debug.LogError(LuaParser.Read.FormatException(e) + "\n" + LocalPath);
Debug.LogWarning(LuaParser.Read.FormatException(e) + "\n" + LocalPath);
return ToReturn;
}

Expand Down Expand Up @@ -365,13 +367,14 @@ public static PropObject LoadProp(string scd, string LocalPath)
}
if(ToReturn.BP.LODs.Length <= 0){
ToReturn.BP.LODs = new BluePrintLoD[1];
ToReturn.BP.LODs[0] = new BluePrintLoD();
ToReturn.BP.LODs[0].LODCutoff = 100;
}

if (ToReturn.BP.LODs[0].Mesh == null)
{
ToReturn.BP.LODs[0].Mesh = PropsInfo.Current.NoPropMesh;
ToReturn.BP.UniformScale = 0.5f;
ToReturn.BP.UniformScale = 2f;
}

if (ToReturn.BP.LODs[0].Mat == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class UnitBluePrint
public string Name = "";
public string HelpText = "";

public int TypeId;

// Display
public BluePrintLoD[] LODs = new BluePrintLoD[0];

Expand Down Expand Up @@ -105,6 +107,8 @@ public static UnitSource CreateEmptyUnit(string LocalPath, UnitSource ToReturn =
ToReturn.BP.CodeName = ToReturn.BP.Name.Replace("_unit", "");
}

ToReturn.BP.TypeId = 0;

ToReturn.BP.Size = Vector3.one;
ToReturn.BP.UniformScale = Vector3.one;
ToReturn.BP.RenderScale = Vector3.one;
Expand Down Expand Up @@ -156,6 +160,10 @@ public static UnitSource LoadUnit(string scd, string LocalPath)

ToReturn.BP.Name = PathSplit[PathSplit.Length - 1].Replace(".bp", "");
ToReturn.BP.CodeName = ToReturn.BP.Name.Replace("_unit", "");


ToReturn.BP.TypeId = ToReturn.BP.CodeName.GetHashCode();

//Debug.Log("Load Unit : " + ToReturn.BP.CodeName);

//Fix LUA
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Placement/PlacementManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void Update () {
UpdateSymmetryObjects();

// Action
if (Input.GetKey(KeyCode.E) || Input.GetKey(KeyCode.R) || Input.GetKey(KeyCode.B) || Input.GetKey(KeyCode.M))
if (Input.GetKey(KeyCode.E) || Input.GetKey(KeyCode.R) || KeyboardManager.BrushSizeHold() || KeyboardManager.BrushStrengthHold())
{
}
else if (Input.GetMouseButtonDown(0))
Expand Down
Loading

0 comments on commit c78e8d6

Please sign in to comment.