Skip to content

Commit

Permalink
feat(#18): add
Browse files Browse the repository at this point in the history
fix: place y fix
  • Loading branch information
dofranko committed Oct 25, 2021
1 parent d4e663a commit 705200c
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 15 deletions.
162 changes: 153 additions & 9 deletions Assets/Prefabs/Enemies/EnemyGameObject.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Transform:
m_Children:
- {fileID: 6170981000574225558}
- {fileID: 5274769450461133627}
- {fileID: 6097348025347003261}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -1053,8 +1054,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0.5400009, y: 10.38}
m_SizeDelta: {x: 3.9, y: -15.81}
m_AnchoredPosition: {x: 0.7099991, y: 9.35}
m_SizeDelta: {x: 3.52, y: -17.58}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5124086887600245640
CanvasRenderer:
Expand Down Expand Up @@ -1111,7 +1112,7 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 8.2
m_fontSize: 6.6
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 1
Expand Down Expand Up @@ -1153,6 +1154,149 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &7714129654557270098
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6097348025347003261}
- component: {fileID: 7097201706496311847}
- component: {fileID: 2776700637826632495}
m_Layer: 0
m_Name: RedLine
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6097348025347003261
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7714129654557270098}
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: 2006164517018326468}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!120 &7097201706496311847
LineRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7714129654557270098}
m_Enabled: 0
m_CastShadows: 0
m_ReceiveShadows: 1
m_DynamicOccludee: 0
m_MotionVectors: 0
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 77758b357c29c5c4ba7fbe70b2998c6c, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Positions:
- {x: 0, y: 0, z: 0}
- {x: 0, y: 0, z: 1}
m_Parameters:
serializedVersion: 3
widthMultiplier: 0.004
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
colorGradient:
serializedVersion: 2
key0: {r: 1, g: 0, b: 0, a: 1}
key1: {r: 1, g: 0, b: 0, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0}
key5: {r: 0, g: 0, b: 0, a: 0}
key6: {r: 0, g: 0, b: 0, a: 0}
key7: {r: 0, g: 0, b: 0, a: 0}
ctime0: 0
ctime1: 65535
ctime2: 0
ctime3: 0
ctime4: 0
ctime5: 0
ctime6: 0
ctime7: 0
atime0: 0
atime1: 65535
atime2: 0
atime3: 0
atime4: 0
atime5: 0
atime6: 0
atime7: 0
m_Mode: 0
m_NumColorKeys: 2
m_NumAlphaKeys: 2
numCornerVertices: 0
numCapVertices: 0
alignment: 0
textureMode: 0
shadowBias: 0.5
generateLightingData: 0
m_UseWorldSpace: 1
m_Loop: 0
--- !u!114 &2776700637826632495
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7714129654557270098}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 997a4c1e8613fbf49bb14582687f869f, type: 3}
m_Name:
m_EditorClassIdentifier:
line: {fileID: 7097201706496311847}
--- !u!1001 &724457982463847356
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1353,18 +1497,18 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 764498c4341ab0d44bcbe375d944411d, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &309300469641127697 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1028810355262229677, guid: 6631e3849a660b34abff2f1123b42d35, type: 3}
--- !u!223 &309300469641127694 stripped
Canvas:
m_CorrespondingSourceObject: {fileID: 1028810355262229682, guid: 6631e3849a660b34abff2f1123b42d35, type: 3}
m_PrefabInstance: {fileID: 724457982463847356}
m_PrefabAsset: {fileID: 0}
--- !u!224 &309300469641127698 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1028810355262229678, guid: 6631e3849a660b34abff2f1123b42d35, type: 3}
m_PrefabInstance: {fileID: 724457982463847356}
m_PrefabAsset: {fileID: 0}
--- !u!223 &309300469641127694 stripped
Canvas:
m_CorrespondingSourceObject: {fileID: 1028810355262229682, guid: 6631e3849a660b34abff2f1123b42d35, type: 3}
--- !u!1 &309300469641127697 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1028810355262229677, guid: 6631e3849a660b34abff2f1123b42d35, type: 3}
m_PrefabInstance: {fileID: 724457982463847356}
m_PrefabAsset: {fileID: 0}
6 changes: 4 additions & 2 deletions Assets/Scripts/EnemySpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ private IEnumerator SpawnEnemiesEnumerator()
if (state == State.DuringWave)
yield return new WaitForSeconds(0.0f);
yield return new WaitForSeconds(3.0f);
var castleLocation = Castle?.transform.position ?? new Vector3();
var castleLocation = Castle?.transform.position + new Vector3(0, 0.5f, 0) ?? new Vector3();
for (int i = 0; i < Random.Range(waveNumber + (int)(waveNumber * 1.6), waveNumber + 1 + (int)(waveNumber * 1.8)); i++)
{
Vector3 newLocation = new Vector3(
castleLocation.x - Random.Range(4.0f, 5.0f) * (Random.Range(0, 2) * 2 - 1),
castleLocation.y + 0.5f,
castleLocation.y + 0.3f,
castleLocation.z - Random.Range(4.0f, 5.0f) * (Random.Range(0, 2) * 2 - 1));
var enemy = Instantiate(enemyPrefab, newLocation, Quaternion.LookRotation(castleLocation - newLocation));
//enemy.transform.LookAt(castleLocation);
Expand Down Expand Up @@ -118,6 +118,8 @@ private void OnCastleSpawnEventHandler(object? sender, System.EventArgs e)
{
if (state != State.InBetweenWaves) //TODO zrobić z tym porządek
CloseShopsAndStartWave();
(sender as Placement).OnCastleSpawn -= OnCastleSpawnEventHandler;

}

private IEnumerator CheckInBetweenWaves(Enemy.EnemyDieEventArgs e)
Expand Down
7 changes: 4 additions & 3 deletions Assets/Scripts/Placement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Placement : MonoBehaviour
public GameObject castleToPlace;
public GameObject placementIndicatorPrefab;
//public GameObject crosshairImage;

public float CastleFloorPositionY { get; private set; } = Mathf.Infinity;
public event System.EventHandler OnCastleSpawn;

private GameObject placementIndicator;
Expand Down Expand Up @@ -50,11 +50,12 @@ void Update()
var mesh = meshFilter.sharedMesh;
Vector3 bottom = new Vector3();
if (mesh)
bottom = new Vector3(0, Mathf.Abs(mesh.vertices.Min(v => v.y)) * meshFilter.transform.localScale.y, 0);
bottom = new Vector3(0, Mathf.Abs(mesh.vertices.Min(v => v.y)) / meshFilter.transform.localScale.y, 0);

Instantiate(castleToPlace, placementPose.position + bottom, placementPose.rotation);
OnCastleSpawn?.Invoke(this, System.EventArgs.Empty); //TODO zamienic na onobjectspawn

if (CastleFloorPositionY == Mathf.Infinity)
CastleFloorPositionY = placementPose.position.y;
placementIndicator.SetActive(false);

///TODO add to game engine (handler or sth)s
Expand Down
21 changes: 21 additions & 0 deletions Assets/Scripts/RedLiner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RedLiner : MonoBehaviour
{
[SerializeField] private LineRenderer line;
private float castleY;

void Start()
{
var placement = FindObjectOfType<Placement>();
castleY = placement.CastleFloorPositionY;
line.enabled = true;
}
void Update()
{
line.SetPosition(0, new Vector3(transform.parent.position.x, transform.parent.position.y, transform.parent.position.z));
line.SetPosition(1, new Vector3(transform.parent.position.x, castleY, transform.parent.position.z));
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/RedLiner.cs.meta

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

4 changes: 3 additions & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ PlayerSettings:
16:9: 1
Others: 1
bundleVersion: 0.2
preloadedAssets: []
preloadedAssets:
- {fileID: -1550076359260888824, guid: cac9f30cc9590f849be2928c3af9f1ae, type: 2}
- {fileID: 4800000, guid: c9f956787b1d945e7b36e0516201fc76, type: 3}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1
Expand Down

0 comments on commit 705200c

Please sign in to comment.