コード例 #1
0
        public void InitFromJSON(String text)
        {
            JObject testJson = JObject.Parse(text);

            attackSpeed = (double)testJson["attackSpeed"];
            moveSpeed   = (double)testJson["moveSpeed"];
            spriteImage = (string)testJson["spriteImage"];
            attackPwr   = (int)testJson["attackPwr"];
            maxHealth   = (int)testJson["maxHealth"];
            attackRange = (int)testJson["attackRange"];
            aggroRange  = (int)testJson["aggroRange"];
            colorName   = (string)testJson["color"];
            if (testJson.ContainsKey("armor"))
            {
                armor = (double)testJson["armor"];
            }
            else
            {
                armor = 0;
            }

            /*
             * if (testJson.ContainsKey("fillColor"))
             * {
             *  fillColorName = (string)testJson["fillColor"];
             *  drawColor = ConvertStringToColor(fillColorName);
             * }
             */
            if (testJson.ContainsKey("sprite"))
            {
                string spriteName = (string)testJson["sprite"];
                if (testJson.ContainsKey("animations"))
                {
                    animManager = new AnimationManager(spriteName, testJson);
                }
                else
                {
                    animManager = new AnimationManager(spriteName);
                }
                this.AddChild(animManager);
                animManager.Play("move");
            }
            if (testJson.ContainsKey("abilities"))
            {
                JArray abilities = (JArray)testJson["abilities"];

                foreach (JObject ability in abilities)
                {
                    string  abilityName     = (string)ability["actionName"];
                    JObject compileTimeArgs = (JObject)ability["compileTimeArgs"];
                    CardAct tempAction      = GodClass.GetAction(abilityName, compileTimeArgs);
                    this.abilityList.Add(tempAction);
                }
            }
        }
コード例 #2
0
        public void LogicInit(String text)
        {
            JObject cardJson = JObject.Parse(text);

            cardTitle = (string)cardJson["cardTitle"];
            cardText  = (string)cardJson["cardText"];
            cardImage = (string)cardJson["cardImage"];
            cardCost  = (int)cardJson["cardCost"];
            if (cardJson.ContainsKey("cardTiming"))
            {
                cardTiming = ((string)cardJson["cardTiming"]).ToLower() == "immediate" ? CardTimeOpts.Immediate : CardTimeOpts.Queued;
            }

            JArray cardActions = (JArray)cardJson["cardActions"];

            foreach (JObject cardAction in cardActions)
            {
                string  cardName        = (string)cardAction["actionName"];
                JObject compileTimeArgs = (JObject)cardAction["compileTimeArgs"];
                CardAct tempAction      = GodClass.GetAction(cardName, compileTimeArgs);
                this.cardActionList.Add(tempAction);
            }
        }