public override void Update(GameTime gameTime) { if (TrileSetOld != LevelManager.TrileSet) { UpdateWidgets(); TrileSetOld = LevelManager.TrileSet; } ScrollOffset += ScrollMomentum; ScrollMomentum *= 0.5f; if (ScrollOffset < 0f) { ScrollOffset = 0f; } if (ScrollOffset > Width - Size.X) { ScrollOffset = Width - Size.X; } if (UpdateBounds) { Size.X = GraphicsDevice.Viewport.Width; Size.Y = 36f; } Width = 0f; for (int i = 0; i < Widgets.Count; i++) { Widgets[i].Update(gameTime); Widgets[i].Position.X = Width - ScrollOffset; Widgets[i].Position.Y = 0; Width += Widgets[i].Size.X + 4f; } }
public virtual void RebuildTriles(TrileSet trileSet, bool quick) { if (!quick) this.DestroyMaterializers(trileSet); if (trileSet != null) { foreach (Trile trile in Enumerable.Where<Trile>((IEnumerable<Trile>) trileSet.Triles.Values, (Func<Trile, bool>) (x => !this.trileMaterializers.ContainsKey(x)))) this.RebuildTrile(trile); this.TrilesMesh.Texture = (Dirtyable<Texture>) ((Texture) trileSet.TextureAtlas); } VertexGroup<VertexPositionNormalTextureInstance>.Deallocate(); }
public void DestroyMaterializers(TrileSet trileSet) { if (trileSet != null) { foreach (TrileMaterializer trileMaterializer in Enumerable.ToArray<TrileMaterializer>(Enumerable.Where<TrileMaterializer>((IEnumerable<TrileMaterializer>) this.trileMaterializers.Values, (Func<TrileMaterializer, bool>) (x => trileSet.Triles.ContainsValue(x.Trile))))) { trileMaterializer.Dispose(); this.trileMaterializers.Remove(trileMaterializer.Trile); } } else this.trileMaterializers.Clear(); }
public void Fill(MapTree.TreeFillContext context, MapNode parent, FaceOrientation origin) { if (this.Valid) { return; } TrileSet trileSet = (TrileSet)null; Level level; try { level = SdlSerializer.Deserialize <Level>(context.ContentRoot + "\\Levels\\" + this.LevelName + ".lvl.sdl"); if (level.TrileSetName != null) { if (!context.TrileSetCache.TryGetValue(level.TrileSetName, out trileSet)) { context.TrileSetCache.Add(level.TrileSetName, trileSet = SdlSerializer.Deserialize <TrileSet>(context.ContentRoot + "\\Trile Sets\\" + level.TrileSetName + ".ts.sdl")); } } } catch (Exception ex) { Console.WriteLine("Warning : Level " + this.LevelName + " could not be loaded because it has invalid markup. Skipping..."); this.Valid = false; return; } this.NodeType = level.NodeType; this.Conditions.ChestCount = Enumerable.Count <ArtObjectInstance>((IEnumerable <ArtObjectInstance>)level.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => x.ArtObjectName.IndexOf("treasure", StringComparison.InvariantCultureIgnoreCase) != -1)) / 2; this.Conditions.ScriptIds = Enumerable.ToList <int>(Enumerable.Select <Script, int>(Enumerable.Where <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(x => x.IsWinCondition)), (Func <Script, int>)(x => x.Id))); this.Conditions.SplitUpCount = Enumerable.Count <TrileInstance>(Enumerable.Union <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, Enumerable.SelectMany <TrileInstance, TrileInstance>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, (Func <TrileInstance, bool>)(x => x.Overlaps)), (Func <TrileInstance, IEnumerable <TrileInstance> >)(x => (IEnumerable <TrileInstance>)x.OverlappedTriles))), (Func <TrileInstance, bool>)(x => { if (x.TrileId >= 0) { return(trileSet[x.TrileId].ActorSettings.Type == ActorType.GoldenCube); } else { return(false); } })); this.Conditions.CubeShardCount = Enumerable.Count <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, (Func <TrileInstance, bool>)(x => { if (x.TrileId >= 0) { return(trileSet[x.TrileId].ActorSettings.Type == ActorType.CubeShard); } else { return(false); } })); this.Conditions.OtherCollectibleCount = Enumerable.Count <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, (Func <TrileInstance, bool>)(x => { if (x.TrileId >= 0 && ActorTypeExtensions.IsTreasure(trileSet[x.TrileId].ActorSettings.Type)) { return(trileSet[x.TrileId].ActorSettings.Type != ActorType.CubeShard); } else { return(false); } })) + Enumerable.Count <ArtObjectInstance>((IEnumerable <ArtObjectInstance>)level.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => x.ArtObjectName == "treasure_mapAO")); this.Conditions.LockedDoorCount = Enumerable.Count <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, (Func <TrileInstance, bool>)(x => { if (x.TrileId >= 0) { return(trileSet[x.TrileId].ActorSettings.Type == ActorType.Door); } else { return(false); } })); this.Conditions.UnlockedDoorCount = Enumerable.Count <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, (Func <TrileInstance, bool>)(x => { if (x.TrileId >= 0) { return(trileSet[x.TrileId].ActorSettings.Type == ActorType.UnlockedDoor); } else { return(false); } })); int num1 = Enumerable.Count <KeyValuePair <int, ArtObjectInstance> >((IEnumerable <KeyValuePair <int, ArtObjectInstance> >)level.ArtObjects, (Func <KeyValuePair <int, ArtObjectInstance>, bool>)(x => x.Value.ArtObjectName.IndexOf("fork", StringComparison.InvariantCultureIgnoreCase) != -1)); int num2 = Enumerable.Count <KeyValuePair <int, ArtObjectInstance> >((IEnumerable <KeyValuePair <int, ArtObjectInstance> >)level.ArtObjects, (Func <KeyValuePair <int, ArtObjectInstance>, bool>)(x => x.Value.ArtObjectName.IndexOf("qr", StringComparison.InvariantCultureIgnoreCase) != -1)); int num3 = Enumerable.Count <KeyValuePair <int, Volume> >((IEnumerable <KeyValuePair <int, Volume> >)level.Volumes, (Func <KeyValuePair <int, Volume>, bool>)(x => { if (x.Value.ActorSettings != null && x.Value.ActorSettings.CodePattern != null) { return(x.Value.ActorSettings.CodePattern.Length > 0); } else { return(false); } })); int num4 = this.LevelName == "OWL" ? 0 : Enumerable.Count <KeyValuePair <int, NpcInstance> >((IEnumerable <KeyValuePair <int, NpcInstance> >)level.NonPlayerCharacters, (Func <KeyValuePair <int, NpcInstance>, bool>)(x => x.Value.Name == "Owl")); int num5 = Enumerable.Count <KeyValuePair <int, ArtObjectInstance> >((IEnumerable <KeyValuePair <int, ArtObjectInstance> >)level.ArtObjects, (Func <KeyValuePair <int, ArtObjectInstance>, bool>)(x => { if (x.Value.ArtObjectName.Contains("BIT_DOOR")) { return(!x.Value.ArtObjectName.Contains("BROKEN")); } else { return(false); } })); int num6 = Enumerable.Count <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(s => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a => { if (a.Object.Type == "Level") { return(a.Operation == "ResolvePuzzle"); } else { return(false); } })))); int num7 = Enumerable.Contains <string>((IEnumerable <string>)MapNode.PuzzleLevels, this.LevelName) ? (this.LevelName == "CLOCK" ? 4 : 1) : 0; this.Conditions.SecretCount = num1 + num2 + num3 + num4 + num6 + num7 + num5; this.HasLesserGate = Enumerable.Any <ArtObjectInstance>((IEnumerable <ArtObjectInstance>)level.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => { if (x.ArtObjectName.IndexOf("lesser_gate", StringComparison.InvariantCultureIgnoreCase) != -1) { return(x.ArtObjectName.IndexOf("base", StringComparison.InvariantCultureIgnoreCase) == -1); } else { return(false); } })); this.HasWarpGate = Enumerable.Any <ArtObjectInstance>((IEnumerable <ArtObjectInstance>)level.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => { if (!(x.ArtObjectName == "GATE_GRAVEAO") && !(x.ArtObjectName == "GATEAO") && (!(x.ArtObjectName == "GATE_INDUSTRIALAO") && !(x.ArtObjectName == "GATE_SEWERAO")) && !(x.ArtObjectName == "ZU_GATEAO")) { return(x.ArtObjectName == "GRAVE_GATEAO"); } else { return(true); } })); foreach (Script script in level.Scripts.Values) { foreach (ScriptAction scriptAction in script.Actions) { if (scriptAction.Object.Type == "Level" && scriptAction.Operation.Contains("Level")) { MapNode.Connection connection = new MapNode.Connection(); bool flag = true; foreach (ScriptTrigger scriptTrigger in script.Triggers) { if (scriptTrigger.Object.Type == "Volume" && scriptTrigger.Event == "Enter" && scriptTrigger.Object.Identifier.HasValue) { int key = scriptTrigger.Object.Identifier.Value; Volume volume; if (!level.Volumes.TryGetValue(key, out volume)) { Console.WriteLine("Warning : A level-changing script links to a nonexistent volume in " + (object)this.LevelName + " (Volume Id #" + (string)(object)key + ")"); flag = false; break; } else if (volume.ActorSettings != null && volume.ActorSettings.IsSecretPassage) { flag = false; break; } else { connection.Face = Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>)volume.Orientations); break; } } } if (flag) { string key = scriptAction.Operation == "ReturnToLastLevel" ? parent.LevelName : scriptAction.Arguments[0]; if (!(key == "PYRAMID") && !(key == "CABIN_INTERIOR_A") && (!(key == "THRONE") || !(this.LevelName == "ZU_CITY_RUINS")) && (!(key == "ZU_CITY_RUINS") || !(this.LevelName == "THRONE"))) { MapNode mapNode; if (!context.LoadedNodes.TryGetValue(key, out mapNode)) { mapNode = new MapNode() { LevelName = key }; context.LoadedNodes.Add(key, mapNode); connection.Node = mapNode; if (connection.Node != parent) { if (parent != null && origin == connection.Face) { connection.Face = FezMath.GetOpposite(origin); } if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.UpLevels, key)) { connection.Face = FaceOrientation.Top; } else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.DownLevels, key)) { connection.Face = FaceOrientation.Down; } else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.OppositeLevels, key)) { connection.Face = FezMath.GetOpposite(connection.Face); } else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.BackLevels, key)) { connection.Face = FaceOrientation.Back; } else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.LeftLevels, key)) { connection.Face = FaceOrientation.Left; } else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.RightLevels, key)) { connection.Face = FaceOrientation.Right; } else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.FrontLevels, key)) { connection.Face = FaceOrientation.Front; } float num8; if (MapNode.OversizeLinks.TryGetValue(key, out num8)) { connection.BranchOversize = num8; } this.Connections.Add(connection); break; } else { break; } } else { break; } } } } } } this.Valid = true; foreach (MapNode.Connection connection in this.Connections) { connection.Node.Fill(context, this, connection.Face); } }