private void Awake() { if (level == -1) { //random stage stage = DataUtils.getRandomStage(world, GameControl.control.getWorldLevel(world)); } else { stage = Instantiate(Resources.Load <StageAsset>("LevelAssets/" + world.ToString() + "/" + world.ToString() + level)); if (wonLastLevel()) { stage = DataUtils.WonLastLvlStage(stage, world, level); } } GameControl.control.GetComponent <Canvas>().enabled = false; GameControl.control.GetComponent <GraphicRaycaster>().enabled = true; setBackground(); PlayerData enemyPlayerData = getEnemyData(); userPlayer = gameObject.AddComponent <ExplorePlayer>(); enemyPlayer = gameObject.AddComponent <ExplorePlayer>(); float CatScale = GameControl.control.playerData.team.Count > enemyPlayerData.team.Count ? getCatScale(GameControl.control.playerData.team.Count) : getCatScale(enemyPlayerData.team.Count); userPlayer.init(GameControl.control.playerData, enemyPlayer, catGameObjectPrefab, CatScale, userPos, Vector3.zero, checkGameOver); enemyPlayer.setAsEnemy(userPlayer); enemyPlayer.init(enemyPlayerData, userPlayer, catGameObjectPrefab, CatScale, enemyPos, new Vector3(0, 180, 0), checkGameOver); setUpStart(); MapManager.StageTransition(1, 0, world, () => { if (level == -1) { string[] randomEncounters = new string[] { enemyPlayerData.team[0].Name + " is happy to see you!", enemyPlayerData.team[0].Name + " is excited to see you!", enemyPlayerData.team[0].Name + " stops you to say hi!", enemyPlayerData.team[0].Name + " wants to play with you!", enemyPlayerData.team[0].Name + " interrupts your journey!", enemyPlayerData.team[0].Name + " confronts you!", "You've been stopped by " + enemyPlayerData.team[0].Name + "!", enemyPlayerData.team[0].Name + " saw you and wants to play!", }; Notify(new string[] { randomEncounters[UnityEngine.Random.Range(0, randomEncounters.Length)] }, Init); return; } Init(); }); }
private void setUI() { if (Unlocked) { string world = worldType.ToString(); transform.Find("banner").Find("text").GetComponent <TextMeshProUGUI>().text = world.First().ToString().ToUpper() + world.Substring(1); Transform clouds = transform.Find("clouds"); if (clouds != null && GameControl.control.getWorldLevelHasPlayed(worldType, 0)) { Destroy(clouds.gameObject); } else if (clouds != null) { LeanTween.color((RectTransform)transform.Find("clouds").transform, new Color(1, 1, 1, 0), 3).setDelay(0.2f).setEaseOutSine(); } } else { transform.Find("banner").gameObject.SetActive(false); Shader sh = Shader.Find("GUI/Text Shader"); Image im = GetComponent <Image>(); im.material = new Material(sh); im.material.color = DataUtils.getDisabledWorldColor(worldType); } }
public static void StageTransition(float from, float to, WorldType world, Action onComplete) { StageTransition ST = Camera.main.GetComponent <StageTransition>(); ST.changeTexture(Resources.Load <Texture2D>("LevelAssets/Textures/" + world.ToString())); LeanTween.value(from, to, 1.2f).setOnUpdate((float value) => { ST.changeCutoff(value); }).setEaseInOutQuad().setOnComplete(onComplete); }
public JoinGamePacket(int playerEntityId, PlayerGamemode gamemode, Dimension dimension, WorldType worldType, int viewDistance, bool verboseDebugInfo = true) { /*Data = ArrayUtilities.Combine( * Converters.GetIntBytes(playerEntityId) * .Add((byte) gamemode), * Converters.GetIntBytes((int) dimension) * .Add(0), * Converters.GetStringBytes(worldType.ToString()), * Converters.GetVarIntBytes(viewDistance) * .Add(Converters.GetBoolBytes(!verboseDebugInfo)) * );*/ _playerEntityId = playerEntityId; _playerGamemode = (byte)gamemode; _dimension = (int)dimension; _worldType = worldType.ToString(); _viewDistance = viewDistance; _hideVerboseDebugInfo = !verboseDebugInfo; }
public WorldPin FindPin(WorldType world) { return(transform.Find(world.ToString()).GetComponent <WorldPin>()); }
void evaluateOnSets(Dictionary <string, MMNode> models, Dictionary <string, List <Dictionary <string, double[, ]> > > sets, string logFile, WorldType worldType) { Console.WriteLine(DateTime.Now + "\t" + "Starting to test log."); //Dump it into a file StreamWriter file = new StreamWriter(logFile, hasWrittenHeaders); //Write some metadata if (!hasWrittenHeaders) { file.WriteLine("worldWidth\t" + worldWidth); file.WriteLine("worldHeight\t" + worldHeight); file.WriteLine("seedsNumber\t" + seedsNumber); file.WriteLine("orientationVariability\t" + orientationVariability); file.WriteLine("retinaSize\t" + retinaSize); file.WriteLine("saccadeSize\t" + saccadeSize); file.WriteLine(); //write the headers file.Write("WorldType,"); file.Write("Model,"); file.Write("SetName,"); file.Write("InvertedBits,"); file.Write("TrainingSetSize,"); file.Write("AllModSumError,"); if (EXTENSIVE_LOG) { file.Write(getMatrixHeadingS("XY-t0", 1, 1, 2)); file.Write(getMatrixHeadingS("XY-t1", 1, 1, 2)); file.Write(getMatrixHeadingS("Vision-t0-Color", retinaSize, retinaSize, 4)); file.Write(getMatrixHeadingS("Vision-t0-Orientation", retinaSize, retinaSize, 2)); file.Write(getMatrixHeadingS("Vision-t0-Shape", retinaSize, retinaSize, 4)); file.Write(getMatrixHeadingS("Saccade", 1, 1, 4)); file.Write(getMatrixHeadingS("Vision-t1-Color", retinaSize, retinaSize, 4)); file.Write(getMatrixHeadingS("Vision-t1-Orientation", retinaSize, retinaSize, 2)); file.Write(getMatrixHeadingS("Vision-t1-Shape", retinaSize, retinaSize, 4)); } foreach (Signal mod in models.First().Value.modalities) { string modName = models.First().Value.labelsModalities[mod]; file.Write(getMatrixHeadingS("corruption_" + modName, 1, 1, 1)); if (EXTENSIVE_LOG) { file.Write(getMatrixHeadingS("reality_" + modName, 1, 1, mod.Width * mod.Height)); file.Write(getMatrixHeadingS("prediction_" + modName, 1, 1, mod.Width * mod.Height)); } file.Write(getMatrixHeadingS("originalMaxError_" + modName, 1, 1, 1)); file.Write(getMatrixHeadingS("corruptedMaxError_" + modName, 1, 1, 1)); file.Write(getMatrixHeadingS("originalSumError_" + modName, 1, 1, 1)); file.Write(getMatrixHeadingS("corruptedSumError_" + modName, 1, 1, 1)); if (modName.Contains("Vision")) { file.Write("wrongPixels_" + modName + ","); } } file.WriteLine(); hasWrittenHeaders = true; } //Start the test foreach (string modelName in models.Keys) { Console.Write("Testing" + modelName + " ..."); Stopwatch watch = new Stopwatch(); watch.Start(); MMNode network = models[modelName]; network.learningLocked = true; foreach (string setName in sets.Keys) { //We have "usedForTraining" if (setName == "train") { continue; } List <Dictionary <string, double[, ]> > set = sets[setName]; //Test with different level of noise for (double bitShiftProb = 0.0; bitShiftProb <= 1.0; bitShiftProb += 0.5) { foreach (Dictionary <string, double[, ]> sample in set) { //Set the modalities int invertedBits = 0; Dictionary <Signal, double> modalityCorruption = new Dictionary <Signal, double>(); foreach (Signal s in network.modalities) { modalityCorruption[s] = 0.0; s.reality = sample[network.labelsModalities[s]].Clone() as double[, ]; //Corrupt the signal if (network.labelsModalities[s].Contains("t1")) { modalityCorruption[s] = bitShiftProb; //1-----------------Toggle the bit //ArrayHelper.ForEach(s.reality, false, (x, y) => //{ // if (MathHelpers.Rand.NextDouble() < bitShiftProb) // { // s.reality[x, y] = Math.Abs(s.reality[x, y] - 1.0); // invertedBits++; // } //}); //2-----------------Set bit to 0.5 ArrayHelper.ForEach(s.reality, false, (x, y) => { if (MathHelpers.Rand.NextDouble() < bitShiftProb) { s.reality[x, y] = 0.5; invertedBits++; } }); } } network.Converge(); network.Diverge(); double globalError = 0.0; foreach (Signal s in network.modalities) { globalError += s.ComputeSumAbsoluteError(); } //Dump the info string line = ""; line += worldType.ToString() + "," + modelName + "," + setName + "," + invertedBits + "," + sets["usedForTraining"].Count + "," + globalError + ","; if (EXTENSIVE_LOG) { line += GetString(sample["XY-t0"]) + "," + GetString(sample["XY-t1"]) + "," + GetString(sample["Vision-t0-Color"]) + "," + GetString(sample["Vision-t0-Orientation"]) + "," + GetString(sample["Vision-t0-Shape"]) + "," + GetString(sample["Saccade"]) + "," + GetString(sample["Vision-t1-Color"]) + "," + GetString(sample["Vision-t1-Orientation"]) + "," + GetString(sample["Vision-t1-Shape"]) + ","; } foreach (Signal s in network.modalities) { line += modalityCorruption[s] + ","; if (EXTENSIVE_LOG) { line += GetString(s.reality) + "," + GetString(s.prediction) + ","; } line += MathHelpers.maximumAbsoluteDistance(s.prediction, sample[network.labelsModalities[s]]) + "," + MathHelpers.maximumAbsoluteDistance(s.prediction, s.reality) + "," + MathHelpers.sumAbsoluteDistance(s.prediction, sample[network.labelsModalities[s]]) + "," + MathHelpers.sumAbsoluteDistance(s.prediction, s.reality) + ","; string modName = network.labelsModalities[s]; if (modName.Contains("Vision")) { line += countWrongPixels(modName, s.prediction, sample[network.labelsModalities[s]]).ToString() + ","; } } file.WriteLine(line); } } } file.Flush(); watch.Stop(); Console.WriteLine("Done {0}", watch.Elapsed); } file.Close(); Console.WriteLine(DateTime.Now + "\t" + "Test log written."); }
public void Load(Script.ScriptSection toParse) { int actgood = -1; short x1 = -1; short x2 = -1; short y1 = -1; short y2 = -1; foreach (Script.TagDataPair t in toParse.TagDataPairs) { string UTag = t.Tag.ToUpper(); switch (t.Tag[0]) { case 'A': if (UTag == "ABWEATH") { weather = t.Data.ToUInt08(); } else if (UTag == "APPEARANCE") { visualAppearance = WorldType.Count; for (WorldType wt = WorldType.Spring; wt < WorldType.Count; wt++) { if (t.Data.Value.ToUpper() == wt.ToString().ToUpper()) { visualAppearance = wt; break; } } if (visualAppearance == WorldType.Count) { visualAppearance = WorldType.Unknown; } } break; case 'b': case 'B': if (UTag == "BUYABLE") { if (actgood > -1) { ((GoodData)goodList[actgood]).BuyValue = t.Data.ToInt32(); } // else // Console.Error( 2, "regions dfn -> You must write BUYABLE after GOOD <num>!" ); } break; case 'c': case 'C': if (UTag == "COLOURMINSKILL") { break; } else if (UTag == "CHANCEFORBIGORE") { chanceFindBigOre = t.Data.ToUInt08(); } else if (UTag == "CHANCEFORCOLOUR") { break; } break; case 'd': case 'D': if (UTag == "DUNGEON") { IsDungeon = (t.Data.ToInt32() == 1); } break; case 'E': if (UTag == "ESCORTS") { // Load the region number in the global array of valid escortable regions // if( t.Data.ToInt32() == 1 ) // cwmWorldState->escortRegions.push_back( regionNum ); } // End - Dupois break; case 'G': if (UTag == "GUARDOWNER") { guardowner = t.Data; } else if (UTag == "GUARDNUM") { break; } else if (UTag == "GUARDLIST") { guardList = t.Data; } else if (UTag == "GUARDED") { IsGuarded = (t.Data.ToInt32() == 1); } else if (UTag == "GATE") { CanGate = (t.Data.ToInt32() == 1); } else if (UTag == "GOOD") { actgood = t.Data.ToInt32(); } break; case 'M': if (UTag == "MIDILIST") { midiList = t.Data.ToUInt16(); } else if (UTag == "MAGICDAMAGE") { CanCastAggressive = (t.Data.ToInt32() == 1); } else if (UTag == "MARK") { CanMark = (t.Data.ToInt32() == 1); } break; case 'N': if (UTag == "NAME") { name = t.Data.Value; // was Substring( 0, 49 ) } else if (UTag == "NUMGUARDS") { numGuards = t.Data.ToUInt16(); } break; case 'o': case 'O': if (UTag == "OREPREF") { // string numPart; string oreName; OrePreference toPush = new OrePreference(); t.Data.Value = t.Data.Value.Trim(); oreName = t.Data.Value.Split(' ')[0]; toPush.OreData.Name = oreName; // toPush.oreIndex = Skills->FindOre( oreName ); // if( toPush.oreIndex != NULL ) // { // if( t.Data.sectionCount( " " ) == 0 ) // toPush.percentChance = 100 / Skills->GetNumberOfOres(); // else // toPush.percentChance = t.Data.section( " ", 1, 1 ).toByte(); orePreferences.Add(toPush); // orePreferences.push_back( toPush ); // orePrefLoaded = true; // } // else // Console.Error( 2, "Invalid ore preference in region %i as %s", regionNum, oreName.c_str() ); } break; case 'R': if (UTag == "RACE") { race = t.Data.ToUInt16(); } else if (UTag == "RECALL") { CanRecall = (t.Data.ToInt32() == 1); } else if (UTag == "RANDOMVALUE") { if (actgood > -1) { GoodData workWith = ((GoodData)goodList[actgood]); string [] tSplit = t.Data.Value.Split(' '); if (tSplit.Length != 1) { workWith.Rand1 = Conversion.ToInt32(tSplit[0]); workWith.Rand2 = Conversion.ToInt32(tSplit[1]); } else { workWith.Rand1 = t.Data.ToInt32(); workWith.Rand2 = workWith.Rand1; } if (workWith.Rand2 < workWith.Rand1) { // Console.Error( 2, " regions dfn -> You must write RANDOMVALUE NUM2[%i] greater than NUM1[%i].", goodList[actgood].rand2, goodList[actgood].rand1 ); workWith.Rand2 = workWith.Rand1 = 0; } } // else // Console.Error( 2, " regions dfn -> You must write RANDOMVALUE after GOOD <num>!" ); } break; case 's': case 'S': if (UTag == "SELLABLE") { if (actgood > -1) { ((GoodData)goodList[actgood]).SellValue = t.Data.ToInt32(); } // else // Console.Error( 2, " regions dfn -> You must write SELLABLE after GOOD <num>!" ); } else if (UTag == "SPAWN") { // UString sect = "PREDEFINED_SPAWN " + t.Data; // ScriptSection *predefSpawn = FileLookup->FindEntry( sect, spawn_def ); // if( predefSpawn == NULL ) // Console.Warning( 2, "Undefined region spawn %s, check your regions.scp and spawn.scp files", t.Data.c_str() ); // else // { // for( UI16 i = 0xFFFF; i > 0; --i ) // { // if( cwmWorldState->spawnRegions.find( i ) != cwmWorldState->spawnRegions.end() ) // { // CSpawnRegion *spawnReg = new CSpawnRegion( i ); // cwmWorldState->spawnRegions[i] = spawnReg; // if( spawnReg != NULL ) // { // spawnReg->SetX1( locations[locations.size() - 1].x1 ); // spawnReg->SetY1( locations[locations.size() - 1].y1 ); // spawnReg->SetX2( locations[locations.size() - 1].x2 ); // spawnReg->SetY2( locations[locations.size() - 1].y2 ); // spawnReg->Load( predefSpawn ); // } // break; // } // } // } } else if (UTag == "SCRIPT") { jsScript = t.Data.ToUInt16(); } break; case 'W': if (UTag == "WORLD") { worldNumber = t.Data.ToUInt08(); } break; case 'x': case 'X': if (UTag == "X1") { x1 = t.Data.ToInt16(); } else if (UTag == "X2") { x2 = t.Data.ToInt16(); } break; case 'y': case 'Y': if (UTag == "Y1") { y1 = t.Data.ToInt16(); } else if (UTag == "Y2") { y2 = t.Data.ToInt16(); locations.Add(new Box(x1, x2, y1, y2)); } break; } } }