Fix bomb placement

This commit is contained in:
Andrei Gavra 2019-06-09 16:55:19 +03:00
parent 500294de4a
commit 17e905c98f
14 changed files with 17 additions and 25 deletions

View file

@ -161,7 +161,7 @@ BoxCollider2D:
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0.009168625, y: 0.045985222}
m_Offset: {x: 0.5, y: 0.5}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
@ -172,5 +172,5 @@ BoxCollider2D:
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1.1100235, y: 0.90802956}
m_Size: {x: 1, y: 1}
m_EdgeRadius: 0

View file

@ -137,8 +137,8 @@ TextureImporter:
y: 253
width: 128
height: 131
alignment: 9
pivot: {x: -0.005050569, y: 0.49665892}
alignment: 6
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
outline: []
physicsShape: []

View file

@ -43,7 +43,7 @@ TextureImporter:
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 4
alignment: 6
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 32
spriteBorder: {x: 0, y: 0, z: 0, w: 0}

View file

@ -492,7 +492,7 @@ GameObject:
- component: {fileID: 1057764287}
- component: {fileID: 1057764286}
- component: {fileID: 1057764285}
m_Layer: 0
m_Layer: 8
m_Name: Tilemap
m_TagString: Untagged
m_Icon: {fileID: 0}

View file

@ -141,7 +141,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 69346940}
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_Children: []
m_Father: {fileID: 585332173}

View file

@ -6,7 +6,7 @@ public class BombController : MonoBehaviour, IExplosable
{
public GameObject explosionPrefab;
BombStatsUtil bombStatsUtil = BombStatsUtil.Instance;
BombStatsManager bombStatsUtil = BombStatsManager.Instance;
bool exploded = false;
// Start is called before the first frame update
@ -29,10 +29,6 @@ public class BombController : MonoBehaviour, IExplosable
exploded = true;
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)
@ -46,7 +42,6 @@ public class BombController : MonoBehaviour, IExplosable
}
else
{
Debug.Log("Collided with something");
break;
}

View file

@ -4,7 +4,7 @@ using UnityEngine;
public class Explosion : MonoBehaviour
{
BombStatsUtil bombUtil = BombStatsUtil.Instance;
BombStatsManager bombUtil = BombStatsManager.Instance;
public void Start()
{

View file

@ -25,7 +25,7 @@ namespace src.Base
public void onExplosion()
{
Debug.Log("Player hit by explosion");
// Debug.Log("Player hit by explosion");
}
}
}

View file

@ -1,10 +1,10 @@
using System.Collections;
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;
public int Power { get; private set; } = 3;
@ -13,11 +13,11 @@ public sealed class BombStatsUtil
public float ExplosionDuration { get; } = 0.55f;
private BombStatsUtil()
private BombStatsManager()
{
}
public static BombStatsUtil Instance
public static BombStatsManager Instance
{
get
{

View file

@ -11,8 +11,6 @@ namespace src.Player
public GameObject bombPrefab;
public Tilemap tilemap;
protected new void Start()
{
base.Start();
@ -59,10 +57,9 @@ namespace src.Player
private void PlaceBomb()
{
Vector3Int cell = tilemap.WorldToCell(transform.position);
Vector3 cellCenterPos = tilemap.GetCellCenterWorld(cell);
Instantiate(bombPrefab, cellCenterPos, Quaternion.identity);
var absX = Mathf.RoundToInt(transform.position.x);
var absY = Mathf.RoundToInt(transform.position.y);
Instantiate(bombPrefab, new Vector3(absX, absY, 0), Quaternion.identity);
}
private void HandleBomb()