public UnlockRule(CityObject obj) { this.objectsUnlocked = new List <CityObject>() { obj }; }
public OutputPipe(CityObject source, Vector2 offset) { this.source = source; this.sourceOffset = offset; this.movable = true; ShowDisconnected(); }
public PipeSocket(CityObject parent, Vector2 offset, Vector2 offset2) { this.parent = parent; this.offset = offset; // TODO: make two-socket objects work this.maxConnections = 2; }
public BuildingSite(CityLevel level, int price, CityObject spawn) : base(level, TextureCache.building_site, spawn.bounds.XY, TextureCache.building_site.Size()) { this.spawn = spawn; this.price = price; this.canDrag = false; Init(); }
public void RemoveObjectDeferred(CityObject obj) { if (nextObjects == null) { nextObjects = objects.ToList(); } nextObjects.Remove(obj); }
public void AddObjectDeferred(CityObject obj) { if (nextObjects == null) { nextObjects = objects.ToList(); } nextObjects.Add(obj); }
public BuildingSite(CityLevel cityLevel, JSONTable template) : base(cityLevel, TextureCache.building_site, template.getVector2("pos"), TextureCache.building_site.Size()) { this.price = template.getInt("price"); this.canDrag = false; JSONArray signatureTemplate = template.getArray("chemical", null); if (signatureTemplate != null) { this.signature = new ChemicalSignature(signatureTemplate); this.spawn = new ChemicalInbox(cityLevel, signature, 0, bounds.XY); } else { this.spawn = CityObject.FromTemplate(cityLevel, template.getJSON("built")); } Init(); }
public void Update(CityLevel metaGame, CityUIBlackboard blackboard) { if (!movable) { return; } hovering = blackboard.inputState.hoveringElement == this;// cachedHandleRect.Contains(blackboard.inputState.MousePos); if (hovering && blackboard.inputState.WasMouseLeftJustPressed()) { dragging = true; blackboard.selectedObject = null; } if (cachedOffset.Y < 0) { ConnectTo(null); } if (dragging) { ConnectTo(null); CityObject overObject = metaGame.GetObjectAt(blackboard.inputState.MousePos); PipeSocket overSocket = null; if (overObject != null) { overSocket = overObject.GetNearestSocket(blackboard.inputState.MousePos); if (overSocket != null && overSocket.pos.Y < sourcePos.Y) { overSocket = null; } } Vector2 clampedPos = blackboard.inputState.MousePos; if (clampedPos.Y <= sourcePos.Y) { clampedPos.Y = sourcePos.Y; } if (blackboard.inputState.mouseLeft.isDown) { if (overSocket != null) { UpdateForTargetPos(overSocket.pos); } else { UpdateForTargetPos(clampedPos); } } else { dragging = false; if (overSocket != null && overSocket.parent != source) { ConnectTo(overSocket); } else { ShowDisconnected(); } } } }
public PipeSocket(CityObject parent, Vector2 offset, int maxConnections) { this.parent = parent; this.offset = offset; this.maxConnections = maxConnections; }
public UnlockRule_Output(CityObject watching, List <CityObject> objects) : base(objects) { this.watching = watching; }
public UnlockRule_Money(int minMoney, CityObject obj) : base(obj) { this.minMoney = minMoney; }
public UnlockRule_Output(CityObject watching, List <UIElement> ui) : base(ui) { this.watching = watching; }
public UnlockRule_Output(CityObject watching, CityObject obj) : base(obj) { this.watching = watching; }
public UnlockRule_Output(CityObject watching, List <UIElement> ui, List <CityObject> objects, List <Weapon> weapons) : base(ui, objects, weapons) { this.watching = watching; }
public void RemoveObject(CityObject obj) { objects.Remove(obj); }
public CityLevel(JSONTable template) { this.name = template.getString("name"); this.pos = template.getVector2("pos"); this.price = template.getInt("price"); this.isTutorial = template.getBool("isTutorial", false); blackboard.cityLevel = this; InitUI(); isNew = true; Dictionary <string, CityObject> objectsByName = new Dictionary <string, CityObject>(); JSONTable unlockTable = template.getJSON("unlocks", null); if (unlockTable != null) { foreach (string unlockName in unlockTable.Keys) { JSONTable unlockTemplates = unlockTable.getJSON(unlockName); List <CityObject> newObjects = new List <CityObject>(); List <UIElement> newUI = new List <UIElement>(); List <Weapon> newWeapons = new List <Weapon>(); foreach (string objectName in unlockTemplates.Keys) { /*if(unlockableUI.ContainsKey(objectName)) * { * newUI.Add(unlockableUI[objectName]); * } * else*/ if (Game1.instance.inventory.unlockableWeapons.ContainsKey(objectName)) { newWeapons.Add(Game1.instance.inventory.unlockableWeapons[objectName]); } else { CityObject newObj = CityObject.FromTemplate(this, unlockTemplates.getJSON(objectName)); objectsByName[objectName] = newObj; newObjects.Add(newObj); } } if (unlockName == "start") { foreach (CityObject obj in newObjects) { objects.Add(obj); //tutorial hack if (obj is ChemicalFactory) { blackboard.selectedObject = obj; } } foreach (UIElement element in newUI) { ui.Add(element); } foreach (Weapon w in newWeapons) { Game1.instance.inventory.UnlockWeapon(w); } } else { unlockRules.Add(new UnlockRule_Output(objectsByName[unlockName], newUI, newObjects, newWeapons)); } } // postprocess to add pipes foreach (string unlockName in unlockTable.Keys) { JSONTable unlockTemplates = unlockTable.getJSON(unlockName); foreach (string objectName in unlockTemplates.Keys) { //if (unlockableUI.ContainsKey(objectName) || if (Game1.instance.inventory.unlockableWeapons.ContainsKey(objectName)) { continue; } JSONTable objectTemplate = unlockTemplates.getJSON(objectName); JSONArray pipeTargets = objectTemplate.getArray("pipes", null); if (pipeTargets != null) { foreach (string pipeTarget in pipeTargets.asStrings()) { CityObject sourceObject = objectsByName[objectName]; CityObject targetObject = objectsByName[pipeTarget]; OutputPipe pipe = sourceObject.pipes.Last(); pipe.ConnectTo(targetObject.GetNearestSocket(targetObject.bounds.XY)); pipe.movable = false; } } } } } }
public void AddObject(CityObject obj) { objects.Add(obj); }