script
This commit is contained in:
@@ -1,52 +1,131 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class movement : MonoBehaviour
|
||||
{
|
||||
public Collider2D oneone_Collider;
|
||||
private static int w = 3; //ennyi oszlop van a mapon
|
||||
private static int h = 4; //ennyi sor van a mapon
|
||||
|
||||
|
||||
public GameObject[,] helyszinek = new GameObject[h, w];
|
||||
public Collider2D[,] colliders = new Collider2D[h, w];
|
||||
|
||||
|
||||
public Camera THE_Camera;
|
||||
|
||||
public GameObject oneone;
|
||||
public Collider2D oneone_Collider;
|
||||
|
||||
public GameObject twoone;
|
||||
public Collider2D twoone_Collider;
|
||||
|
||||
public GameObject threeone;
|
||||
public Collider2D threeone_Collider;
|
||||
|
||||
public GameObject onetwo;
|
||||
public Collider2D onetwo_Collider;
|
||||
|
||||
public GameObject twotwo;
|
||||
public Collider2D twotwo_Collider;
|
||||
|
||||
public GameObject threetwo;
|
||||
public Collider2D threetwo_Collider;
|
||||
|
||||
public GameObject onethree;
|
||||
public Collider2D onethree_Collider;
|
||||
|
||||
public GameObject twothree;
|
||||
public Collider2D twothree_Collider;
|
||||
|
||||
public GameObject threethree;
|
||||
public Collider2D threethree_Collider;
|
||||
|
||||
public GameObject onefour;
|
||||
public Collider2D onefour_Collider;
|
||||
|
||||
public GameObject twofour;
|
||||
public Collider2D twofour_Collider;
|
||||
|
||||
public GameObject threefour;
|
||||
public Collider2D threefour_Collider;
|
||||
|
||||
public GameObject player;
|
||||
|
||||
string[,] arr2d = new string[4, 3]
|
||||
|
||||
private int jelenlegi_x = 1;
|
||||
private int jelenlegi_y = 1;
|
||||
private int akciopont = 6;
|
||||
private int tavolsag = 0;
|
||||
|
||||
private string[,] helyek = new string[4, 3]//kell e meg?
|
||||
{
|
||||
{"oneone", "twoone", "threeone" },
|
||||
{"onetwo", "twotwo", "threetwo" },
|
||||
{"onethree", "twothree", "threethree" },
|
||||
{"onefour", "twofour", "threefour" }
|
||||
};
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
private void Awake() {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
public void FixedUpdate()
|
||||
{
|
||||
//new WaitForSeconds(2);
|
||||
//player.transform.position = oneone.transform.position;
|
||||
|
||||
// player mozgat<61>sa es konzolra iratas
|
||||
//ha kattint nezze meg a tombbon hogy overlappol valamelyik colliderrel
|
||||
if (Input.GetKeyDown(KeyCode.Mouse0) && oneone_Collider.OverlapPoint(THE_Camera.ScreenToWorldPoint(Input.mousePosition)))
|
||||
{
|
||||
Debug.Log("Player clicked on the collider: " + oneone_Collider.gameObject.name);
|
||||
for (int x = 0; x < w; x++)
|
||||
{
|
||||
for (int y = 0; y < h; y++)
|
||||
{
|
||||
if (helyek[x,y].Equals("oneone"))
|
||||
{
|
||||
Debug.Log("Player clicked on the collider: " + oneone_Collider.gameObject.name);
|
||||
tavolsag = x + y - jelenlegi_x + jelenlegi_y;
|
||||
if (tavolsag < 1)
|
||||
{
|
||||
tavolsag = -tavolsag;
|
||||
if (tavolsag == 1 && akciopont != 0)
|
||||
{
|
||||
player.transform.position = oneone.transform.position;
|
||||
jelenlegi_x = 1;
|
||||
jelenlegi_y = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Nincs eleg akciopontod vagy nem 1 mezon belul akarsz lepni");
|
||||
}
|
||||
}
|
||||
}
|
||||
//break; ??
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
///////////////////////////
|
||||
///
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Mouse0)) {
|
||||
for (int i = 0; i < colliders.GetLength(0); i++) {
|
||||
for (int j = 0; j < colliders.GetLength(1); j++) {
|
||||
if (colliders[i, j].OverlapPoint(THE_Camera.ScreenToWorldPoint(Input.mousePosition))){
|
||||
Debug.Log("Player clicked on the collider: " + colliders[i,j].gameObject.name);
|
||||
tavolsag = i + j - jelenlegi_x + jelenlegi_y;
|
||||
if (tavolsag < 1) {
|
||||
tavolsag = -tavolsag;
|
||||
if (tavolsag == 1 && akciopont != 0) {
|
||||
player.transform.position = oneone.transform.position;
|
||||
jelenlegi_x = 1;
|
||||
jelenlegi_y = 1;
|
||||
} else {
|
||||
Debug.Log("Nincs eleg akciopontod vagy nem 1 mezon belul akarsz lepni");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ MonoBehaviour:
|
||||
width: 1920
|
||||
height: 997
|
||||
m_ShowMode: 4
|
||||
m_Title: Hierarchy
|
||||
m_Title: Scene
|
||||
m_RootView: {fileID: 2}
|
||||
m_MinSize: {x: 875, y: 300}
|
||||
m_MaxSize: {x: 10000, y: 10000}
|
||||
@@ -119,7 +119,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 300, y: 200}
|
||||
m_MaxSize: {x: 24288, y: 16192}
|
||||
vertical: 0
|
||||
controlID: 61
|
||||
controlID: 59
|
||||
--- !u!114 &6
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@@ -144,7 +144,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 200, y: 200}
|
||||
m_MaxSize: {x: 16192, y: 16192}
|
||||
vertical: 1
|
||||
controlID: 90
|
||||
controlID: 60
|
||||
--- !u!114 &7
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@@ -169,7 +169,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 200, y: 100}
|
||||
m_MaxSize: {x: 16192, y: 8096}
|
||||
vertical: 0
|
||||
controlID: 91
|
||||
controlID: 61
|
||||
--- !u!114 &8
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@@ -206,7 +206,7 @@ MonoBehaviour:
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 1
|
||||
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_Name: GameView
|
||||
m_Name: SceneView
|
||||
m_EditorClassIdentifier:
|
||||
m_Children: []
|
||||
m_Position:
|
||||
@@ -217,12 +217,12 @@ MonoBehaviour:
|
||||
height: 603
|
||||
m_MinSize: {x: 202, y: 221}
|
||||
m_MaxSize: {x: 4002, y: 4021}
|
||||
m_ActualView: {fileID: 14}
|
||||
m_ActualView: {fileID: 16}
|
||||
m_Panes:
|
||||
- {fileID: 16}
|
||||
- {fileID: 14}
|
||||
m_Selected: 1
|
||||
m_LastSelected: 0
|
||||
m_Selected: 0
|
||||
m_LastSelected: 1
|
||||
--- !u!114 &10
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@@ -247,7 +247,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 200, y: 100}
|
||||
m_MaxSize: {x: 16192, y: 8096}
|
||||
vertical: 0
|
||||
controlID: 102
|
||||
controlID: 18
|
||||
--- !u!114 &11
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@@ -293,8 +293,8 @@ MonoBehaviour:
|
||||
y: 0
|
||||
width: 727
|
||||
height: 344
|
||||
m_MinSize: {x: 102, y: 121}
|
||||
m_MaxSize: {x: 4002, y: 4021}
|
||||
m_MinSize: {x: 100, y: 100}
|
||||
m_MaxSize: {x: 4000, y: 4000}
|
||||
m_ActualView: {fileID: 18}
|
||||
m_Panes:
|
||||
- {fileID: 18}
|
||||
@@ -449,9 +449,9 @@ MonoBehaviour:
|
||||
m_SceneHierarchy:
|
||||
m_TreeViewState:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs:
|
||||
m_SelectedIDs: 14200000
|
||||
m_LastClickedID: 0
|
||||
m_ExpandedIDs: 2afbffff
|
||||
m_ExpandedIDs: 22fbffff
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
@@ -889,9 +889,9 @@ MonoBehaviour:
|
||||
m_IsLocked: 0
|
||||
m_FolderTreeState:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs: a4650000
|
||||
m_LastClickedID: 26020
|
||||
m_ExpandedIDs: 000000009a650000
|
||||
m_SelectedIDs: aa650000
|
||||
m_LastClickedID: 26026
|
||||
m_ExpandedIDs: 00000000a0650000
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
@@ -919,7 +919,7 @@ MonoBehaviour:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs:
|
||||
m_LastClickedID: 0
|
||||
m_ExpandedIDs: 000000009a650000
|
||||
m_ExpandedIDs: 00000000a0650000
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
@@ -946,7 +946,7 @@ MonoBehaviour:
|
||||
m_ListAreaState:
|
||||
m_SelectedInstanceIDs:
|
||||
m_LastClickedInstanceID: 0
|
||||
m_HadKeyboardFocusLastEvent: 0
|
||||
m_HadKeyboardFocusLastEvent: 1
|
||||
m_ExpandedInstanceIDs: c623000000000000
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
|
||||
Reference in New Issue
Block a user