コード例 #1
0
ファイル: Compiler.cs プロジェクト: michaelcheers/Mpl2
        public Compiler(JSONTable settings)
        {
            this.settings = settings;

            this.operators = new List <Operator>();
            int precedence = 0;

            foreach (string s in settings.getArray("OPERATORS").asStrings())
            {
                foreach (char c in s)
                {
                    symbols.Add(c);
                }
                operators.Add(new Operator(s, precedence));
                precedence++;
            }

            string startPatternName = settings.getString("START", null);

            if (startPatternName != null)
            {
                startPattern = settings.getArray(startPatternName);
            }
            else
            {
                startPattern = settings.getArray("START", null);
            }
        }
コード例 #2
0
        public LevelScript(JSONTable template)
        {
            spawns = new List<List<MinionType>>();
            name = template.getString("name", "UNNAMED");
            JSONArray spawnTemplate = template.getArray("monsters");
            for (int Idx = 0; Idx < spawnTemplate.Length; ++Idx)
            {
                List<MinionType> thisTurn = new List<MinionType>();
                foreach (string minion in spawnTemplate.getArray(Idx).asStrings())
                {
                    MinionType type = MinionType.get(minion);
                    thisTurn.Add(type);
                }
                spawns.Add(thisTurn);
            }

            scenery = new List<KeyValuePair<MinionType, Point>>();
            foreach (JSONArray entry in template.getArray("scenery", JSONArray.empty).asJSONArrays())
            {
                scenery.Add(new KeyValuePair<MinionType,Point>(MinionType.get(entry.getString(0)), new Point(entry.getInt(1), entry.getInt(2))));
            }

            ongoingEffects = new List<KeyValuePair<Card, Point>>();
            foreach (JSONArray entry in template.getArray("ongoingEffects", JSONArray.empty).asJSONArrays())
            {
                ongoingEffects.Add(new KeyValuePair<Card, Point>(Card.get(entry.getString(0)), new Point(entry.getInt(1), entry.getInt(2))));
            }

            levelType = LevelType.get(template.getString("type"));

            string unlock = template.getString("unlock", null);
            if(unlock != null)
                unlocksCard = Card.get(unlock);
        }
コード例 #3
0
        public void Init(JSONTable template, ContentManager Content)
        {
            string artName = template.getString("art");

            art        = Content.Load <Texture2D>(artName);
            name       = template.getString("name", artName); // for now
            text       = template.getString("text", "").InsertLineBreaks(Game1.font, ConvergeUIObject.CardTooltipWidth - 15);
            textHeight = (int)Game1.font.MeasureString(text).Y;
            cardType   = 0;
            foreach (string name in template.getArray("cardType").asStrings())
            {
                cardType |= (ConvergeCardType)Enum.Parse(typeof(ConvergeCardType), name);
            }
            power     = template.getInt("power", 0);
            toughness = template.getInt("toughness", 0);
            string producesTemplate = template.getString("produces", "");

            if (producesTemplate != "")
            {
                produces = new ConvergeManaAmount(template.getString("produces"));
            }

            string costTemplate = template.getString("cost", "");

            if (costTemplate != "")
            {
                cost = new ConvergeManaAmount(costTemplate);
            }

            keywords = 0;
            foreach (string name in template.getArray("keywords", JSONArray.empty).asStrings())
            {
                keywords |= (ConvergeKeyword)Enum.Parse(typeof(ConvergeKeyword), name);
            }

            activatedAbilities = new List <ConvergeActivatedAbilitySpec>();
            foreach (JSONTable abilityTemplate in template.getArray("activated", JSONArray.empty).asJSONTables())
            {
                activatedAbilities.Add(new ConvergeActivatedAbilitySpec(abilityTemplate, Content));
            }

            triggeredAbilities = new List <ConvergeTriggeredAbilitySpec>();
            foreach (JSONTable abilityTemplate in template.getArray("triggered", JSONArray.empty).asJSONTables())
            {
                triggeredAbilities.Add(new ConvergeTriggeredAbilitySpec(abilityTemplate, Content));
            }

            if (template.hasKey("effect"))
            {
                actionEffect = ConvergeCommand.New(template.getArray("effect"), Content);
            }
            if (template.hasKey("target"))
            {
                actionTarget = ConvergeSelector.New(template.getProperty("target"));
            }
        }
コード例 #4
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;
        }
コード例 #5
0
 public ConvergeTriggeredAbilitySpec(JSONTable template, ContentManager Content)
 {
     triggerType    = (ConvergeTriggerType)Enum.Parse(typeof(ConvergeTriggerType), template.getString("trigger"));
     triggerPlayer  = ConvergeSelector.New(template.getProperty("triggerPlayer", null));
     triggerSubject = ConvergeSelector.New(template.getProperty("triggerSubject", null));
     triggerTarget  = ConvergeSelector.New(template.getProperty("triggerTarget", null));
     condition      = ConvergeSelector.New(template.getProperty("condition", null));
     effect         = ConvergeCommand.New(template.getArray("effect"), Content);
 }
コード例 #6
0
ファイル: Centrifuge.cs プロジェクト: LaurieCheers/SpeedChem
 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();
 }
コード例 #7
0
        public ConvergeActivatedAbilitySpec(JSONTable template, ContentManager Content)
        {
            frame      = Content.Load <Texture2D>(template.getString("frame", "abilityFrame"));
            icon       = Content.Load <Texture2D>(template.getString("icon"));
            text       = template.getString("text", "").InsertLineBreaks(Game1.font, ConvergeUIAbility.AbilityTooltipWidth - 15);
            textHeight = (int)Game1.font.MeasureString(text).Y;
            effect     = ConvergeCommand.New(template.getArray("effect"), Content);
            frameColor = template.getString("frameColor", "FFFFFF").toColor();

            if (template.hasKey("attackEffect"))
            {
                attackEffect = ConvergeCommand.New(template.getArray("attackEffect"), Content);
            }

            if (template.hasKey("target"))
            {
                target = ConvergeSelector.New(template.getProperty("target"));
            }

            manacost = new ConvergeManaAmount(template.getString("manaCost", ""));
            uses     = template.getInt("uses", 0);

            altCost = 0;
            foreach (string altcostString in template.getArray("altCost", JSONArray.empty).asStrings())
            {
                altCost |= (ConvergeAltCost)Enum.Parse(typeof(ConvergeAltCost), altcostString);
            }

            JSONArray zoneTemplate = template.getArray("activeZones", null);

            if (zoneTemplate == null)
            {
                activeZones = ConvergeZoneId.Attack | ConvergeZoneId.Defense | ConvergeZoneId.Home;
            }
            else
            {
                activeZones = 0;
                foreach (string zoneName in zoneTemplate.asStrings())
                {
                    activeZones |= (ConvergeZoneId)Enum.Parse(typeof(ConvergeZoneId), zoneName);
                }
            }
        }
コード例 #8
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();
 }
コード例 #9
0
 public Pattern getPattern(string name)
 {
     if (elements.ContainsKey(name))
     {
         return(elements[name]);
     }
     else
     {
         Pattern result = toPattern(scope.getArray(name));
         elements[name] = result;
         return(result);
     }
 }
コード例 #10
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();
        }
コード例 #11
0
 public LevelType(JSONTable template, ContentManager content)
 {
     spawnPoint = new List<Point>();
     foreach(JSONArray spawnTemplate in template.getArray("spawnPoint").asJSONArrays())
     {
         spawnPoint.Add(spawnTemplate.toPoint());
     }
     wizardPos = template.getArray("wizardPos").toPoint();
     levelSize = template.getArray("levelSize").toPoint();
     startingResources = ResourceAmount.createList(template.getJSON("startingResources"));
     floorTexture = content.Load<Texture2D>(template.getString("floorTexture"));
     entranceTexture = content.Load<Texture2D>(template.getString("entranceTexture"));
     pathTexture = content.Load<Texture2D>(template.getString("pathTexture"));
 }
コード例 #12
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();
 }
コード例 #13
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            data = new JSONTable("Content/data.json");

            mouseOverGlow = new RichImage(data.getJSON("mouseOverGlow"), Content);
            cardFrame     = new RichImage(data.getJSON("cardFrame"), Content);
            whiteFrame    = new RichImage(data.getJSON("whiteFrame"), Content);
            blueFrame     = new RichImage(data.getJSON("blueFrame"), Content);
            blackFrame    = new RichImage(data.getJSON("blackFrame"), Content);
            redFrame      = new RichImage(data.getJSON("redFrame"), Content);
            greenFrame    = new RichImage(data.getJSON("greenFrame"), Content);
            goldFrame     = new RichImage(data.getJSON("goldFrame"), Content);

            font             = Content.Load <SpriteFont>("Arial");
            shieldbg         = Content.Load <Texture2D>("shieldbg");
            powerbg          = Content.Load <Texture2D>("powerbg");
            woundbg          = Content.Load <Texture2D>("woundbg");
            tappedicon       = Content.Load <Texture2D>("tapped");
            abilityHighlight = Content.Load <Texture2D>("abilityHighlight");
            targetArrow      = Content.Load <Texture2D>("targetArrow");
            targetBeam       = Content.Load <Texture2D>("targetBeam");
            badTargetArrow   = Content.Load <Texture2D>("badTargetArrow");
            badTargetBeam    = Content.Load <Texture2D>("badTargetBeam");
            attackBeam       = Content.Load <Texture2D>("attackBeam");

            resourceTextures = new Texture2D[]
            {
                Content.Load <Texture2D>("total_resources"),
                Content.Load <Texture2D>("white_hats"),
                Content.Load <Texture2D>("blue_science"),
                Content.Load <Texture2D>("black_hats"),
                Content.Load <Texture2D>("red_munitions"),
                Content.Load <Texture2D>("green_seeds"),
            };

            ui = new UIContainer();

            self              = new ConvergePlayer(data.getJSON("self"), Content);
            opponent          = new ConvergePlayer(data.getJSON("opponent"), Content);
            self.opponent     = opponent;
            opponent.opponent = self;

            ui.Add(new ConvergeUIObject(self.homeBase));
            ui.Add(new ConvergeUIObject(opponent.homeBase));

            UIButtonStyle defaultStyle = UIButton.GetDefaultStyle(Content);

            endTurnButton = new UIButton("End Turn", new Rectangle(600, 400, 80, 40), defaultStyle, EndTurn_action, uiActions);
            ui.Add(endTurnButton);

            UIButton newHandButton = new UIButton("Cheat:New Hand", new Rectangle(600, 300, 80, 40), defaultStyle, NewHand_action, uiActions);

            ui.Add(newHandButton);

            JSONTable allCardsTemplate = data.getJSON("cards");

            foreach (string cardName in allCardsTemplate.Keys)
            {
                ConvergeCardSpec newSpec = new ConvergeCardSpec();
                ConvergeCardSpec.allCards.Add(cardName, newSpec);

                newSpec.Init(allCardsTemplate.getJSON(cardName), Content);
            }

            foreach (string cardName in data.getArray("mydeck").asStrings())
            {
                //ConvergeObject handCard =
                new ConvergeObject(ConvergeCardSpec.allCards[cardName], self.laboratory);
                //ui.Add(new ConvergeUIObject(handCard));
            }

            foreach (string cardName in data.getArray("oppdeck").asStrings())
            {
                //ConvergeObject handCard =
                new ConvergeObject(ConvergeCardSpec.allCards[cardName], opponent.laboratory);
                //ui.Add(new ConvergeUIObject(handCard));
            }


            UpdateZoneChanges();

            self.BeginGame();
            opponent.BeginGame();

            activePlayer = self;
            self.BeginMyTurn();
            opponent.numLandsPlayed = 1; // can't play a land in your first response phase
        }
コード例 #14
0
 public MinionType(JSONTable template, ContentManager content)
     : base(template, content)
 {
     upkeep = ResourceAmount.createList(template.getJSON("upkeep", null));
     attackCost = ResourceAmount.createList(template.getJSON("attackCost", null));
     whenDies = Effect_Base.create(template.getArray("whenDies", null));
     awakenTypeName = template.getString("awakenType", null);
     string onFireTextureName = template.getString("onFireTexture", null);
     if (onFireTextureName != null)
         onFireTexture = content.Load<Texture2D>(onFireTextureName);
     stats.maxHealth = template.getInt("health", 1);
     stats.health = stats.maxHealth;
     stats.attack = template.getInt("attack", 0);
     stats.move = template.getInt("move", 1);
     stats.armor = template.getInt("armor", 0);
     Enum.TryParse<Range>(template.getString("range", "adjacent"), out stats.range);
     foreach (string abilityName in template.getArray("keywords", JSONArray.empty).asStrings())
     {
         Keyword keyword;
         bool ok = Enum.TryParse<Keyword>(abilityName, out keyword);
         Debug.Assert(ok);
         stats.keywords |= keyword;
     }
     spells = template.getString("spells", null);
     description = template.getString("description", "Just a guy");
 }
コード例 #15
0
        public PermanentType(JSONTable template, ContentManager content)
        {
            name = template.getString("name");

            string textureName = template.getString("texture");
            texture = (textureName != null) ? content.Load<Texture2D>(textureName) : null;

            upkeep = ResourceAmount.createList(template.getJSON("upkeep", null));
            ongoing = Effect_Base.create(template.getArray("ongoing", null));
            ongoing_late = Effect_Base.create(template.getArray("ongoing_late", null));
            triggers = TriggeredAbility.createList(template.getArray("triggers", null));
        }
コード例 #16
0
ファイル: CityLevel.cs プロジェクト: LaurieCheers/SpeedChem
        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;
                            }
                        }
                    }
                }
            }
        }
コード例 #17
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();
 }