new void Start () { WalkingMode (); SelectHUD (); GameObject inetGO = GameObject.Find ("RedIntercon"); if (inetGO != null) { iNetRef = inetGO.GetComponent<interconNetwork> (); } speed = PLAYERSPEED; GameObject mgo = GameObject.Find ("MirrorObject"); if(mgo != null) { mirrorObject = mgo.GetComponent<MirrorObject> (); } agent = GetComponent<UnityEngine.AI.NavMeshAgent> (); if (agent != null) { agent.enabled = false; agent.updateRotation = false; } r = GetComponent<Rigidbody> (); unblockControls (); cam = GameObject.Find ("CameraLerp").GetComponent<CameraManager> (); masterControllerRef = GameObject.Find ("MasterController"); mcsRef = masterControllerRef.GetComponent<MasterControllerScript> (); rosetta = GameObject.Find ("Rosetta").GetComponent<Rosetta> (); ds = mcsRef.getStorage (); // check music if (!ds.retrieveBoolValue ("Is" + levelRef.locationName + "MusicPlaying")) { mcsRef.selectMixer (0); string lvl = levelRef.locationName.Substring (5, 1); //mcsRef.playMusic (int.Parse(lvl)); mcsRef.setVolume (1.0f); ds.storeBoolValue ("Is" + levelRef.locationName + "MusicPlaying", true); } spawningShadowElapsedTime = noSpawningShadowTime; state2 = PlayerState.idling; interactionQuadRef.GetComponent<SpriteRenderer> ().enabled = false; interaction = Interaction.None; interactee = null; backupInteractee = null; direction = PlayerDirection.front; playerRendRef = spriteQuadRef.GetComponent<SpriteRenderer>(); playerMatRef = playerRendRef.material; otherPlayerRendRef = spriteQuadBehindRef.GetComponent<SpriteRenderer> (); otherPlayerMat = otherPlayerRendRef.material; ascendPos = 0.0f; ascendSpeed = 0.0f; ascendAccel = 45.0f; elapsedTime = 0.0f; if (ds.retrieveBoolValue ("PlayerMustMaterialize")) { state = PlayerState.dematerialized; playerMatRef.color = new Color (1, 1, 1, 0); blocked = true; } else { state = PlayerState.idling; //opacity = 1.0f; playerMatRef.color = new Color (1, 1, 1, 1); } float x, y, z; x = ds.retrieveFloatValue ("Coords" + levelRef.locationName + "X"); y = ds.retrieveFloatValue ("Coords" + levelRef.locationName + "Y"); z = ds.retrieveFloatValue ("Coords" + levelRef.locationName + "Z"); Debug.Log ("<color=red>Player coords retrieved: (" + x + "," + y + "," + z + ") on "+levelRef.locationName+" </color>"); int orientation; orientation = ds.retrieveIntValue ("Orientation"); Debug.Log ("<color=green>Player orient. stored: (" + orientation + ") on "+levelRef.locationName+"</color>"); setOrientation (orientation); if ((x == 0) && (y == 0) && (z == 0)) { if (GameObject.Find ("PlayerStart")) { Vector3 newPos = GameObject.Find ("PlayerStart").transform.position; this.transform.position = newPos; } mustSnapToPlayerStart = 60; } if ((x != 0.0f) && (y != 0.0f) && (z != 0.0f)) { Vector3 newPos = new Vector3 (x, y, z); this.transform.position = newPos; mustSnapToPlayerStart = 0; } levelRef.loadPhysicalCameraPosition (); cam.Initialize (); string nameOfFollowingCharacter = ds.retrieveStringValue ("FollowingChar"); if (!nameOfFollowingCharacter.Equals ("")) { GameObject charaGO = GameObject.Find (nameOfFollowingCharacter); if (charaGO != null) { float xc = ds.retrieveFloatValue ("FollowerRelativeCoordsX"); float xy = ds.retrieveFloatValue ("FollowerRelativeCoordsY"); float xz = ds.retrieveFloatValue ("FollowerRelativeCoordsZ"); CharacterGenerator chara = charaGO.GetComponent<CharacterGenerator> (); if (chara != null) { chara.warpToRelativeToPlayer (new Vector3 (xc, xy, xz)); chara.setAutopilotAbsolute (true); chara.preventAwake = true; chara.stopAllEvents (); chara.startFollowingPlayer (); chara.markedAsStartFollowing = true; } } } levelRef.Start (); string retAct = ds.retrieveStringValue ("ReturnFromActivity"); if (retAct.Equals ("Well")) { int res = ds.retrieveIntValue ("ActivityResult"); if (res > 0) { int red = ds.retrieveIntValue ("RedManaObtained"); int blue = ds.retrieveIntValue ("BlueManaObtained"); if (red > 0) { string msg = rosetta.retrieveString (recoveryStrings.getStringId (0)) + red; levelRef._wm_alert (msg); } else { //string msg = rosetta.retrieveString (recoveryStrings.getStringId (1)) + blue; string s1 = recoveryStrings.getStringId (1); string s2 = rosetta.retrieveString (s1); string s3 = s2 + blue; levelRef._wm_alert (s3); } } else { //levelRef._wm_alert (rosetta.retrieveString (recoveryStrings.getStringId (2))); string s1 = recoveryStrings.getStringId (2); string s2 = rosetta.retrieveString (s1); levelRef._wm_alert (s2); } } else if (retAct.Equals ("Main-1")) { string lvl = levelRef.locationName.Substring (0, 6); ds.storeIntValue (lvl + "SpawnedShadows", 0); } if (levelRef.floor == 0) ds.storeStringValue ("ReturnFromActivity", "Main"); else if (levelRef.floor == -1) ds.storeStringValue ("ReturnFromActivity", "Main-1"); else if (levelRef.floor == 1) ds.storeStringValue ("ReturnFromActivity", "Main+1"); height = this.transform.position.y - 6; externalForce = Vector3.zero; mcsRef.saveGame (false); // save every time the player is spawned (change location) /* * * Check reentrancy * */ string reentryCondition = ds.retrieveStringValue ("ReentryCondition"); if (reentryCondition.Equals ("MirrorActivation")) { mirrorActivationDelaying = true; //camRef.GetComponent<CameraLookAt> ().enabled = false; cam._wm_disableLookAt (); } else mirrorActivationDelaying = false; if (reentryCondition.Equals ("Inventory")) { ds.storeStringValue ("ReentryCondition", ""); // consume condition int _num = ds.retrieveIntValue ("InventoryLevel"); inventory.reenter (_num); } if(levelRef.retrieveBoolValue("Meditating")) { levelRef.storeBoolValue("Meditating", false); meditatingRemaining = 4.5f; playerRendRef.sprite = Meditating[0]; otherPlayerRendRef.sprite = Meditating[0]; } else { meditatingRemaining = 0.0f; } /* * * Reset reentry condition * */ started = true; }