Commit 078c1d2a authored by 18신대성's avatar 18신대성

일반벽과 거울을 Wall 클래스에 종속시킴

parent daf752cb
......@@ -3,29 +3,8 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class Mirror : MonoBehaviour, IBulletInteractor, IBreakable
public class Mirror : Wall, IBulletInteractor, IBreakable
{
public Vector2 mapPos;
// data about this mirror
public Vector2Int ldPos // left down pos
{
get { return new Vector2Int((int)mapPos.x, (int)mapPos.y); }
}
public Vector2Int rdPos // right down pos
{
get { return ldPos + (dir ? new Vector2Int(1, 0) : new Vector2Int(0, 1)); }
}
public bool dir // false: ver, true: hor
{
get { return (int)(transform.rotation.eulerAngles.y / 90) % 2 != 1; }
}
private int len = 1; // length of mirror
public void SetmapPos(Vector2 pos)
{
mapPos = pos;
}
public void Break()
{
Destroy(gameObject);
......
......@@ -2,7 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
public class NormalWall : MonoBehaviour, IBulletInteractor
public class NormalWall : Wall, IBulletInteractor
{
public void Interact(Bullet bullet)
{
......@@ -12,7 +12,11 @@ public class NormalWall : MonoBehaviour, IBulletInteractor
}
else if (bullet is MirrorBullet)
{
gameObject.AddComponent<Mirror>();
Mirror mirror = gameObject.AddComponent<Mirror>();
GetComponent<Renderer>().material = GameManager.inst.mirrorMaterial;
mirror.SetmapPos(mapPos);
mirror.len = len;
mirror.type = WallType.Mirror;
Destroy(this);
}
}
......
......@@ -5,6 +5,7 @@ using System.Linq;
public class GameManager : SingletonBehaviour<GameManager>
{
public Material mirrorMaterial;
/*
private List<IPlayerInteractor> playerInteractors;
......
......@@ -2,6 +2,13 @@
using System.Collections.Generic;
using UnityEngine;
public enum WallType
{
NULL,
Normal,
Mirror
}
public class Wall : MonoBehaviour
{
/// <summary>
......@@ -14,13 +21,14 @@ public class Wall : MonoBehaviour
}
public Vector2Int rdPos // right down pos
{
get { return ldPos + (dir ? new Vector2Int(1, 0) : new Vector2Int(0, 1)); }
get { return ldPos + (dir ? new Vector2Int(len, 0) : new Vector2Int(0, len)); }
}
public bool dir // false: ver, true: hor
{
get { return (int)(transform.rotation.eulerAngles.y / 90) % 2 != 1; }
}
public int len = 1; // length of wall
public WallType type;
public void SetmapPos(Vector2 pos)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment