public CityObject(CityLevel cityLevel, Texture2D texture, Vector2 pos, Vector2 size) { this.cityLevel = cityLevel; this.bounds = new Vectangle(ClampToShelf(pos), size); this.sprite = new SpriteObject(texture, bounds.Origin, size); sprite.layerDepth = 0.0f; }
public void Unlock(CityLevel metaGame) { if (objectsUnlocked != null) { foreach (CityObject obj in objectsUnlocked) { metaGame.AddObject(obj); } } if (uiUnlocked != null) { foreach (UIElement ui in uiUnlocked) { metaGame.AddUI(ui); } } if (weapons != null) { foreach (Weapon w in weapons) { Game1.instance.inventory.UnlockWeapon(w); } } objectsUnlocked = null; uiUnlocked = null; }
public static CityObject FromTemplate(CityLevel cityLevel, JSONTable template) { string type = template.getString("type"); switch (type) { case "inbox": return(new ChemicalInbox(cityLevel, template)); case "outbox": return(new ChemicalOutbox(cityLevel, template)); case "factory": return(new ChemicalFactory(cityLevel, template)); case "silo": return(new ChemicalSilo(cityLevel, template)); case "crystalOutbox": return(new CrystalOutbox(cityLevel, template)); case "buildingSite": return(new BuildingSite(cityLevel, template)); case "plinth": return(new WeaponPlinth(cityLevel, template)); case "blueprint": return(new Blueprint(cityLevel, template)); default: throw new ArgumentException("Unknown CityObject type \"" + type + "\""); } }
public void Update(CityLevel metaGame) { if (Test(metaGame)) { Unlock(metaGame); } }
public Blueprint(CityLevel cityLevel, string unlocks, int price, Vector2 pos) : base(cityLevel, TextureCache.inbox, pos, TextureCache.inbox.Size()) { this.unlocks = unlocks; this.price = price; this.canDrag = false; Init(); }
public WeaponPlinth(CityLevel cityLevel, Weapon weapon, int price, Vector2 pos) : base(cityLevel, TextureCache.inbox, pos, TextureCache.inbox.Size()) { this.weapon = weapon; this.price = price; this.canDrag = false; Init(); }
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 WeaponPlinth(CityLevel cityLevel, JSONTable template) : base(cityLevel, TextureCache.plinth, template.getVector2("pos"), TextureCache.plinth.Size()) { this.weapon = Game1.instance.inventory.unlockableWeapons[template.getString("weapon")]; this.price = template.getInt("price", 0); this.canDrag = false; this.crystals = template.getInt("crystals", 0); Init(); }
public Blueprint(CityLevel cityLevel, JSONTable template) : base(cityLevel, TextureCache.blueprint, template.getVector2("pos"), TextureCache.blueprint.Size()) { this.unlocks = template.getString("unlocks"); this.price = template.getInt("price", 0); this.label = template.getString("label"); this.canDrag = false; Init(); }
public ChemicalFactory(CityLevel cityLevel, JSONTable template) : base( cityLevel, template.getBool("movable", true)? TextureCache.processor : TextureCache.processor_rusty, template.getVector2("pos") ) { this.canDrag = template.getBool("movable", true); this.isBigFactory = template.getBool("bigFactory", false); InitPipes(); }
public Centrifuge(CityLevel cityLevel, JSONTable template) : base( cityLevel, TextureCache.centrifuge, template.getVector2("pos") ) { this.inputSignature = new ChemicalSignature(template.getArray("chemical")); canDrag = template.getBool("movable", true); Init(); }
public ChemicalSilo(CityLevel cityLevel, JSONTable template) : base( cityLevel, TextureCache.silo, template.getVector2("pos"), TextureCache.silo.Size() ) { this.signature = new ChemicalSignature(template.getArray("chemical")); canDrag = template.getBool("movable", true); Init(); }
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 ChemicalOutbox(CityLevel cityLevel, ChemicalSignature signature, int price, Vector2 pos) : base(cityLevel, TextureCache.outbox, pos, TextureCache.outbox.Size()) { this.signature = signature; this.price = price; Init(); }
public ChemicalOutbox(CityLevel cityLevel, JSONTable template) : base(cityLevel, TextureCache.outbox, template.getVector2("pos"), TextureCache.outbox.Size()) { this.signature = new ChemicalSignature(template.getArray("chemical")); this.price = template.getInt("price"); Init(); }
public CrystalOutbox(CityLevel cityLevel, JSONTable template) : base(cityLevel, TextureCache.depot, template.getVector2("pos"), TextureCache.depot.Size()) { this.signature = new ChemicalSignature(template.getArray("chemical")); this.numCrystals = template.getInt("crystals", 1); Init(); }
public void ViewCity(CityLevel cityLevel) { cityLevel.InitUI(); cityLevel.isNew = false; this.currentScreen = cityLevel; }
public abstract bool Test(CityLevel metaGame);
public ChemicalSilo(CityLevel cityLevel, Vector2 pos) : base(cityLevel, TextureCache.silo, pos, TextureCache.silo.Size()) { Init(); }
public override bool Test(CityLevel metaGame) { return(watching.didOutput); }
public ChemicalFactory(CityLevel cityLevel, Vector2 pos, bool movable, bool isBigFactory) : base(cityLevel, TextureCache.processor, pos) { this.canDrag = movable; this.isBigFactory = isBigFactory; InitPipes(); }
public WorldObject_City(CityLevel cityLevel) : base(TextureCache.city, cityLevel.pos) { this.cityLevel = cityLevel; }
public ChemicalSilo(CityLevel cityLevel, ChemicalSignature signature, int amount, Vector2 pos) : base(cityLevel, TextureCache.silo, pos, TextureCache.silo.Size()) { this.signature = signature; this.amount = amount; Init(); }
public Centrifuge(CityLevel cityLevel, Vector2 pos) : base(cityLevel, TextureCache.centrifuge, pos) { Init(); }
public CrystalOutbox(CityLevel cityLevel, ChemicalSignature signature, Vector2 pos) : base(cityLevel, TextureCache.depot, pos, TextureCache.depot.Size()) { this.signature = signature; 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 override bool Test(CityLevel metaGame) { return(Game1.instance.inventory.money >= minMoney); }