void generatePath() { Timekeeper timekeeper = Timekeeper.getInstance(); Tuple3I position = memComponent.position; int startTick = timekeeper.getTick(); int moveTick = timekeeper.GetTickIn(fadeTime); float tickIncrement = 1.0f / (moveTick - startTick); float progress = 0; Memory memory; // Add first reposition memory memory = new Memory(Memory.MemoryEvent.reposition, position); memComponent.hashtable[moveTick] = memory; // Create appearing animation for (int tick = startTick + 1; tick <= moveTick; tick++) { memory = new Memory(Memory.MemoryEvent.appearing, progress += tickIncrement); memComponent.hashtable[tick] = memory; } int speedTicks = timekeeper.GetTickIn(speed) - timekeeper.getTick(); moveTick++; // Add subsequent reposition memories while (MapGenerator.GetPathValueFor(position) != 1) { moveTick += speedTicks; if ((moveTick - startTick) / speedTicks > 1000) // more than 1000 steps { Debug.Log("Path taking too long!"); return; } position = NextPathFor(position); memory = new Memory(Memory.MemoryEvent.reposition, position); memComponent.hashtable[moveTick] = memory; } // Add animation for climbing the ladder position.third = 1; Tuple3I newPosition = position + new Tuple3I(1, 0, 0); for (int i = 0; i < 16; i++) { memory = new Memory(Memory.MemoryEvent.reposition, position, newPosition, i * 1.0f / 16); memComponent.hashtable[moveTick + i] = memory; } }
public void willStartWalking() { GameObject newPlayer = Instantiate(currentPlayer); MemoryComponent newMemoryComponent = newPlayer.GetComponent <MemoryComponent> (); currentPlayer = newPlayer; memComponent = newMemoryComponent; foreach (Transform child in currentPlayer.transform) { if (child.CompareTag("Animator")) { Renderer rend = child.GetComponent <Renderer>(); rend.material.SetFloat("_bwBlend", 0); } } lastPressTime = timekeeper.getTime(); memComponent.state = Memory.MemoryEvent.appearing; memComponent.progress = 0.1f; // set inactive state // memComponent.SetInactive(); // currentPlayer.GetComponent<MemorySystem>().ImmediateSave( // timekeeper.getTick() - 1); memComponent.firstActiveTick = timekeeper.getTick() - 1; memComponent.isSaving = true; state = State.transitioning; memComponent.state = Memory.MemoryEvent.appearing; memComponent.progress = 0.1f; currentPlayer.GetComponent <MovementSystem>().startTransition(transitionTime); timekeeper.stopRewind(); }
public void Spawn(int[] enemies) { Timekeeper timekeeper = Timekeeper.getInstance(); foreach (GameObject enemy in currentEnemies) { Destroy(enemy, 1.0f); } currentEnemies.Clear(); int spritesLength = enemyAnimators.Length; int spriteIndex = Random.Range(0, spritesLength); // Spawn for each entangled group for (int i = 0; i < enemies.Length; i++) { GameObject[] twins = new GameObject[enemies[i]]; TupleI observed = new TupleI(0, enemies[i]); for (int j = 0; j < enemies[i]; j++) { GameObject newEnemy = Instantiate(enemyPrefab, Vector3.zero, Quaternion.identity); twins[j] = newEnemy; newEnemy.name = "Enemy-" + wave + "-" + i + "-" + j; currentEnemies.Add(newEnemy); newEnemy.GetComponent <MemoryComponent>().position = randomValidPosition(); newEnemy.GetComponent <MemoryComponent>().firstActiveTick = timekeeper.getTick(); newEnemy.GetComponent <AnimatorChildComponent>().animator. runtimeAnimatorController = enemyAnimators[spriteIndex]; EnemyObservingSystem observer = newEnemy.GetComponent <EnemyObservingSystem>(); observer.twins = twins; observer.observed = observed; observer.spawnSystem = this; observer.chargeComponent = GetComponent <ChargeComponent>(); } spriteIndex = (spriteIndex + 1) % spritesLength; } }