public IEnumerator RotateLock(Transform lockTransform, MapDirection targetDirection, MapDirection unlockDirection) { State.HasBeenAltered = true; Debug.Log("Rotating " + lockTransform.name + " to " + targetDirection.ToString()); //mLockTarget is a tool that helps me debug TODO remove it StoneGrindingAudio.Play(); mLockTarget.position = lockTransform.position; mLockTarget.rotation = Quaternion.Euler(0f, (int)targetDirection, 0f); Quaternion rotateStart = lockTransform.rotation; Quaternion rotateEnd = mLockTarget.rotation; double timeStarted = WorldClock.AdjustedRealTime; double duration = 1.25f; while (WorldClock.AdjustedRealTime < (timeStarted + duration)) { float normalizedAmount = (float)((WorldClock.AdjustedRealTime - timeStarted) / duration); lockTransform.rotation = Quaternion.Slerp(rotateStart, rotateEnd, normalizedAmount); yield return(null); } lockTransform.rotation = rotateEnd; //check to see if we're unlocked if (targetDirection == unlockDirection) { //TODO play a sound or something } mRotatingLock = false; worlditem.RefreshHud(); StoneGrindingAudio.Stop(); CheckIfUnlocked(); yield break; }
public Navnode GetNextNode(int start, MapDirection dir) { try { return(navmesh[start].Neighbors[dir]); } catch { Console.WriteLine("Node " + start + " has no " + dir.ToString() + " neighbor!"); return(null); } }