private void createInnerPoints(Transfer parent, WalkPath path, bool reversed) { IEnumerable <Point> points = path.InnerPoints; if (reversed) { points = points.Reverse(); } foreach (var point in points) { TransferPoint entity = new TransferPoint { Transfer = parent, DLat = (short)Math.Round((point.Latitude - parent.Origin.Latitude) * 10000.0), DLon = (short)Math.Round((point.Longitude - parent.Origin.Longitude) * 10000.0) }; sdb.AddEntity(entity); } }
void Update() { if (!paused) { if (canMove) { if (Input.GetAxisRaw("Horizontal") < 0 && transform.position == pos) // Left { directionV = Vector2.left; if (CollisionCheck(directionV)) { GameObject objectHit = InteractCheck(directionV); pushing(objectHit); // Walk into wall sound effect } else { pos += 2 * Vector3.left; } } if (Input.GetAxisRaw("Horizontal") > 0 && transform.position == pos) // Right { directionV = Vector2.right; if (CollisionCheck(directionV)) { { GameObject objectHit = InteractCheck(directionV); pushing(objectHit); // Walk into wall sound effect } } else { pos += 2 * Vector3.right; } } if (Input.GetAxisRaw("Vertical") > 0 && transform.position == pos) // Up { directionV = Vector2.up; if (CollisionCheck(directionV)) { { GameObject objectHit = InteractCheck(directionV); pushing(objectHit); // Walk into wall sound effect } } else { pos += 2 * Vector3.up; } } if (Input.GetAxisRaw("Vertical") < 0 && transform.position == pos) // Down { directionV = Vector2.down; if (CollisionCheck(directionV)) { { GameObject objectHit = InteractCheck(directionV); pushing(objectHit); // Walk into wall sound effect } } else { pos += 2 * Vector3.down; } } } transform.position = Vector3.MoveTowards(transform.position, pos, Time.deltaTime * speed); // Moving to new pos } // User interaction with a delay of how quickly it can be done equal to interactDelay if (Input.GetAxisRaw("Interact") > 0 & Time.time >= timestamp) { timestamp = Time.time + interactDelay; GameObject objectHit = InteractCheck(directionV); if (objectHit != null) { // Interacting with person or object if (objectHit.GetComponent <NPC_Behavior>() && interacting == false) { NPC_Behavior NPC = objectHit.GetComponent <NPC_Behavior>(); UI_DialogueSystem.SetActive(true); interacting = true; canMove = false; StartCoroutine(NPC.Interact()); } // Interacting with savepoint if (objectHit.GetComponent <SaveCrystal>() && interacting == false) { //SaveCrystal saveCrystal = objectHit.GetComponent<SaveCrystal>(); UI_SaveCrystal.SetActive(true); interacting = true; canMove = false; //saveCrystal.save(); } // Interacting with door, teleporter or something similar if (objectHit.GetComponent <TransferPoint>() && interacting == false) { TransferPoint transferPoint = objectHit.GetComponent <TransferPoint>(); //interacting = true; //canMove = false; gameManagerUpdate(); transferPoint.transfer(); // Set to HYPERSPEED, WE'RE GOING PLACES. updatePos(); } // Interacting with enemy or something similar that starts an encounter immediately if (objectHit.GetComponent <hostileEncounter>() && interacting == false) { hostileEncounter hostileEncounter = objectHit.GetComponent <hostileEncounter>(); //interacting = true; //canMove = false; gameManagerUpdate(); hostileEncounter.startBattle(); // Starts the battle updatePos(); } } } // Pause, pause, pause everything please! bring up the menu make everything stop if (Input.GetAxisRaw("Pause") > 0) { pauseButtonDown = true; } else { pauseButtonDown = false; } if (pauseButtonDown == true && pauseButtonPrevious == false) { if (paused) { // Unpausing UI_PauseMenuRoot.SetActive(false); UI_PauseMenu.SetActive(false); UI_PauseMenuParty.SetActive(false); UI_PauseMenuJournal.SetActive(false); paused = false; } else { if (!UI_DialogueSystem.activeSelf) { // If the dialogue box is not open/active UI_PauseMenu.SetActive(true); UI_PauseMenuRoot.SetActive(true); paused = true; } } } // Abort! abort! you know, dialogue if (Input.GetAxisRaw("Back") > 0) { if (paused) { //Unpausing UI_PauseMenuRoot.SetActive(false); UI_PauseMenu.SetActive(false); paused = false; } if (UI_DialogueSystem.activeSelf) { UI_DialogueSystem.SetActive(false); canMove = true; interacting = false; } } pauseButtonPrevious = pauseButtonDown; }