// Use this for initialization public void Start() { clone = GetComponentInParent <CloneScript>(); gameTicks = 0.0f; ouchies = 0.0f; //keeps track of time between ouching the enemy drawTime = 0.3f; //alter this to modify how long the sword stays up ts = GetComponent <Transform>(); pause = false; rightRot = new Vector3(0.0f, 0.0f, 0.0f); leftRot = new Vector3(0.0f, 180.0f, 0.0f); isNotClone = false; /* * if (drawn) * { * swordUp(rightRot); * } * else * { * swordDown(rightRot); * } */ }
// Update is called once per frame void Update() { PlayerScript PlayerScript = GetComponent <PlayerScript>(); TimeTravelIndicator TimeTravelIndicator = GetComponent <TimeTravelIndicator>(); if (frameNum % framerate == 0) //every big frame, record the player's actions { bool didSword = PlayerScript.didSword; bool didShoot = PlayerScript.didShoot; CloneLocation toAdd = new CloneLocation(transform.position, playerRotation.transform.rotation.eulerAngles, didSword, didShoot); if (didShoot) { PlayerScript.didShoot = false; } if (didSword) { PlayerScript.didSword = false; } locations.Add(key, toAdd); //Add the player's current location to the locations map key++; //The location's number } frameNum++; int charge = PlayerScript.getCharges(); if (charge >= currLevelCharges()) //go back in time { newClone = Instantiate(clone); //create the clone PlayerScript.resetCharges(); //set charges to 0 TimeTravelIndicator.setFlash("white"); //flashes the screen white Resetter resetter = nonPlayerObjects.GetComponent <Resetter>(); //resets the location of everything resetter.reset = true; bucket.GetComponent <BucketScript>().reset(); //resets the bucket's status timer.GetComponent <Timer>().reset(); //resets the timer locations.Add(key, DESTROY_CLONE); //Adds a marker - the past self should be destroyed here key++; } if ((newClone != null) && (frameNum % framerate == 0)) //every big frame, update the clone { CloneLocation toSet = (CloneLocation)locations[key2]; CloneScript cloneScript = newClone.GetComponent <CloneScript>(); if (!PlayerScript.getPause()) //Pauses the clone { cloneScript.setLocation(toSet); //set the clone's location key2++; } } }
/* Called once by the MainLoop to set up the board's gameObjects */ public Cell[,] spawnBoard() { /* * textEffectHighScore.Stop(); * textEffectHighScore.Clear(); * * textHighScore.SetActive(false); * textPlayerGoals1.SetActive(false); * textPlayerGoals2.SetActive(false); * * doorToggleSeconds = -1f; * frameCount = 0; * timeOfLevel = 0; * playTimeOfLevel = 0; * firstMoveWasMade = false; * cellAudioIdx = 0; * * curLevel = level; * * gameMap = gameMapList[level]; * startMap = gameMap.getMap(); * gridWidth = startMap.GetLength(0); * gridHeight = startMap.GetLength(1); */ int numCells = 0; /* * textNameData.text = gameMap.getLevelName(); * textScoreData.text = "Leader: " + gameMap.getLeastMoves() + " moves in " + gameMap.getFastestTime() + " sec by " + * gameMap.getPlayerNames(); * textCurrentScore.SetActive(true); * textHighScore.SetActive(true); */ Cell[,] grid = new Cell[width, height]; /* Used to check that there is only one goal in the map */ bool foundGoal = false; /* Spawn board blocks */ //Debug.Log("Spawn Board(" + level + "): " + grid.GetLength(0) + "(" + gridWidth + ") x " + grid.GetLength(1) + "(" + gridHeight + ")"); CloneScript boardBlockScript = boardBlock.GetComponent <CloneScript>(); for (int x = 0; x < width; x++) { for (int z = 0; z < height; z++) { if (map[x, z] == Element._.NOTHING) { continue; } //Debug.Log("startMap[" + x + ", " + z + "]=" + startMap[x, z]); numCells++; int y = Random.Range(2, 40); GameObject block = boardBlockScript.cloneMe(x, 0, z); block.SetActive(true); grid[x, z] = new Cell(map[x, z], block, new Material(Shader.Find("Standard"))); if (map[x, z] == Element._.GOAL) { if (foundGoal) { Debug.Log("Each level must have Exactly ONE goal."); } foundGoal = true; //goalBlock.transform.position = new Vector3(x, 1, z); } } } return(grid); }