mirror of
https://github.com/DerTyp7/grow-ai-unity.git
synced 2025-10-29 20:42:08 +01:00
added Gridinfo
This commit is contained in:
17
Assets/GridInfo.cs
Normal file
17
Assets/GridInfo.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class GridInfo : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static GridInfo instance;
|
||||||
|
|
||||||
|
public int gridWidth = 20;
|
||||||
|
public int gridHeight = 20;
|
||||||
|
public float cellSize = 1f;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/GridInfo.cs.meta
Normal file
11
Assets/GridInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a9ff0826ad15d5c43859748285744c87
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -12,7 +12,11 @@ public class PathfindingSystem : MonoBehaviour
|
|||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
pathfinding = new Pathfinding(20, 10);
|
int gridWidth = GridInfo.instance.gridWidth;
|
||||||
|
int gridHeight = GridInfo.instance.gridHeight;
|
||||||
|
float cellSize = GridInfo.instance.cellSize;
|
||||||
|
|
||||||
|
pathfinding = new Pathfinding(gridWidth, gridHeight, cellSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
|
|||||||
@@ -313,6 +313,10 @@ PrefabInstance:
|
|||||||
propertyPath: city
|
propertyPath: city
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3391280458837659705, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
|
||||||
|
propertyPath: m_Enabled
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 3391280458837659708, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
|
- target: {fileID: 3391280458837659708, guid: 4b478a82c8aed4e4e9f09083bf6afa01, type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Person
|
value: Person
|
||||||
@@ -377,6 +381,7 @@ GameObject:
|
|||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1522634446}
|
- component: {fileID: 1522634446}
|
||||||
|
- component: {fileID: 1522634448}
|
||||||
- component: {fileID: 1522634445}
|
- component: {fileID: 1522634445}
|
||||||
- component: {fileID: 1522634447}
|
- component: {fileID: 1522634447}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
@@ -427,6 +432,21 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: db134add0ff65f04aa54ed5edf6d6df2, type: 3}
|
m_Script: {fileID: 11500000, guid: db134add0ff65f04aa54ed5edf6d6df2, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!114 &1522634448
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1522634444}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: a9ff0826ad15d5c43859748285744c87, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
gridWidth: 100
|
||||||
|
gridHeight: 100
|
||||||
|
cellSize: 1
|
||||||
--- !u!1001 &1762203019
|
--- !u!1001 &1762203019
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ public class GridBuildingSystem : MonoBehaviour
|
|||||||
if (instance == null)
|
if (instance == null)
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
int gridWidth = 20;
|
int gridWidth = GridInfo.instance.gridWidth;
|
||||||
int gridHeight = 20;
|
int gridHeight = GridInfo.instance.gridHeight;
|
||||||
float cellSize = 1f;
|
float cellSize = GridInfo.instance.cellSize;
|
||||||
|
|
||||||
buildingGrid = new Grid<GridObject>(gridWidth, gridHeight, cellSize, Vector3.zero, (Grid<GridObject> g, int x, int y) => new GridObject(g, x, y));
|
buildingGrid = new Grid<GridObject>(gridWidth, gridHeight, cellSize, Vector3.zero, (Grid<GridObject> g, int x, int y) => new GridObject(g, x, y));
|
||||||
placedObjectTypeSO = placedObjectTypeSOList[0];
|
placedObjectTypeSO = placedObjectTypeSOList[0];
|
||||||
|
|||||||
@@ -1,16 +1,4 @@
|
|||||||
/*
|
using System.Collections;
|
||||||
------------------- Code Monkey -------------------
|
|
||||||
|
|
||||||
Thank you for downloading this package
|
|
||||||
I hope you find it useful in your projects
|
|
||||||
If you have any questions let me know
|
|
||||||
Cheers!
|
|
||||||
|
|
||||||
unitycodemonkey.com
|
|
||||||
--------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ public class Pathfinding {
|
|||||||
private List<PathNode> openList;
|
private List<PathNode> openList;
|
||||||
private List<PathNode> closedList;
|
private List<PathNode> closedList;
|
||||||
|
|
||||||
public Pathfinding(int width, int height) {
|
public Pathfinding(int width, int height, float cellSize) {
|
||||||
Instance = this;
|
Instance = this;
|
||||||
grid = new Grid<PathNode>(width, height, 1f, Vector3.zero, (Grid<PathNode> g, int x, int y) => new PathNode(g, x, y));
|
grid = new Grid<PathNode>(width, height, cellSize, Vector3.zero, (Grid<PathNode> g, int x, int y) => new PathNode(g, x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Grid<PathNode> GetGrid() {
|
public Grid<PathNode> GetGrid() {
|
||||||
|
|||||||
Reference in New Issue
Block a user