예제 #1
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();
 }
예제 #2
0
        public ConvergeZone(JSONTable template, ConvergePlayer owner, ConvergeZoneId zoneId)
        {
            this.owner      = owner;
            this.zoneId     = zoneId;
            this.basePos    = template.getVector2("basePos");
            this.slotOffset = template.getVector2("slotOffset");
            this.inPlay     = template.getBool("inPlay", false);
            this.isHidden   = template.getBool("isHidden", false);
            Vector2 topLeft     = template.getVector2("topLeft");
            Vector2 bottomRight = template.getVector2("bottomRight");

            bounds = new Rectangle(topLeft.ToPoint(), (bottomRight - topLeft).ToPoint());
        }
예제 #3
0
        public ConvergePlayer(JSONTable template, ContentManager Content)
        {
            this.home         = new ConvergeZone(template.getJSON("home"), this, ConvergeZoneId.Home);
            this.resourceZone = new ConvergeZone(template.getJSON("resources"), this, ConvergeZoneId.Resources);
            this.attack       = new ConvergeZone(template.getJSON("attack"), this, ConvergeZoneId.Attack);
            this.defense      = new ConvergeZone(template.getJSON("defense"), this, ConvergeZoneId.Defense);
            this.hand         = new ConvergeZone(template.getJSON("hand"), this, ConvergeZoneId.Hand);
            this.homeBase     = new ConvergeObject(new ConvergeCardSpec(template.getJSON("homebase"), Content), home);
            this.discardPile  = new ConvergeZone(template.getJSON("discardPile"), this, ConvergeZoneId.DiscardPile);
            this.laboratory   = new ConvergeZone(template.getJSON("laboratory"), this, ConvergeZoneId.Laboratory);

            zones = new Dictionary <ConvergeZoneId, ConvergeZone>()
            {
                { ConvergeZoneId.Home, home },
                { ConvergeZoneId.Resources, resourceZone },
                { ConvergeZoneId.Attack, attack },
                { ConvergeZoneId.Defense, defense },
                { ConvergeZoneId.Hand, hand },
                { ConvergeZoneId.DiscardPile, discardPile },
                { ConvergeZoneId.Laboratory, laboratory },
            };

            this.life     = template.getInt("startingLife");
            this.faceLeft = template.getBool("faceLeft", false);
        }
예제 #4
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();
 }
예제 #5
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();
 }
예제 #6
0
        public Card(JSONTable template, ContentManager content)
        {
            name = template.getString("name");
            cost = ResourceAmount.createList(template.getJSON("cost", null));
            effect = Effect_Base.create(template.getArray("effect", null));
            if (template.hasKey("ongoing") || template.hasKey("triggers"))
            {
                ongoingType = new PermanentType(template, content);
            }
            image = content.Load<Texture2D>(template.getString("texture"));
            smallFrameTexture = content.Load<Texture2D>("square");
            Enum.TryParse<TargetType>(template.getString("target", "none"), out targetType);
            frameTexture = content.Load<Texture2D>("cardframe_large");
            description = DragonGfx.Tooltip.StringToLines(template.getString("description", ""), Game1.font, 100);
            upgradeCost = ResourceAmount.createList(template.getJSON("upgradeCost", null));
            targetTest = TriggerItemTest.create(template.getArray("targetTest", null));
            spellSet = template.getString("spellSet", null);

            foreach (JSONTable upgradeTemplate in template.getArray("upgrades", JSONArray.empty).asJSONTables())
            {
                if(upgrades == null)
                    upgrades = new List<Card>();

                upgrades.Add(new Card(upgradeTemplate, content));
            }

            switch (template.getString("type", null))
            {
                case "special":
                    frameColor = new Color(235, 200, 255);
                    break;
                case "minion":
                    frameColor = new Color(200, 255, 200);
                    break;
                case "production":
                    frameColor = new Color(255, 220, 190);
                    break;
                case "modifier":
                    frameColor = new Color(255, 190, 200);
                    break;
                default:
                    frameColor = Color.White;
                    break;
            }

            string id = template.getString("id", null);
            if (id != null)
            {
                cardsById.Add(id, this);
            }

            defaultUnlocked = template.getBool("unlocked", false);
            unlocked = defaultUnlocked;
        }
예제 #7
0
        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;
                            }
                        }
                    }
                }
            }
        }