Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GameController : MonoBehaviour {
- public Entity player;
- public Transform grid;
- float testTimer = 5f;
- void Start() {
- MoveEntity(player, 1, 1);
- }
- void Update() {
- testTimer -= Time.deltaTime;
- if(testTimer<0){
- MoveEntity(player, 5, 5);
- }
- }
- Transform GetSpace(int x, int y) {
- return grid.GetChild(y - 1).GetChild(x - 1);
- }
- void MoveEntity(Entity entity, int x, int y) {
- entity.locationX = x;
- entity.locationY = y;
- entity.transform.SetParent(GetSpace(x, y));
- }
- public void ReceiveTileInput(GameObject tile) {
- int[] location = GetTileLocation(tile.transform);
- MoveEntity(player, location[0], location[1]);
- }
- int[] GetTileLocation(Transform tileTransform) {
- return new int[] {tileTransform.parent.GetSiblingIndex() + 1, tileTransform.parent.parent.GetSiblingIndex() + 1};
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement