// Use this for initialization void Start() { GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1) { GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject"); for (int i = 0; i < mainObjectList.Length; ++i) { if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved) mainObject = mainObjectList[i]; } } // Ensures all necessary scripts are added for the MainObject gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureGameScriptsAdded(); worldCollisionRef = gameStateManagerRef.GetWorldCollision(); playerRef = GameObject.FindGameObjectWithTag("Player").GetComponent<TWCharacterController>(); //Init local reference - J.C. TearManagerLocalRef = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); }
void Start() { // get a reference to the tear manager tearManager = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); // get a reference to fold fold = GameObject.FindGameObjectWithTag("FoldObject").GetComponent<Fold>(); }
/// <summary> /// Start this instance. /// </summary> private void Start() { overPlayer = false; //initialize to false tornOverPlayer = false; TM = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); }
// Use this for initialization void Start() { #region initialization // NOTICE : DOM // the following is now needed // due to the prefab of 'MainObject' GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1) { GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject"); for (int i = 0; i < mainObjectList.Length; ++i) { if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved) mainObject = mainObjectList[i]; } } // Ensures all necessary scripts are added for the MainObject gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureCoreScriptsAdded(); gameStateManagerRef.EnsureScriptAdded("TouchController"); soundManagerRef = mainObject.GetComponent<SoundManager>(); screenManagerRef = mainObject.GetComponent<ScreenManager>(); #region initialize references backsidePivotReference = GameObject.Find("backsidepivot"); coverupPivotReference = GameObject.Find ("coveruppivot"); tornBacksidePieceReference = GameObject.Find ("tornBacksidePiece"); //sets the reference of the touchcontroller to the touchcontroller script. touchController = mainObject.GetComponent<TouchController>(); //sets the reference of the backsidesideReference to the backside or "fold" backsideReference = backsidePivotReference.transform.FindChild("backside").gameObject; backSideInitialColor = backsideReference.GetComponent<MeshRenderer>().material.color; //sets the reference of the backsideCollisionReference to the platforms on the back of the paper. backsideCollisionReference = GameObject.FindGameObjectsWithTag("FoldPlatform"); //sets the camera reference to the main camera cameraReference = GameObject.Find("Main Camera"); //sets the player reference to the player playerReference = GameObject.Find("Player_Prefab"); //sets the backgroundTransform to the transform of the background paper. origBackground = GameObject.FindGameObjectWithTag("background"); backgroundTransform = origBackground.transform; //sets backgroundBounds to the bounds of the background paper backgroundBounds = backgroundTransform.GetComponent<MeshFilter>().mesh.bounds; //sets changeMeshScript to the ChangeMeshScript which removes and restores triangles. changeMeshScript = this.GetComponent<ChangeMeshScript>(); tearReference = GameObject.Find("Tear_Manager").GetComponent<TearManager>(); coverupReference = coverupPivotReference.transform.FindChild("coverup").gameObject; tearPaperMesh = GameObject.Find("backside").GetComponent<MeshFilter>().mesh; unfoldCollisionReference = GameObject.Find("Player_Prefab").GetComponent<UnfoldCollision>(); shadowReference = GameObject.Find("shadow"); rayTraceBlockRef = GameObject.Find("rayTraceBlocker"); paperBorderInsideRef = GameObject.Find("paper_border_inside"); paperBorderOutsideRef = GameObject.Find("paper_border_outside"); worldCollisionRef = mainObject.GetComponent<WorldCollision>(); backsideTriangles = tearPaperMesh.triangles; #endregion //sets original position and rotation to its starting position and rotation foldOriginalRotation = backsidePivotReference.transform.rotation; foldOriginalPosition = backsidePivotReference.transform.position; //sets starting position coverup's starting position coverupStartingPosition = coverupPivotReference.transform.position; //sets coverup's original position to the vector required for the tranforms to work properly coverupOriginalPosition = new Vector3(0,0,-3); //sets coverup's original rotation to its starting rotation coverupOriginalRotation = coverupPivotReference.transform.rotation; coverupPrefab = coverupPivotReference.transform; foldPrefab = backsidePivotReference.transform; //initializes variables to defaults. fingerList = new List<Vector2>(); backgroundObjMax = new Vector2(); backgroundObjMin = new Vector2(); posModifier = new Vector3(); posModLastValid = new Vector3(); unfoldPosModifier = new Vector3(); foldTmpZLayer = GVariables.zFoldLayer - 1; coverupTmpZLayer = GVariables.zCoverLayer -1; prevMousestate = false; currMouseState = false; firstTouch = false; isFolded = false; overPlayer = false; needsToUnfold = false; isOffPaper = true; backsideIsInstantiated = false; currentlyFolding = false; missingTriangles = new List<Vector3>(); //changeMeshScript.GrabUpdatedPlatforms("FoldPlatform"); deletedTri = new int[0]; startingQuadrant = Quadrant.NONE; currentQuadrant = Quadrant.NONE; foldEdge = Edge.BuildManifoldEdges(backsideReference.GetComponent<MeshFilter>().mesh); guiEnable = false; blah = false; foldInput = false; prevFoldInput = false; #endregion }
void Start() { // the following is now needed due to the prefab of 'MainObject' GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureCoreScriptsAdded(); screenManagerRef = mainObject.GetComponent<ScreenManager>(); soundManagerRef = mainObject.GetComponent<SoundManager>(); characterControllerRef = GameObject.FindGameObjectWithTag("Player").GetComponent<TWCharacterController>(); mainCamera = GameObject.FindGameObjectWithTag("MainCamera"); // get a reference to the tear manager tearManager = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); // get a reference to fold fold = GameObject.FindGameObjectWithTag("FoldObject").GetComponent<Fold>(); LvlGoalCoreRef = GameObject.FindGameObjectWithTag("GoalCore").GetComponent<LvlGoalCore>(); // Get the global variables reference. GameObject gVar = GameObject.FindGameObjectsWithTag("globalVariables")[0]; globalVariables = gVar.GetComponent<GVariables>(); // if the goal is on the backside move necessary components by offset to be at correct location. if(goalOnBackSide){ // change the box collider on the goal core Vector3 GoalCollider = this.gameObject.GetComponent<BoxCollider>().center; GoalCollider = new Vector3(GoalCollider.x, GoalCollider.y, GoalCollider.z + (offset*2f)); this.gameObject.GetComponent<BoxCollider>().center = GoalCollider; // change the graphics child object position Vector3 GraphicTrans = transform.FindChild("Graphics").transform.position; GraphicTrans = new Vector3(GraphicTrans.x, GraphicTrans.y, GraphicTrans.z + offset); transform.FindChild("Graphics").transform.position = GraphicTrans; // change the goal core child object. Vector3 GoalCoreTrans = transform.FindChild("GoalCore").transform.position; GoalCoreTrans = new Vector3(GoalCoreTrans.x, GoalCoreTrans.y, GoalCoreTrans.z + offset); transform.FindChild("GoalCore").transform.position = GoalCoreTrans; } buttonCamera = GameObject.FindGameObjectWithTag("button"); }
/// <summary> /// Use this for initialization /// </summary> private void Start() { //init the local reference to this component thisMeshFilter = GetComponent<MeshFilter>(); //Initialize pointers to Scene GameObjects TearManager = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); PlayerObjectRef = GameObject.FindGameObjectWithTag("Player"); EndGoalObjectRef = GameObject.FindGameObjectWithTag("EndGoal"); //newPiece = newPaper; originalColor = new Color(1.0f, 1.0f, 1.0f, 1.0f); //Set the mesh offset distance based off object's vertice topology SetMeshOffsetWorldSpace(); //SetMeshOffsetScreenSpace(); //Initially, we set the paper's screen position to be zero screenPoint = new Vector3(0.0f, 0.0f, 0.0f); //Initialize the newMesh to be the same length of the previous newMesh = new Vector3[mesh.vertices.Length]; //The following is being used for tearing edge FX //could be better, doesn't need to go through every vert SetBoundsOfPaper(); //init the dictionary storing the vertices along the tear line and their associated index //init the the mesh.vertice array tearLine = new Dictionary<Vector3, int>(); tearLineTime = new Dictionary<Vector3, float>(); tearLinePositionTime = new Dictionary<float, Vector3>(); if(!PlatformPaper && !CloneObject) { //Init container into for torn edge FX tearEdgeFXcontainer = new GameObject("Tear_EdgeFXcontainer"); tearEdgeFXcontainer.transform.position = new Vector3(0,0,0); } //Set the tearLineTimer to zero initially as the starting tear line 'time' tearLineTimer = 0; //The following is used to create organized grid structure // to easily access vertices during runtime SetPaperGrid(); Clone = (GameObject) Instantiate(newPaper, this.transform.position, this.transform.rotation); Clone2 = (GameObject) Instantiate(newPaper, this.transform.position, this.transform.rotation); //TearManager.OriginalPlatformTopology.Add(Clone, GetComponent<MeshFilter>().mesh.triangles); //TearManager.OriginalPlatformTopology.Add(Clone2, GetComponent<MeshFilter>().mesh.triangles); Clone.GetComponent<TearPaper>().enabled = false; Clone2.GetComponent<TearPaper>().enabled = false; Clone.SetActive(false); Clone2.SetActive(false); if(TearEdgeFXPool == null) { int totalNumDecalsInPool = 500; TearEdgeFXPool = new GameObject[totalNumDecalsInPool]; for(int itor = 0; itor < totalNumDecalsInPool; itor++) { TearEdgeFXPool[itor] = (GameObject)Instantiate(TearManager.EdgeDecalObject); } } }
/// <summary> /// Start this instance. /// </summary> private void Start() { //Start tutorial tutorialFinished = false; //Make sure the tearPaper script is disabled during tutorial MainWorldPaper.GetComponent<TearPaper>().enabled = false; //initialize the local reference to the tear manager tearManagerRef = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1) { GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject"); for (int i = 0; i < mainObjectList.Length; ++i) { if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved) mainObject = mainObjectList[i]; } } // Ensures all necessary scripts are added for the MainObject gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); if(gameStateManagerRef.GetStatisticManager() != null) { if(Application.loadedLevel < gameStateManagerRef.GetStatisticManager().LevelScoresDict.Count + 1) tutorialFinished = true; } }
// Initializes any references that were not set in Start(). private void InitRemainingRefs() { //if(!allLoaded){ if(!paperObject){ paperObject = GameObject.FindGameObjectWithTag("background"); } if(!tearBorder){ tearBorder = GameObject.FindGameObjectWithTag("DeadSpace"); foldBorder = GameObject.FindGameObjectWithTag("foldborder"); unfoldBorder = GameObject.FindGameObjectWithTag("unfoldborder"); unfoldBlocker = GameObject.FindGameObjectWithTag("RayTraceBlocker"); moveBorder = GameObject.FindGameObjectWithTag("insideBorder"); menuButton = GameObject.Find("MenuButton_Prefab"); restartButton = GameObject.Find("RestartButton_Prefab"); } if(GameObject.FindGameObjectWithTag("TearManager")){ tearManagerRef = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); } if(GameObject.FindGameObjectWithTag("Player")){ playerObject = GameObject.FindGameObjectWithTag("Player"); unfoldCollisionRef = playerObject.GetComponent<UnfoldCollision>(); // JUSTIN, CHAR CONTR IS ATTACHED TO THE PLAYER, NOT MAIN OBJECT - D.A. controllerRef = GameObject.FindGameObjectWithTag("Player").GetComponent<TWCharacterController>(); } if(GameObject.FindGameObjectWithTag("FoldObject")){ foldRef = GameObject.FindGameObjectWithTag("FoldObject").GetComponent<Fold>(); } if(paperObject && tearManagerRef && playerObject && foldRef){ allLoaded = true; } //} }
// Use this for initialization void Start() { // Ensures all necessary scripts are added for the MainObject gameStateManagerRef = gameObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureCoreScriptsAdded(); inputManagerRef = gameObject.GetComponent<InputManager>(); playerObject = GameObject.FindGameObjectWithTag("Player"); paperObject = GameObject.FindGameObjectWithTag("background"); backsidePaperObject = GameObject.FindGameObjectWithTag("Fold"); // by default, player should be facing right // since we typically start from the left and head right currentDirection = AnimationDirection.RIGHT; /* FILLING IN ALL OF THE ANIMATIONS WITH TEXTURE2D FRAMES */ List<Texture2D> walkList = new List<Texture2D>(); PopulateWalkAnimations(walkList); walkAnimation = new Animation(walkList, Animation.AnimationState.WALK); List<Texture2D> idleList = new List<Texture2D>(); PopulateIdleAnimations(idleList); idleAnimation = new Animation(idleList, Animation.AnimationState.IDLE); List<Texture2D> standList = new List<Texture2D>(); PopulateStandAnimations(standList); standAnimation = new Animation(standList, Animation.AnimationState.STAND); List<Texture2D> jumpList = new List<Texture2D>(); PopulateJumpAnimations(jumpList); jumpAnimation = new Animation(jumpList, Animation.AnimationState.JUMP); List<Texture2D> idleAnimAList = new List<Texture2D>(); PopulateIdleAnimationA(idleAnimAList); idleAnimationA = new Animation(idleAnimAList, Animation.AnimationState.IDLEA); List<Texture2D> idleAnimBList = new List<Texture2D>(); PopulateIdleAnimationB(idleAnimBList); idleAnimationB = new Animation(idleAnimBList, Animation.AnimationState.IDLEB); List<Texture2D> landWallList = new List<Texture2D>(); PopulateLandWallAnimation(landWallList); landWallAnimation = new Animation(landWallList, Animation.AnimationState.WALKINTOWALL); List<Texture2D> slideUpList = new List<Texture2D>(); PopulateSlideUpAnimation(slideUpList); slideUpAnimation = new Animation(slideUpList, Animation.AnimationState.WALKUP); List<Texture2D> slideDownList = new List<Texture2D>(); PopulateSlideDownAnimation(slideDownList); slideDownAnimation = new Animation(slideDownList, Animation.AnimationState.WALKDOWN); List<Texture2D> deathList = new List<Texture2D>(); PopulateDeathAnimation(deathList); deathAnimation = new Animation(deathList, Animation.AnimationState.DEATH); List<Texture2D> openList = new List<Texture2D>(); PopulateOpenAnimation(openList); openAnimation = new Animation(openList, Animation.AnimationState.OPENDOOR); List<Texture2D> fallList = new List<Texture2D>(); PopulateFallAnimation(fallList); fallAnimation = new Animation(fallList, Animation.AnimationState.FALL); level1FrameList.Add(level1Frame1); level1FrameList.Add(level1Frame2); level1FrameList.Add(level1Frame3); //Load backside textures -> J.C. BacksideLevel1FrameList.Add(BacksideLevel1Frame1); BacksideLevel1FrameList.Add(BacksideLevel1Frame2); BacksideLevel1FrameList.Add(BacksideLevel1Frame3); //Add to list storing level background animation -> J.C. level2FrameList.Add(level2Frame1); level2FrameList.Add(level2Frame2); level2FrameList.Add(level2Frame3); level3FrameList.Add(level3Frame1); level3FrameList.Add(level3Frame2); level3FrameList.Add(level3Frame3); Backsidelevel3FrameList.Add(Backsidelevel3Frame1); Backsidelevel3FrameList.Add(Backsidelevel3Frame2); Backsidelevel3FrameList.Add(Backsidelevel3Frame3); //Add to list storing level background animation -> J.C. level4FrameList.Add(level4Frame1); level4FrameList.Add(level4Frame2); level4FrameList.Add(level4Frame3); //Add to list storing level background animation -> J.C. level5FrameList.Add(level5Frame1); level5FrameList.Add(level5Frame2); level5FrameList.Add(level5Frame3); //Add to list storing level background animation -> J.C. Backsidelevel5FrameList.Add(Backsidelevel5Frame1); Backsidelevel5FrameList.Add(Backsidelevel5Frame2); Backsidelevel5FrameList.Add(Backsidelevel5Frame3); //Add to list storing level background animation -> J.C. level6FrameList.Add(level6Frame1); level6FrameList.Add(level6Frame2); level6FrameList.Add(level6Frame3); //Load backside textures -> J.C. BacksideLevel6FrameList.Add(BacksideLevel6Frame1); BacksideLevel6FrameList.Add(BacksideLevel6Frame2); BacksideLevel6FrameList.Add(BacksideLevel6Frame3); //Add to list storing level background animation -> J.C. level7FrameList.Add(level7Frame1); level7FrameList.Add(level7Frame2); level7FrameList.Add(level7Frame3); //Load backside textures -> J.C. BacksideLevel7FrameList.Add(BacksideLevel7Frame1); BacksideLevel7FrameList.Add(BacksideLevel7Frame2); BacksideLevel7FrameList.Add(BacksideLevel7Frame3); //Add to list storing level background animation -> J.C. level8FrameList.Add(level8Frame1); level8FrameList.Add(level8Frame2); level8FrameList.Add(level8Frame3); //Load backside textures -> J.C. BacksideLevel8FrameList.Add(BacksideLevel8Frame1); BacksideLevel8FrameList.Add(BacksideLevel8Frame2); BacksideLevel8FrameList.Add(BacksideLevel8Frame3); //Add to list storing level background animation -> J.C. level9FrameList.Add(level9Frame1); level9FrameList.Add(level9Frame2); level9FrameList.Add(level9Frame3); //Load backside textures -> J.C. BacksideLevel9FrameList.Add(BacksideLevel9Frame1); BacksideLevel9FrameList.Add(BacksideLevel9Frame2); BacksideLevel9FrameList.Add(BacksideLevel9Frame3); //Add to list storing level background animation -> J.C. level10FrameList.Add(level10Frame1); level10FrameList.Add(level10Frame2); level10FrameList.Add(level10Frame3); //Load backside textures -> T.R. BacksideLevel10FrameList.Add(BacksideLevel10Frame1); BacksideLevel10FrameList.Add(BacksideLevel10Frame2); BacksideLevel10FrameList.Add(BacksideLevel10Frame3); //Add to list storing level background animation -> J.C. level11FrameList.Add(level11Frame1); level11FrameList.Add(level11Frame2); level11FrameList.Add(level11Frame3); //Load backside textures -> T.R. BacksideLevel11FrameList.Add(BacksideLevel11Frame1); BacksideLevel11FrameList.Add(BacksideLevel11Frame2); BacksideLevel11FrameList.Add(BacksideLevel11Frame3); //Add to list storing level background animation -> J.C. level12FrameList.Add(level12Frame1); level12FrameList.Add(level12Frame2); level12FrameList.Add(level12Frame3); //Load backside textures -> T.R. BacksideLevel12FrameList.Add(BacksideLevel12Frame1); BacksideLevel12FrameList.Add(BacksideLevel12Frame2); BacksideLevel12FrameList.Add(BacksideLevel12Frame3); //Add to list storing level background animation -> J.C. level13FrameList.Add(level13Frame1); level13FrameList.Add(level13Frame2); level13FrameList.Add(level13Frame3); //Load backside textures -> T.R. BacksideLevel13FrameList.Add(BacksideLevel13Frame1); BacksideLevel13FrameList.Add(BacksideLevel13Frame2); BacksideLevel13FrameList.Add(BacksideLevel13Frame3); //Add to list storing level background animation -> J.C. level14FrameList.Add(level14Frame1); level14FrameList.Add(level14Frame2); level14FrameList.Add(level14Frame3); //Load backside textures -> T.R. BacksideLevel14FrameList.Add(BacksideLevel14Frame1); BacksideLevel14FrameList.Add(BacksideLevel14Frame2); BacksideLevel14FrameList.Add(BacksideLevel14Frame3); //Add to list storing level background animation -> J.C. level15FrameList.Add(level15Frame1); level15FrameList.Add(level15Frame2); level15FrameList.Add(level15Frame3); //Add to list storing level background animation -> J.C. BacksideLevel15FrameList.Add(BacksideLevel15Frame1); BacksideLevel15FrameList.Add(BacksideLevel15Frame2); BacksideLevel15FrameList.Add(BacksideLevel15Frame3); //Add to list storing level background animation -> J.C. level16FrameList.Add(level16Frame1); level16FrameList.Add(level16Frame2); level16FrameList.Add(level16Frame3); //Load backside textures -> T.R. BacksideLevel16FrameList.Add(BacksideLevel16Frame1); BacksideLevel16FrameList.Add(BacksideLevel16Frame2); BacksideLevel16FrameList.Add(BacksideLevel16Frame3); //Add to list storing level background animation -> J.C. level17FrameList.Add(level17Frame1); level17FrameList.Add(level17Frame2); level17FrameList.Add(level17Frame3); //Load backside textures -> T.R. BacksideLevel17FrameList.Add(BacksideLevel17Frame1); BacksideLevel17FrameList.Add(BacksideLevel17Frame2); BacksideLevel17FrameList.Add(BacksideLevel17Frame3); //Add to list storing level background animation -> J.C. level18FrameList.Add(level18Frame1); level18FrameList.Add(level18Frame2); level18FrameList.Add(level18Frame3); //Load backside textures -> T.R. BacksideLevel18FrameList.Add(BacksideLevel18Frame1); BacksideLevel18FrameList.Add(BacksideLevel18Frame2); BacksideLevel18FrameList.Add(BacksideLevel18Frame3); //Add to list storing level background animation -> J.C. level19FrameList.Add(level19Frame1); level19FrameList.Add(level19Frame2); level19FrameList.Add(level19Frame3); //Add to list storing level background animation -> J.C. level20FrameList.Add(level20Frame1); level20FrameList.Add(level20Frame2); level20FrameList.Add(level20Frame3); //Add to list storing level background animation -> J.C. level21FrameList.Add(level21Frame1); level21FrameList.Add(level21Frame2); level21FrameList.Add(level21Frame3); //Add to list storing level background animation -> J.C. level22FrameList.Add(level22Frame1); level22FrameList.Add(level22Frame2); level22FrameList.Add(level22Frame3); //Add to list storing level background animation -> J.C. level23FrameList.Add(level23Frame1); level23FrameList.Add(level23Frame2); level23FrameList.Add(level23Frame3); //Add to list storing level background animation -> J.C. level24FrameList.Add(level24Frame1); level24FrameList.Add(level24Frame2); level24FrameList.Add(level24Frame3); //Add to list storing level background animation -> J.C. level25FrameList.Add(level25Frame1); level25FrameList.Add(level25Frame2); level25FrameList.Add(level25Frame3); finalLevel1FrameList.Add(finalLevel1Frame1); finalLevel6FrameList.Add(finalLevel6Frame1); finalLevel7FrameList.Add(finalLevel7Frame1); finalLevel8FrameList.Add(finalLevel8Frame1); finalLevel9FrameList.Add(finalLevel9Frame1); loadingFrameList.Add(loadingFrame1); loadingFrameList.Add(loadingFrame2); loadingFrameList.Add(loadingFrame3); //douglas -is this coded needed at all? looks like its not used by anything allAnimations.Clear(); allAnimations.Add(slideUpAnimation); allAnimations.Add(slideDownAnimation); allAnimations.Add(openAnimation); allAnimations.Add(deathAnimation); allAnimations.Add(landWallAnimation); allAnimations.Add(idleAnimationA); allAnimations.Add(idleAnimationB); allAnimations.Add(walkAnimation); allAnimations.Add(standAnimation); allAnimations.Add(idleAnimation); allAnimations.Add(jumpAnimation); currFrame = 0; timeToWait = 1 / TRANSITION_FPS; currentAnimType = AnimationType.STAND; currentAnim = standAnimation; firstInGameLoop = true; reversed = false; //The following is initializes the local tearManagerRef if (GameObject.FindGameObjectWithTag("TearManager")) TearManagerRef = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); }
private IEnumerator AnimateLevel(string currLevel) { //UnityEngine.Debug.Log("NUM " + currLevelFrame); if (currLevelFrame >= currentLevelTextures.Count - 1) currLevelFrame = 0; else currLevelFrame++; if (currLevelBacksideFrame >= currentLevelBacksideTextures.Count - 1) currLevelBacksideFrame = 0; else currLevelBacksideFrame++; yield return new WaitForSeconds(DetermineLevelAnimSpeed(currLevel)); if(TearManagerRef == null){ TearManagerRef = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); } if(TearManagerRef != null && TearManagerRef.TearFinished){ //ensure that the object references are intialized - > J.C. if(CutPiecePaper == null && TearManagerRef != null && TearManagerRef.MainWorldCutPaper != null) CutPiecePaper = TearManagerRef.MainWorldCutPaper; if(WorldPiecePaper == null && TearManagerRef != null && TearManagerRef.MainWorldPaper != null) WorldPiecePaper = TearManagerRef.MainWorldPaper; //Now update the torn pieces to animate level background art if(currentLevelTextures != null && currentLevelTextures.Count() > 0 && currLevelFrame < currentLevelTextures.Count() && currentLevelTextures[currLevelFrame] != null) { CutPiecePaper.renderer.sharedMaterial.mainTexture = currentLevelTextures[currLevelFrame]; WorldPiecePaper.renderer.sharedMaterial.mainTexture = currentLevelTextures[currLevelFrame]; } //Update backside texture accordingly -> J.C. if(currLevelBacksideFrame < currentLevelBacksideTextures.Count()) { backsidePaperObject.renderer.sharedMaterial.mainTexture = currentLevelBacksideTextures[currLevelBacksideFrame]; } } else // if (TearManagerRef != null && !TearManagerRef.TearFinished) { //The following check is for NON Animated levels -> J.C. if(currLevelFrame < currentLevelTextures.Count()) { if(paperObject != null) paperObject.renderer.sharedMaterial.mainTexture = currentLevelTextures[currLevelFrame]; } //Update backside texture accordingly -> J.C. if (backsidePaperObject) { if (currLevelBacksideFrame < currentLevelBacksideTextures.Count()) { backsidePaperObject.renderer.sharedMaterial.mainTexture = currentLevelBacksideTextures[currLevelBacksideFrame]; } } } //else // else // { // //The following should NOT be called -> J.C. // UnityEngine.Debug.Log("Poopy, ONLY IS THIS IS CALLED OUTSIDE LEVEL TRANSITION OR RESET --- there is an Animating Level Material swap error - JOHN C. FIX"); // } StopCoroutine("AnimateLevel"); StartCoroutine("AnimateLevel",currLevel); }