Beispiel #1
0
 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;
 }
Beispiel #2
0
 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;
 }
Beispiel #3
0
        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 + "\"");
            }
        }
Beispiel #4
0
 public void Update(CityLevel metaGame)
 {
     if (Test(metaGame))
     {
         Unlock(metaGame);
     }
 }
Beispiel #5
0
 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();
 }
Beispiel #6
0
 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();
 }
Beispiel #7
0
 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();
 }
Beispiel #8
0
 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();
 }
Beispiel #9
0
 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();
 }
Beispiel #10
0
 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();
 }
Beispiel #11
0
 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();
 }
Beispiel #12
0
 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();
 }
Beispiel #13
0
        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();
        }
Beispiel #14
0
 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();
 }
Beispiel #15
0
 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();
 }
Beispiel #16
0
 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();
 }
Beispiel #17
0
 public void ViewCity(CityLevel cityLevel)
 {
     cityLevel.InitUI();
     cityLevel.isNew    = false;
     this.currentScreen = cityLevel;
 }
Beispiel #18
0
 public abstract bool Test(CityLevel metaGame);
Beispiel #19
0
 public ChemicalSilo(CityLevel cityLevel, Vector2 pos) : base(cityLevel, TextureCache.silo, pos, TextureCache.silo.Size())
 {
     Init();
 }
Beispiel #20
0
 public override bool Test(CityLevel metaGame)
 {
     return(watching.didOutput);
 }
Beispiel #21
0
 public ChemicalFactory(CityLevel cityLevel, Vector2 pos, bool movable, bool isBigFactory) : base(cityLevel, TextureCache.processor, pos)
 {
     this.canDrag      = movable;
     this.isBigFactory = isBigFactory;
     InitPipes();
 }
Beispiel #22
0
 public WorldObject_City(CityLevel cityLevel) : base(TextureCache.city, cityLevel.pos)
 {
     this.cityLevel = cityLevel;
 }
Beispiel #23
0
 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();
 }
Beispiel #24
0
 public Centrifuge(CityLevel cityLevel, Vector2 pos) : base(cityLevel, TextureCache.centrifuge, pos)
 {
     Init();
 }
Beispiel #25
0
 public CrystalOutbox(CityLevel cityLevel, ChemicalSignature signature, Vector2 pos) : base(cityLevel, TextureCache.depot, pos, TextureCache.depot.Size())
 {
     this.signature = signature;
     Init();
 }
Beispiel #26
0
        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();
                    }
                }
            }
        }
Beispiel #27
0
 public override bool Test(CityLevel metaGame)
 {
     return(Game1.instance.inventory.money >= minMoney);
 }