86 lines
1.6 KiB
C#
86 lines
1.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Script.Map;
|
|
using UnityEngine;
|
|
|
|
public class Grid : MonoBehaviour
|
|
{
|
|
public int x { get; private set; }
|
|
public int y { get; private set; }
|
|
public bool Open { get; private set; }
|
|
public Grid East { get; private set; }
|
|
public Grid South { get; private set; }
|
|
public Grid West { get; private set; }
|
|
public Grid North { get; private set; }
|
|
|
|
public void SetData(int _x,int _y)
|
|
{
|
|
x = _x;
|
|
y = _y;
|
|
}
|
|
|
|
public void SetBool(bool bo)
|
|
{
|
|
Open = bo;
|
|
}
|
|
|
|
public void SetRestPostion()
|
|
{
|
|
transform.localPosition = new Vector3(x*100, y * -100,0);
|
|
}
|
|
|
|
|
|
public void SetAdjacentGrid()
|
|
{
|
|
if (x - 1>=0)
|
|
{
|
|
MapManager.ins.MapGrid[x - 1,y].SetEast(this);
|
|
}
|
|
if (y - 1>=0)
|
|
{
|
|
MapManager.ins.MapGrid[x,y - 1].SetSouth(this);
|
|
}
|
|
if (y + 1<MapManager.ins.y)
|
|
{
|
|
MapManager.ins.MapGrid[x,y + 1].SetNorth(this);
|
|
}
|
|
if (x + 1<MapManager.ins.x)
|
|
{
|
|
MapManager.ins.MapGrid[x + 1,y].SetWest(this);
|
|
}
|
|
}
|
|
|
|
public void SetEast(Grid grid)
|
|
{
|
|
East = grid;
|
|
}
|
|
public void SetSouth(Grid grid)
|
|
{
|
|
South = grid;
|
|
}
|
|
public void SetWest(Grid grid)
|
|
{
|
|
West = grid;
|
|
}
|
|
public void SetNorth(Grid grid)
|
|
{
|
|
North = grid;
|
|
}
|
|
public void ResetPosition()
|
|
{
|
|
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|