repair camera calibrating + finish adding configs

This commit is contained in:
Felix Boucher 2023-09-24 10:48:37 -04:00
parent ef6b345a03
commit f9a54513cd
5 changed files with 10 additions and 54 deletions

View File

@ -572,7 +572,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 519420028} m_GameObject: {fileID: 519420028}
m_Enabled: 0 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e1e75c8792eeaf44a8afc3d3fa678c74, type: 3} m_Script: {fileID: 11500000, guid: e1e75c8792eeaf44a8afc3d3fa678c74, type: 3}
m_Name: m_Name:

View File

@ -1,39 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GlobalOffset : MonoBehaviour
{
private Vector2 oldOffset;
[field:SerializeField]
public Vector2 Offset { get; set; }
void Start()
{
oldOffset = Offset;
}
private void OffsetChanged()
{
foreach (var obj in gameObject.scene.GetRootGameObjects())
{
Translate(obj.transform);
}
}
void Translate(Transform transform)
{
foreach(Transform t in transform) {
}
}
// Update is called once per frame
void Update()
{
if (oldOffset != Offset)
{
OffsetChanged();
oldOffset = Offset;
}
}
}

View File

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

View File

@ -6,17 +6,22 @@ public class KeepLevelAnchored : MonoBehaviour
{ {
Camera _camera; Camera _camera;
Rect _levelBound; Rect _levelBound;
bool _boundCalculated = false;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
LevelManager.Instance.LevelLoaded += CalculateBound;
CalculateBound(LevelManager.Instance.CurrentLevel);
_camera = Camera.main; _camera = Camera.main;
LevelManager.Instance.LevelLoaded += CalculateBound;
if (!LevelManager.Instance.CurrentLevel) return;
CalculateBound(LevelManager.Instance.CurrentLevel);
} }
private void CalculateBound(GatherAndDefend.LevelEditor.Level level) private void CalculateBound(GatherAndDefend.LevelEditor.Level level)
{ {
_boundCalculated = false;
_levelBound = level.CalculateBounds(); _levelBound = level.CalculateBounds();
_boundCalculated = true;
} }
void OnDestroy() void OnDestroy()
@ -27,6 +32,7 @@ public class KeepLevelAnchored : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if (!_boundCalculated) return;
//move right //move right
var xMax = _levelBound.xMax; var xMax = _levelBound.xMax;
var width = _camera.ScreenToWorldPoint(Vector2.one * _camera.pixelWidth).x; var width = _camera.ScreenToWorldPoint(Vector2.one * _camera.pixelWidth).x;

View File

@ -47,7 +47,7 @@ namespace GatherAndDefend.LevelEditor
// if the function we receive is null, we just make it constant 1 // if the function we receive is null, we just make it constant 1
if (tileSpawnAcceleration == default) tileSpawnAcceleration = () => 1; if (tileSpawnAcceleration == default) tileSpawnAcceleration = () => 1;
const int tilesPerSecond = 15; var tilesPerSecond = GlobalConfig.Instance.Current.baseTileSpawnSpeed;
reference.transform.localPosition = _position; reference.transform.localPosition = _position;
reference.transform.localScale = _scale; reference.transform.localScale = _scale;