1
0
Fork 0

Random Ground Texturen Fix

This commit is contained in:
Triceraptodactyl 2018-04-23 15:54:31 +02:00
parent 85a6981a98
commit 2e41921358
7 changed files with 33 additions and 103 deletions

View file

@ -1,87 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1487413182883822}
m_IsPrefabParent: 1
--- !u!1 &1487413182883822
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4167595944037000}
- component: {fileID: 212910617741009226}
m_Layer: 0
m_Name: ground
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4167595944037000
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1487413182883822}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &212910617741009226
SpriteRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1487413182883822}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 1778783263
m_SortingLayer: -2
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 79d2e82f1d7398f41aa2dd6501e9d21c, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: bc8a58beb0459094483211a5c7933959
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1245,7 +1245,10 @@ MonoBehaviour:
type: 2} type: 2}
BorderSingle: {fileID: 1277252496101342, guid: ed9537580662f6046a1514a4c5bfdd98, BorderSingle: {fileID: 1277252496101342, guid: ed9537580662f6046a1514a4c5bfdd98,
type: 2} type: 2}
Ground: {fileID: 1487413182883822, guid: bc8a58beb0459094483211a5c7933959, type: 2} Ground0: {fileID: 1487413182883822, guid: bc8a58beb0459094483211a5c7933959, type: 2}
Ground1: {fileID: 1772182943815902, guid: d5ac6ff96b8389a4f89e000bb512df0c, type: 2}
Ground2: {fileID: 1292387089709784, guid: ea403377dca91e246a37fc2101f23c5d, type: 2}
Ground3: {fileID: 1395236729573066, guid: 2b27ba92cf33a624ea670c46a3e569b0, type: 2}
DoorInner: {fileID: 1065161683117842, guid: 06aa81f4fbf9a3a4a8f9fdadafcbf7fa, type: 2} DoorInner: {fileID: 1065161683117842, guid: 06aa81f4fbf9a3a4a8f9fdadafcbf7fa, type: 2}
DoorOuter: {fileID: 1575370008060226, guid: 70bf9bb227285e74383db2dc84cc6c50, type: 2} DoorOuter: {fileID: 1575370008060226, guid: 70bf9bb227285e74383db2dc84cc6c50, type: 2}
Rock: {fileID: 1373919933116942, guid: 5f26192f79d542e49ad24fadc39f5654, type: 2} Rock: {fileID: 1373919933116942, guid: 5f26192f79d542e49ad24fadc39f5654, type: 2}

View file

@ -22,7 +22,13 @@ public class GameController : MonoBehaviour {
[SerializeField] [SerializeField]
GameObject BorderSingle; GameObject BorderSingle;
[SerializeField] [SerializeField]
GameObject Ground; GameObject Ground0;
[SerializeField]
GameObject Ground1;
[SerializeField]
GameObject Ground2;
[SerializeField]
GameObject Ground3;
[SerializeField] [SerializeField]
GameObject DoorInner; GameObject DoorInner;
[SerializeField] [SerializeField]
@ -111,7 +117,10 @@ public class GameController : MonoBehaviour {
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLUR, RockLUR); genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLUR, RockLUR);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockURD, RockURD); genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockURD, RockURD);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLRD, RockLRD); genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLRD, RockLRD);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground, Ground); genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground0, Ground0);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground1, Ground1);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground2, Ground2);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground3, Ground3);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.DoorInner, DoorInner); genPrefabs.Add(GenerationProcessor.ExtendedTileType.DoorInner, DoorInner);
genPrefabs.Add(GenerationProcessor.ExtendedTileType.DoorOuter, DoorOuter); genPrefabs.Add(GenerationProcessor.ExtendedTileType.DoorOuter, DoorOuter);
} }

View file

@ -4,7 +4,7 @@ using UnityEngine;
public class GenerationProcessor { public class GenerationProcessor {
public enum ExtendedTileType { public enum ExtendedTileType {
BorderOuter, BorderInner, BorderSingle, Ground, DoorInner, DoorOuter, Rock, RockL, RockU, RockR, RockD, RockLU, RockLR, RockLD, RockUR, RockUD, RockRD, RockLURD, RockLUD, RockLUR, RockURD, RockLRD BorderOuter, BorderInner, BorderSingle, Ground0, Ground1, Ground2, Ground3, DoorInner, DoorOuter, Rock, RockL, RockU, RockR, RockD, RockLU, RockLR, RockLD, RockUR, RockUD, RockRD, RockLURD, RockLUD, RockLUR, RockURD, RockLRD
} }
Dictionary<ExtendedTileType, GameObject> prefabs; Dictionary<ExtendedTileType, GameObject> prefabs;
public GenerationProcessor(Dictionary<ExtendedTileType, GameObject> prefabs) { public GenerationProcessor(Dictionary<ExtendedTileType, GameObject> prefabs) {
@ -16,7 +16,7 @@ public class GenerationProcessor {
name = "Room" name = "Room"
}; };
foreach ( Vector2Int v in tiles.Keys ) { foreach ( Vector2Int v in tiles.Keys ) {
ExtendedTileType type = ExtendedTileType.Ground; ExtendedTileType type = GetRandomGroundType();
int rotation = 0; int rotation = 0;
switch ( tiles[v].type ) { switch ( tiles[v].type ) {
case Room.TileType.WALL: case Room.TileType.WALL:
@ -24,7 +24,7 @@ public class GenerationProcessor {
rotation = GetCorrectWallRotation(type, tiles[v].position); rotation = GetCorrectWallRotation(type, tiles[v].position);
break; break;
case Room.TileType.GROUND: case Room.TileType.GROUND:
type = ExtendedTileType.Ground; type = GetRandomGroundType();
break; break;
case Room.TileType.DOOR: case Room.TileType.DOOR:
type = GetCorrectDoorType(tiles, v); type = GetCorrectDoorType(tiles, v);
@ -42,7 +42,7 @@ public class GenerationProcessor {
private GameObject CreateGOFromType(Vector2 v, int rotation, Room.TileType type, ExtendedTileType t, GameObject root) { private GameObject CreateGOFromType(Vector2 v, int rotation, Room.TileType type, ExtendedTileType t, GameObject root) {
GameObject tmp = null; GameObject tmp = null;
if (type != Room.TileType.GROUND) if (type != Room.TileType.GROUND)
CreateGOFromType(v, 0, Room.TileType.GROUND, ExtendedTileType.Ground, root); CreateGOFromType(v, 0, Room.TileType.GROUND, GetRandomGroundType(), root);
if ( prefabs.ContainsKey(t) && root != null ) { if ( prefabs.ContainsKey(t) && root != null ) {
tmp = Object.Instantiate(prefabs[t], root.transform); tmp = Object.Instantiate(prefabs[t], root.transform);
tmp.transform.position = v; tmp.transform.position = v;
@ -194,7 +194,6 @@ public class GenerationProcessor {
return 90; return 90;
toCheck = position + new Vector2Int(1, 0); toCheck = position + new Vector2Int(1, 0);
return 0; return 0;
break;
case ExtendedTileType.DoorInner: case ExtendedTileType.DoorInner:
Vector2Int toCheckD = position + new Vector2Int(0, -1); Vector2Int toCheckD = position + new Vector2Int(0, -1);
if(tiles.ContainsKey(toCheckD) && tiles[toCheckD].type == Room.TileType.DOOR) if(tiles.ContainsKey(toCheckD) && tiles[toCheckD].type == Room.TileType.DOOR)
@ -203,4 +202,18 @@ public class GenerationProcessor {
} }
return 0; return 0;
} }
private ExtendedTileType GetRandomGroundType() {
int num = (int) (UnityEngine.Random.value * 4);
switch(num) {
case 0:
return ExtendedTileType.Ground0;
case 1:
return ExtendedTileType.Ground1;
case 2:
return ExtendedTileType.Ground2;
default:
return ExtendedTileType.Ground3;
}
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB