public void buildAll() { if (tileData == null) { Debug.Log("[失敗]請先設定LodeRunnerGraphBuilder的tileData"); return; } if (graphMap == null) { Debug.Log("[失敗]請先設定LodeRunnerGraphBuilder的graphMap"); return; } if (width == 0 || height == 0) { Vector2 size = new Vector2(tileData.getWidth(), tileData.getHeight()); resetSize(size); } buildArrowMap(); buildJumpToMap(); buildGraph(); UserMoveController player = setPlayerContext(); setAIContext(player); Debug.Log("buildAll() finish"); }
void setAIContext(UserMoveController player) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { GameObject obj = tileCreator.getObj(x, y); if (obj != null) { Movable movable = obj.GetComponentInChildren <Movable>(); if (movable != null) { movable.graphBuilder = this; } AIMoveController ai = obj.GetComponentInChildren <AIMoveController>(); if (ai != null) { ai.player = player; ai.graphMap = graphMap; } } } } }
void OnTriggerExit2D(Collider2D other) { Debug.Log("exit trap"); if (catchAI != null) { catchAI = null; } catchPlayer = null; }
void OnTriggerEnter2D(Collider2D other) { Debug.Log("enter trap"); catchPlayer = other.gameObject.GetComponent <UserMoveController>(); catchAI = other.gameObject.GetComponent <AIMoveController>(); if (catchAI != null) { catchAI.getSM().handleMessage(new StateMsg <AIMoveController>((int)AIMsg.catchByTrap, null)); } }
void OnTriggerEnter2D(Collider2D other) { Debug.Log("enter trap"); catchPlayer = other.gameObject.GetComponent<UserMoveController>(); catchAI = other.gameObject.GetComponent<AIMoveController>(); if (catchAI != null) { catchAI.getSM().handleMessage(new StateMsg((int)AIMsg.catchByTrap)); } }
UserMoveController setPlayerContext() { UserMoveController player = null; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { GameObject obj = tileCreator.getObj(x, y); if (obj != null) { player = obj.GetComponentInChildren <UserMoveController>(); if (player != null) { player.graphBuilder = this; player.tileCreator = tileCreator; return(player); } } } } return(player); }
void setAIContext(UserMoveController player) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { GameObject obj = tileCreator.getObj(x, y); if (obj != null) { Movable movable = obj.GetComponentInChildren<Movable>(); if (movable != null) movable.graphBuilder = this; AIMoveController ai = obj.GetComponentInChildren<AIMoveController>(); if (ai != null) { ai.player = player; ai.graphMap = graphMap; } } } } }