Finish Merge

This commit is contained in:
Denis-Cosmin Nutiu 2019-06-09 19:13:50 +03:00
commit 62bee02357
21 changed files with 943 additions and 216 deletions

3
.gitignore vendored
View file

@ -140,6 +140,9 @@ fabric.properties
# Uncomment this line if you wish to ignore the asset store tools plugin
# [Aa]ssets/AssetStoreTools*
# Ignore Rider Plugin
[Aa]ssets/Plugins/Editor/JetBrains/*
# TextMesh Pro files
[Aa]ssets/TextMesh*Pro/

View file

@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 4177940729222266820}
- component: {fileID: 4177940729222266823}
- component: {fileID: 4177940729222266822}
- component: {fileID: 2823577682722293689}
m_Layer: 8
m_Name: bman_destructible_wall
m_TagString: Untagged
@ -128,3 +129,15 @@ BoxCollider2D:
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0
--- !u!114 &2823577682722293689
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4177940729222266681}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b30e7124fcdf4e1f92fc7dd42d8c7298, type: 3}
m_Name:
m_EditorClassIdentifier:

View file

@ -1,33 +0,0 @@
fileFormatVersion: 2
guid: 74a491a3f49a745eab0ec1f9e031b533
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,167 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &6843575828445418657
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6843575828445418654}
- component: {fileID: 6843575828445418655}
- component: {fileID: 6843575828445418656}
- component: {fileID: 6843575828445418653}
- component: {fileID: 6843575828445418652}
- component: {fileID: 6843575828445418651}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6843575828445418654
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6843575828445418657}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 7.2106156}
m_LocalScale: {x: 1, y: 1, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &6843575828445418655
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6843575828445418657}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
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: 0
m_SortingLayer: 0
m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.16, y: 0.16}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &6843575828445418656
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6843575828445418657}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3cc05deb3d6e44128ad7bc8610cedac, type: 3}
m_Name:
m_EditorClassIdentifier:
movementSpeed: 4
respawnPosition: {fileID: 0}
bombPrefab: {fileID: 5909392949477884267, guid: 28467e0d65b5d3844bf1862ac0c49ad9,
type: 3}
--- !u!50 &6843575828445418653
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6843575828445418657}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 0
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!61 &6843575828445418652
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6843575828445418657}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.5144317, y: 0.50000024}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 1, y: 1}
newSize: {x: 0.16, y: 0.16}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 0.913409, y: 0.88454485}
m_EdgeRadius: 0
--- !u!95 &6843575828445418651
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6843575828445418657}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: dc9347e7518ed4709b6cacd42554e650, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d3055091a17dc4aa1accf2e33ccef144
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -126,7 +126,7 @@ GameObject:
- component: {fileID: 69346944}
- component: {fileID: 69346946}
- component: {fileID: 69346945}
m_Layer: 8
m_Layer: 0
m_Name: Tilemap
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -8018,7 +8018,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 266944714}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.51, y: 0.06, z: -2.7893844}
m_LocalPosition: {x: 0, y: 0, z: -2.7893844}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 97386695}
@ -8156,7 +8156,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519420028}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 7.777341, y: -4.0430503, z: -2.7893844}
m_LocalPosition: {x: 10.581639, y: -4.0430503, z: -2.7893844}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
@ -8215,9 +8215,10 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 840487112}
- component: {fileID: 840487113}
- component: {fileID: 840487111}
m_Layer: 0
m_Name: LevelManager
m_Name: GameManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -8235,14 +8236,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 308dfc6b26c3b422faf1717231fc888b, type: 3}
m_Name:
m_EditorClassIdentifier:
columns: 30
rows: 20
boardHolder: {fileID: 585332173}
startPosition: {fileID: 185746015}
indestructibleWallPrefab: {fileID: 5959564480851182330, guid: dd25aabed7c6c491eb405f1e5c5f4d99,
type: 3}
destructibleWallPrefab: {fileID: 4177940729222266681, guid: da559e681f8d34d58bb5f3457045664a,
type: 3}
boardHolder: {fileID: 585332173}
--- !u!4 &840487112
Transform:
m_ObjectHideFlags: 0
@ -8257,6 +8256,18 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &840487113
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 840487110}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 697f5ae5656c74dcd8d7f5d619adb0ac, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1135949884
GameObject:
m_ObjectHideFlags: 0
@ -8321,149 +8332,83 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1352658974
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1352658977}
- component: {fileID: 1352658976}
- component: {fileID: 1352658975}
- component: {fileID: 1352658978}
- component: {fileID: 1352658979}
m_Layer: 0
m_Name: MockPlayer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1352658975
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1352658974}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3cc05deb3d6e44128ad7bc8610cedac, type: 3}
m_Name:
m_EditorClassIdentifier:
movementSpeed: 4
respawnPosition: {fileID: 185746015}
bombPrefab: {fileID: 5909392949477884267, guid: 28467e0d65b5d3844bf1862ac0c49ad9,
type: 3}
tilemap: {fileID: 69346943}
--- !u!212 &1352658976
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1352658974}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
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: 0
m_SortingLayer: 0
m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: 753e29d30d8044605aede9853c9308c7, type: 3}
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.16, y: 0.16}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &1352658977
--- !u!4 &1352658977 stripped
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
m_PrefabInstance: {fileID: 6843575829779162303}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1352658974}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.51, y: 0.06, z: 7.2106156}
m_LocalScale: {x: 1, y: 1, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &1352658978
Rigidbody2D:
serializedVersion: 4
--- !u!1001 &6843575829779162303
PrefabInstance:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1352658974}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 0
m_Material: {fileID: 0}
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!61 &1352658979
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1352658974}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.5144317, y: 0.50000024}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 1, y: 1}
newSize: {x: 0.16, y: 0.16}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 0.913409, y: 0.88454485}
m_EdgeRadius: 0
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 6843575828445418657, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_LocalPosition.z
value: 7.2106156
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418654, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6843575828445418656, guid: d3055091a17dc4aa1accf2e33ccef144,
type: 3}
propertyPath: respawnPosition
value:
objectReference: {fileID: 185746015}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d3055091a17dc4aa1accf2e33ccef144, type: 3}

View file

@ -1,4 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace src.Helpers
@ -19,5 +20,13 @@ namespace src.Helpers
list[i] = aux;
}
}
public static T PopRandom<T>(this IList<T> list)
{
var randomIndex = Mathf.FloorToInt(Random.Range(0, list.Count - 1));
var elem = list[randomIndex];
list.RemoveAt(randomIndex);
return elem;
}
}
}

View file

@ -0,0 +1,34 @@
using UnityEngine;
namespace src.Managers
{
public class GameManager : MonoBehaviour
{
public static GameManager Instance = null;
private LevelManager _levelManager;
public void Awake()
{
if (Instance == null)
{
Instance = this;
}
else if (Instance != null)
{
Destroy(gameObject);
}
/* Don't destroy when reloading the scene */
DontDestroyOnLoad(gameObject);
_levelManager = GetComponent<LevelManager>();
InitGame();
}
private void InitGame()
{
_levelManager.InitLevel();
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 697f5ae5656c74dcd8d7f5d619adb0ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using src.Base;
using src.Helpers;
using src.Wall;
using UnityEngine;
using Random = UnityEngine.Random;
@ -11,64 +12,117 @@ namespace src.Managers
{
public class Count
{
public readonly int Min;
public readonly int Max;
private readonly int _min;
private readonly int _max;
public Count(int min, int max)
{
Min = min;
Max = max;
_min = min;
_max = max;
}
public int RandomIntRange()
{
return Mathf.FloorToInt(Random.Range(_min, _max));
}
}
public int columns = 30;
public int rows = 20;
public Count DestructibleWallCount
{
get => _destructibleWallCount;
set => _destructibleWallCount = value;
}
/* Specifies how many objects we want per level. */
public Count destructibleWallCount = new Count(150, 350);
public Count enemyCount = new Count(20, 50);
public Count UpgradesCount
{
get => _upgradesCount;
set => _upgradesCount = value;
}
public Count EnemyCount
{
get => _enemyCount;
set => _enemyCount = value;
}
/* Used to group spawned objects */
public Transform boardHolder;
/* Holds the starting position of the player */
public Transform startPosition;
public GameObject indestructibleWallPrefab;
public GameObject destructibleWallPrefab;
/* Used to group spawned objects */
public Transform boardHolder;
/* Specifies how many objects we want per level. */
private Count _destructibleWallCount = new Count(150, 350);
private Count _upgradesCount = new Count(0, 5);
private Count _enemyCount = new Count(20, 50);
/* The size of the board. */
private const int Columns = 30;
private const int Rows = 20;
/* Holds the available positions */
private readonly List<Vector3> _gridPositions = new List<Vector3>();
private readonly List<Vector3> _freeGridPositions = new List<Vector3>();
private readonly List<GameObject> _destructibleWalls = new List<GameObject>();
/* Test only */
public void Awake()
private void SetupUpgrades()
{
InitBoard();
SetupLevel();
var count = _upgradesCount.RandomIntRange();
for (var i = 0; i < count; i++)
{
if (_destructibleWalls.Count == 0)
{
Debug.LogWarning("No destructible walls left, cannot spawn upgrade.");
continue;
}
/* Get the destructible wall script and make it to spawn the upgrade */
var wall = _destructibleWalls.PopRandom().GetComponent<DestructibleWall>();
Debug.Log($"Spawned upgrade at: x:{wall.XCoordinate} y:{wall.YCoordinate}");
wall.SpawnsUpgrade();
}
}
public void InitBoard()
private void SetupExit()
{
_gridPositions.Clear();
/* We want to iterate over the X axis taking into consideration the startPosition's offset */
for (var x = startPosition.position.x; x < columns; x++)
if (_destructibleWalls.Count == 0)
{
for (var y = startPosition.position.y; y > rows * -1; y--)
Debug.LogWarning("No destructible walls found, cannot spawn exit!");
return;
}
/* Get the destructible wall script and make it to spawn the exit */
var wall = _destructibleWalls.PopRandom().GetComponent<DestructibleWall>();
Debug.Log($"Spawned exit at: x:{wall.XCoordinate} y:{wall.YCoordinate}");
wall.SpawnsExit();
}
/* Place the indestructible tiles on the board and saves the
* unused positions in a list. */
private void InitBoard()
{
_freeGridPositions.Clear();
/* We want to iterate over the X axis taking into consideration the startPosition's offset */
for (var x = startPosition.position.x; x < Columns; x++)
{
for (var y = startPosition.position.y; y > Rows * -1; y--)
{
/* We want the following positions to be a safe zone. */
/* Don't place anything on starting position */
if (Mathf.FloorToInt(x) == 0 && Mathf.FloorToInt(y) == 0)
if (Mathf.RoundToInt(x) == 0 && Mathf.RoundToInt(y) == 0)
{
continue;
}
/* Don't place anything on X=1 and Y=0 */
if (Mathf.FloorToInt(x) == 1 && Mathf.FloorToInt(y) == 0)
if (Mathf.RoundToInt(x) == 1 && Mathf.RoundToInt(y) == 0)
{
continue;
}
/* Don't place anything on X=0 and Y=1 */
if (Mathf.FloorToInt(x) == 0 && Mathf.FloorToInt(y) == 1)
if (Mathf.RoundToInt(x) == 0 && Mathf.RoundToInt(y) == -1)
{
continue;
}
@ -80,24 +134,24 @@ namespace src.Managers
}
/* Add position to _gridPositions */
_gridPositions.Add(new Vector3(x, y, 0f));
_freeGridPositions.Add(new Vector3(x, y, 0f));
}
}
}
public void SetupLevel()
/* Randomly places destructible tiles on the level. */
private void SetupLevelDestructibleWalls()
{
var random = new Random();
var numberOfDestructilbeWallsToPlace =
Mathf.FloorToInt(Random.Range(destructibleWallCount.Min, destructibleWallCount.Max));
var numberOfDestructilbeWallsToPlace = _destructibleWallCount.RandomIntRange();
_gridPositions.ShuffleList();
foreach (var nextPosition in _gridPositions)
_freeGridPositions.ShuffleList();
foreach (var nextPosition in _freeGridPositions)
{
if (numberOfDestructilbeWallsToPlace == 0)
{
break;
}
PlaceDestructibleTile(nextPosition);
numberOfDestructilbeWallsToPlace -= 1;
}
@ -105,14 +159,17 @@ namespace src.Managers
private void PlaceDestructibleTile(Vector3 position)
{
Debug.Log($"PlaceDestructibleTile: x:{position.x} y:{position.y}");
var instance = Instantiate(destructibleWallPrefab, position, Quaternion.identity);
_destructibleWalls.Add(instance);
instance.transform.SetParent(boardHolder);
}
private bool PlaceIndestructibleTile(float x, float y)
{
var absX = Mathf.FloorToInt(x);
var absY = Mathf.FloorToInt(y);
Debug.Log($"PlaceIndestructibleTile: x:{x} y:{y}");
var absX = Mathf.RoundToInt(x);
var absY = Mathf.RoundToInt(y);
if (absX % 2 == 0 || absY % 2 == 0) return false;
@ -121,5 +178,14 @@ namespace src.Managers
instance.transform.SetParent(boardHolder);
return true;
}
/* Initializes the level. */
public void InitLevel()
{
InitBoard();
SetupLevelDestructibleWalls();
SetupExit();
SetupUpgrades();
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5a3a413dae6e40f2967fc143c723dce6
timeCreated: 1559667182

View file

@ -0,0 +1,36 @@
using src.Base;
namespace src.Wall
{
public class DestructibleWall : GameplayComponent
{
private bool _spawnExit;
private bool _spawnUpgrade;
public void SpawnsExit()
{
_spawnExit = true;
}
public void SpawnsUpgrade()
{
_spawnUpgrade = true;
}
public float XCoordinate => transform.position.x;
public float YCoordinate => transform.position.y;
public void OnDestroy()
{
if (_spawnExit)
{
// TODO Spawn an exit
}
else if (_spawnUpgrade)
{
// TODO Spawn an upgrade, use composition to UpgradeManager
// to get random / desired upgrade
}
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b30e7124fcdf4e1f92fc7dd42d8c7298
timeCreated: 1559667193

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8cf9aa37a78d94c9a9b27e0aa3d65b3e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,72 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: PlayerAnimator
serializedVersion: 5
m_AnimatorParameters: []
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 1107510709762736314}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1102 &1102275762780126800
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: PlayerRunning
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: 2cdaef357e9274d569d0b48634ff44c2, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &1107510709762736314
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 1102275762780126800}
m_Position: {x: 200, y: 0, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 1102275762780126800}

View file

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

View file

@ -0,0 +1,89 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: PlayerRunning
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: 21300000, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- time: 0.083333336
value: {fileID: 21300002, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- time: 0.16666667
value: {fileID: 21300004, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- time: 0.25
value: {fileID: 21300006, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- time: 0.33333334
value: {fileID: 21300008, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- time: 0.41666666
value: {fileID: 21300010, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- time: 0.5
value: {fileID: 21300012, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- time: 0.5833333
value: {fileID: 21300014, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
attribute: m_Sprite
path:
classID: 212
script: {fileID: 0}
m_SampleRate: 12
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 0
script: {fileID: 0}
typeID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: 21300000, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- {fileID: 21300002, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- {fileID: 21300004, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- {fileID: 21300006, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- {fileID: 21300008, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- {fileID: 21300010, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- {fileID: 21300012, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
- {fileID: 21300014, guid: 69237087e6b0b42ac8d25d0035b2e01b, type: 3}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.6666666
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -0,0 +1,278 @@
fileFormatVersion: 2
guid: 69237087e6b0b42ac8d25d0035b2e01b
TextureImporter:
fileIDToRecycleName:
21300000: player_run_0
21300002: player_run_1
21300004: player_run_2
21300006: player_run_3
21300008: player_run_4
21300010: player_run_5
21300012: player_run_6
21300014: player_run_7
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 2
spriteExtrude: 1
spriteMeshType: 1
alignment: 6
spritePivot: {x: 0, y: 0}
spritePixelsToUnits: 128
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: player_run_0
rect:
serializedVersion: 2
x: 0
y: 0
width: 128
height: 128
alignment: 6
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 1e36cd93f9c0a42c98fcc35c8e4ae7f5
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: player_run_1
rect:
serializedVersion: 2
x: 128
y: 0
width: 128
height: 128
alignment: 6
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 9c891826c5f474cb49d6edbeb7e80f18
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: player_run_2
rect:
serializedVersion: 2
x: 256
y: 0
width: 128
height: 128
alignment: 6
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 9939665c63d7042618d86775a884554e
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: player_run_3
rect:
serializedVersion: 2
x: 384
y: 0
width: 128
height: 128
alignment: 6
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 32a7c47449ffa4ac985893c3ae600b39
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: player_run_4
rect:
serializedVersion: 2
x: 512
y: 0
width: 128
height: 128
alignment: 6
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: a96b5e3187255408585e0328a87ff229
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: player_run_5
rect:
serializedVersion: 2
x: 640
y: 0
width: 128
height: 128
alignment: 6
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 6d13da6564137493987537f6b25259c0
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: player_run_6
rect:
serializedVersion: 2
x: 768
y: 0
width: 128
height: 128
alignment: 6
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: 5ad0822b46e8f4f578e5ae02017a8753
vertices: []
indices:
edges: []
weights: []
- serializedVersion: 2
name: player_run_7
rect:
serializedVersion: 2
x: 896
y: 0
width: 128
height: 128
alignment: 6
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []
tessellationDetail: 0
bones: []
spriteID: dde402ecf23ba476ca550e1b2662cd77
vertices: []
indices:
edges: []
weights: []
outline: []
physicsShape: []
bones: []
spriteID: cba2d783860c64c119fac4cf57dd911c
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant: