/// <summary> /// Sets the neighborIndex as the next goal location, and the direction you need to walk to get to it /// Sets all the flags and also hanndles data collection /// </summary> /// <param name="neighborIndex"></param> /// <param name="dir"></param> private void SetMoveTo(int neighborIndex, int dir, string tag) { // have to check the prop placements/card placements here var nextLocation = currentLocation.GetNeighbor((HexDirection)((neighborIndex + 6) % 6)); if (CanMove(nextLocation, dir) && turnController.CanMove(nextLocation.landType)) { Dictionary <string, string> strData = new Dictionary <string, string>() { { "character", tag }, { "type", "M" + (dir == 1 ? "F":"B") }, { "position", nextLocation.coordinates.ToString() } }; webSocketManager.Send("movement", strData, null); if (turnBased) { turnController.Movement(myCharacter, nextLocation.landType); } goalLocation = nextLocation; deltaV = 0; walkVal = dir; agentState = AgentState.Walking; walkAmount = Vector3.Distance(goalLocation.transform.position, currentLocation.transform.position); var km = new DataCollection.KeyMovement(); km.direction = goalLocation.coordinates.ToString(); km.keyDownTime = timeKeeper.gameTime; } else { isExecuting = false; OnCollisionEnter(); } }
/// <summary> /// Used for onscreen DPAD (see HoldRelease Script for UI). Like the inputlogger. /// starts a new log for datacollection /// </summary> /// <param name="dirkey">"right | left |forward| back"</param> public void SetKeyDown(string dirkey) { keyDown = true; currentMovement = new DataCollection.KeyMovement(); currentMovement.keyDownTime = timeKeeper.gameTime - timeKeeper.initSec; currentMovement.direction = dirkey; if (dirkey == "right" || dirkey == "left") { if (dirkey == "right") { rotVal = 1; } else { rotVal = -1; } agentState = AgentState.Turning; } else { if (dirkey == "forward") { walkVal = 1; } else { walkVal = -1; } agentState = AgentState.Walking; } }
/// <summary> /// Called in OnCollisionEnter /// In the event of hitting something and player cannot continue set course of action /// Stops all movement, and resets the action queue for movemnt to be started anew from point of collision /// </summary> public void StopClearAll() { agentState = AgentState.Stationary; actionsQ.Clear(); if (timeKeeper) { var keyMovement = new DataCollection.KeyMovement(); keyMovement.direction = "stop"; keyMovement.keyDownTime = timeKeeper.gameTime; } isExecuting = false; }