public static void AddInvoker(SpeedBlock speedBlock) { invoker.Add(speedBlock); foreach (UnityAction ua in Speedlistener) { speedBlock.AddSpeedUpListener(ua); } }
public static Block Instantiate(string name) { Experiment.Measurement.newBlock(name); Block b; switch (name) { case "carousel": b = new CogBlock <CarouselTrial>(); break; case "propeller": b = new CogBlock <PropellerTrial>(); break; case "speed": b = new SpeedBlock(); break; case "training": b = new CogBlock <CogTrial>(); break; case "direction": b = new CogBlock <DirectionTrial>(); break; case "trainingStability": b = new GenericBlock <StabilityTrial>(); break; case "stabilityGreen": b = new GenericBlock <GreenStabilityTrial>("RESP,CRESP,AnzahlVersuche,Antwortkoordinaten,RT1,RT2,RT3,RT-Gesamt"); break; case "stabilityRed": b = new RedStabilityBlock(2); break; case "matrix": b = new MatrixBlock(7, 3); break; case "vocabulary": b = new VocabularyBlock(13); break; case "carouselTransfer": b = new CogBlock <CarouselTrial>(); // orientiert an Standard carousel break; case "prt": b = new RedStabilityBlock(0); // orientiert an RedStab break; case "sts": b = new RedStabilityBlock(1); // orientiert an RedStab break; default: throw new System.ArgumentException("Tried to instantiate a block with an unknown type: '" + name + "'"); } b.Config = name; return(b); }
} //End update private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "SlowBlock") { SlowBlock slowBlock = collision.GetComponent <SlowBlock>(); currentSpeed -= slowBlock.SlowValue; SpeedChange(); } if (collision.gameObject.tag == "SpeedBlock") { SpeedBlock speedBlock = collision.GetComponent <SpeedBlock>(); currentSpeed += speedBlock.SpeedValue; SpeedChange(); } if (collision.gameObject.tag == "Wall") { Debug.Log("Hit Wall"); levelControl.LoseLevel(); } if (collision.gameObject.tag == "Trophy") { Debug.Log("GG"); trophyCount++; Destroy(collision.gameObject); if (trophyCount < trophyReq) { Debug.Log(trophyCount); } else { levelControl.WinLevel(); } } if (collision.gameObject.tag == "TeleBlock" && canTeleport == 0) { canTeleport += 2; TeleBlock teleBlock = collision.GetComponent <TeleBlock>(); gameObject.transform.position = teleBlock.Teleport.position; } if (collision.gameObject.tag == "TriggerBlock") { TriggerBlock triggerBlock = collision.GetComponent <TriggerBlock>(); for (int i = 0; i < triggerBlock.toMove.Length; i++) { if (triggerBlock.toMove[i].GetComponent <Wall>().Moving) { triggerBlock.toMove[i].GetComponent <Wall>().Moving = false; } else { triggerBlock.toMove[i].GetComponent <Wall>().Moving = true; } } } if (currentSpeed < startingSpeed) { currentSpeed = startingSpeed; } //speed cap and minimim if (currentSpeed > maxSpeed) { currentSpeed = maxSpeed; } }
private void PrepareLevel(bool spawnPlayer) { Level level = new Level(LEVEL_WIDTH, LEVEL_HEIGHT); BOUNDRY_BLOCKS[0] = new Vector3(0, 0); BOUNDRY_BLOCKS[1] = new Vector3(LEVEL_WIDTH * 2.65f, 0); BOUNDRY_BLOCKS[2] = new Vector3(0, LEVEL_HEIGHT * 2.65f); BOUNDRY_BLOCKS[3] = new Vector3(0, 0); for (int x = 0; x < LEVEL_WIDTH; x++) { for (int y = 0; y < LEVEL_HEIGHT; y++) { Color color = currentLevelTex.GetPixel(x, y); if (ColorMap.MatchesColor(color, ColorMap.THEME_FOREST)) // read in theme { ThemeLoader.LoadForestTheme(); } else if (ColorMap.MatchesColor(color, ColorMap.THEME_DESERT)) { ThemeLoader.LoadDesertTheme(); } else if (ColorMap.MatchesColor(color, ColorMap.DULL_BLOCK)) { DullBlock block = Instantiate(defaultBlock); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.CHECKPOINT)) { CheckpointBlock block = Instantiate(checkpointBlock); block.block = Block.init(x, y, level, block.gameObject); CheckpointManager.AddCheckpoint(block); } else if (ColorMap.MatchesColor(color, ColorMap.AIR_BLOCK)) { AirBlock block = Instantiate(airBlock); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.SPEED_BLOCK)) { SpeedBlock block = Instantiate(speedBlock); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.CRUMBLY_BLOCK)) { CrumblyBlock block = Instantiate(crumblyBlock); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.FINISH)) { FinishBlock block = Instantiate(finishBlock); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.LEAP_BOOST_BLOCK)) { LeapBoostBlock block = Instantiate(leapBoostBlock); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.AUTO_LEAP_BOOST_BLOCK)) { AutoLeapBoostBlock block = Instantiate(autoLeapBoostBlock); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.DISGUISED_CRUMBLY_BLOCK)) { CrumblyBlock block = Instantiate(crumblyBlock); Disguise disguise = block.gameObject.AddComponent <Disguise>(); disguise.identity = crumblyBlock.GetComponent <SpriteRenderer>().sprite; disguise.camouflage = defaultBlock.GetComponent <SpriteRenderer>().sprite; disguise.HideIdentity(); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.DISGUISED_AUTO_LEAP_BOOST_BLOCK)) { AutoLeapBoostBlock block = Instantiate(autoLeapBoostBlock); Disguise disguise = block.gameObject.AddComponent <Disguise>(); disguise.identity = autoLeapBoostBlock.GetComponent <SpriteRenderer>().sprite; disguise.camouflage = defaultBlock.GetComponent <SpriteRenderer>().sprite; disguise.HideIdentity(); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.DISGUISED_DULL_BLOCK)) { DullBlock block = Instantiate(defaultBlock); Disguise disguise = block.gameObject.AddComponent <Disguise>(); disguise.identity = defaultBlock.GetComponent <SpriteRenderer>().sprite; disguise.camouflage = null; disguise.HideIdentity(); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.GHOST_BLOCK)) { DullBlock block = Instantiate(defaultBlock); Disguise disguise = block.gameObject.AddComponent <Disguise>(); disguise.identity = null; disguise.camouflage = null; disguise.HideIdentity(); block.block = Block.init(x, y, level, block.gameObject); } else if (ColorMap.MatchesColor(color, ColorMap.ENEMY_SUKAMON)) { // spawn sukamon EnemyControl ec = Instantiate(sukamon); ec.transform.position = new Vector3(x * 2.65f, y * 2.65f + 0.5f); } else if (ColorMap.MatchesColor(color, ColorMap.DIGIVICE)) { } else if (ColorMap.MatchesColor(color, ColorMap.ENEMY_KINGETEMON)) { EnemyControl ec = Instantiate(kingetemon); ec.transform.position = new Vector3(x * 2.65f, y * 2.65f + 0.5f); } else if (ColorMap.MatchesColor(color, ColorMap.ENEMY_SUKAMON_STATIC)) { EnemyControl ec = Instantiate(sukamon); ec.blockRadius = 0; ec.transform.position = new Vector3(x * 2.65f, y * 2.65f + 0.5f); } else if (ColorMap.MatchesColor(color, ColorMap.ENEMY_GIGANTIC_SUKAMON)) { EnemyControl ec = Instantiate(giganticSukamon); ec.blockRadius = 20; ec.moveSpeed = 8; //ec.health *= 5; ec.transform.position = new Vector3(x * 2.65f, y * 2.65f + 0.5f); } else if (ColorMap.MatchesColor(color, ColorMap.WOODEN_SIGN)) { SignDialogue sd = Instantiate(signDialogue); sd.transform.position = new Vector3(x * 2.65f, y * 2.65f + 0.5f); } } } currentLevel = level; foreach (var observer in OBSERVERS) { observer.OnLevelLoaded(level); } if (spawnPlayer) { int score = 1; if (currentPlayerInstance != null) { score = currentPlayerInstance.score; } Vector3 pos = CheckpointManager.ActiveCheckpoint.transform.position; Player p = Instantiate(player); p.transform.position = new Vector3(pos.x, pos.y + 5, pos.z); currentPlayerInstance = p; p.score = score; Debug.Log(p.score); Camera.main.GetComponent <CamCapture>().player = p; Camera.main.GetComponent <CamCapture>().boundryBlocks = BOUNDRY_BLOCKS; } }