Upload Game

This commit is contained in:
Michał Gdula 2023-03-14 14:43:42 +00:00
parent b3f494d5c2
commit 18b63ffa9b
150 changed files with 85782 additions and 0 deletions

View file

@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Custom_Grid : MonoBehaviour
{
private int width;
private int height;
private int cellsize;
private Vector3 originPosition;
private int[,] gridArray;
public Custom_Grid(int width, int height, int cellsize, Vector3 originPosition)
{
this.width = width;
this.height = height;
this.cellsize = cellsize;
this.originPosition = originPosition;
gridArray = new int[width, height];
for(int x = 0; x < gridArray.GetLength(0); x++)
{
for(int z = 0; z < gridArray.GetLength(1); z++)
{
// Debug.DrawLine(GetWorldPosition(x, z), GetWorldPosition(x + 1, z), Color.black, 1000f);
// Debug.DrawLine(GetWorldPosition(x, z), GetWorldPosition(x, z + 1), Color.black, 1000f);
}
}
}
public int GetCellSize()
{
return cellsize;
}
public Vector3 GetWorldPosition(int x, int z)
{
return new Vector3(x, 0, z) * cellsize + originPosition;
}
public int[] GetXZ(Vector3 worldPosition)
{
int x = Mathf.FloorToInt((worldPosition - originPosition).x / cellsize);
int z = Mathf.FloorToInt((worldPosition - originPosition).z / cellsize);
return new int[] { x, z };
}
}