Fix bomb placement
This commit is contained in:
parent
500294de4a
commit
17e905c98f
14 changed files with 17 additions and 25 deletions
|
@ -161,7 +161,7 @@ BoxCollider2D:
|
||||||
m_IsTrigger: 1
|
m_IsTrigger: 1
|
||||||
m_UsedByEffector: 0
|
m_UsedByEffector: 0
|
||||||
m_UsedByComposite: 0
|
m_UsedByComposite: 0
|
||||||
m_Offset: {x: 0.009168625, y: 0.045985222}
|
m_Offset: {x: 0.5, y: 0.5}
|
||||||
m_SpriteTilingProperty:
|
m_SpriteTilingProperty:
|
||||||
border: {x: 0, y: 0, z: 0, w: 0}
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
pivot: {x: 0, y: 0}
|
pivot: {x: 0, y: 0}
|
||||||
|
@ -172,5 +172,5 @@ BoxCollider2D:
|
||||||
adaptiveTiling: 0
|
adaptiveTiling: 0
|
||||||
m_AutoTiling: 0
|
m_AutoTiling: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Size: {x: 1.1100235, y: 0.90802956}
|
m_Size: {x: 1, y: 1}
|
||||||
m_EdgeRadius: 0
|
m_EdgeRadius: 0
|
|
@ -137,8 +137,8 @@ TextureImporter:
|
||||||
y: 253
|
y: 253
|
||||||
width: 128
|
width: 128
|
||||||
height: 131
|
height: 131
|
||||||
alignment: 9
|
alignment: 6
|
||||||
pivot: {x: -0.005050569, y: 0.49665892}
|
pivot: {x: 0, y: 0}
|
||||||
border: {x: 0, y: 0, z: 0, w: 0}
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
outline: []
|
outline: []
|
||||||
physicsShape: []
|
physicsShape: []
|
||||||
|
|
|
@ -43,7 +43,7 @@ TextureImporter:
|
||||||
spriteMode: 1
|
spriteMode: 1
|
||||||
spriteExtrude: 1
|
spriteExtrude: 1
|
||||||
spriteMeshType: 1
|
spriteMeshType: 1
|
||||||
alignment: 4
|
alignment: 6
|
||||||
spritePivot: {x: 0.5, y: 0.5}
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
spritePixelsToUnits: 32
|
spritePixelsToUnits: 32
|
||||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
|
|
@ -492,7 +492,7 @@ GameObject:
|
||||||
- component: {fileID: 1057764287}
|
- component: {fileID: 1057764287}
|
||||||
- component: {fileID: 1057764286}
|
- component: {fileID: 1057764286}
|
||||||
- component: {fileID: 1057764285}
|
- component: {fileID: 1057764285}
|
||||||
m_Layer: 0
|
m_Layer: 8
|
||||||
m_Name: Tilemap
|
m_Name: Tilemap
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
|
|
|
@ -141,7 +141,7 @@ Transform:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 69346940}
|
m_GameObject: {fileID: 69346940}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0.5, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 585332173}
|
m_Father: {fileID: 585332173}
|
||||||
|
|
|
@ -6,7 +6,7 @@ public class BombController : MonoBehaviour, IExplosable
|
||||||
{
|
{
|
||||||
public GameObject explosionPrefab;
|
public GameObject explosionPrefab;
|
||||||
|
|
||||||
BombStatsUtil bombStatsUtil = BombStatsUtil.Instance;
|
BombStatsManager bombStatsUtil = BombStatsManager.Instance;
|
||||||
bool exploded = false;
|
bool exploded = false;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
|
@ -29,10 +29,6 @@ public class BombController : MonoBehaviour, IExplosable
|
||||||
|
|
||||||
exploded = true;
|
exploded = true;
|
||||||
Destroy(gameObject, 0.3f);
|
Destroy(gameObject, 0.3f);
|
||||||
//GameObject bombObject = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
|
|
||||||
//bombObject.GetComponent<Explosion>().Explode(transform.position);
|
|
||||||
|
|
||||||
Destroy(gameObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator CreateExplosions(Vector3 direction)
|
private IEnumerator CreateExplosions(Vector3 direction)
|
||||||
|
@ -46,7 +42,6 @@ public class BombController : MonoBehaviour, IExplosable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Log("Collided with something");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ using UnityEngine;
|
||||||
|
|
||||||
public class Explosion : MonoBehaviour
|
public class Explosion : MonoBehaviour
|
||||||
{
|
{
|
||||||
BombStatsUtil bombUtil = BombStatsUtil.Instance;
|
BombStatsManager bombUtil = BombStatsManager.Instance;
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace src.Base
|
||||||
|
|
||||||
public void onExplosion()
|
public void onExplosion()
|
||||||
{
|
{
|
||||||
Debug.Log("Player hit by explosion");
|
// Debug.Log("Player hit by explosion");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public sealed class BombStatsUtil
|
public sealed class BombStatsManager
|
||||||
{
|
{
|
||||||
|
|
||||||
private static readonly BombStatsUtil instance = new BombStatsUtil();
|
private static readonly BombStatsManager instance = new BombStatsManager();
|
||||||
const int MAX_POWER = 7;
|
const int MAX_POWER = 7;
|
||||||
|
|
||||||
public int Power { get; private set; } = 3;
|
public int Power { get; private set; } = 3;
|
||||||
|
@ -13,11 +13,11 @@ public sealed class BombStatsUtil
|
||||||
|
|
||||||
public float ExplosionDuration { get; } = 0.55f;
|
public float ExplosionDuration { get; } = 0.55f;
|
||||||
|
|
||||||
private BombStatsUtil()
|
private BombStatsManager()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BombStatsUtil Instance
|
public static BombStatsManager Instance
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
|
@ -11,8 +11,6 @@ namespace src.Player
|
||||||
|
|
||||||
public GameObject bombPrefab;
|
public GameObject bombPrefab;
|
||||||
|
|
||||||
public Tilemap tilemap;
|
|
||||||
|
|
||||||
protected new void Start()
|
protected new void Start()
|
||||||
{
|
{
|
||||||
base.Start();
|
base.Start();
|
||||||
|
@ -59,10 +57,9 @@ namespace src.Player
|
||||||
|
|
||||||
private void PlaceBomb()
|
private void PlaceBomb()
|
||||||
{
|
{
|
||||||
Vector3Int cell = tilemap.WorldToCell(transform.position);
|
var absX = Mathf.RoundToInt(transform.position.x);
|
||||||
Vector3 cellCenterPos = tilemap.GetCellCenterWorld(cell);
|
var absY = Mathf.RoundToInt(transform.position.y);
|
||||||
|
Instantiate(bombPrefab, new Vector3(absX, absY, 0), Quaternion.identity);
|
||||||
Instantiate(bombPrefab, cellCenterPos, Quaternion.identity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleBomb()
|
private void HandleBomb()
|
||||||
|
|
Loading…
Reference in a new issue