Ejemplo n.º 1
0
        /// <summary>
        /// Indicates to the game mode that it is activated.
        /// </summary>
        public override void Activate()
        {
            // Call the base
            base.Activate();

            // Figure out the penalty
            StagePenaltyInfo info = StagePenaltyInfo.Random;

            // If we are null, then just continue on
            if (info == null)
            {
                Timeout();
                return;
            }

            // Set the value
            Subtitle = "New Stage";
            Title    = info.Title;
            Text     = String.Format(info.Description,
                                     Game.State.SecondsPerTurn,
                                     Game.State.BugCount,
                                     Game.State.GrabCost);
            ChestVisible = false;

            // Create the block
            block = AssetLoader.Instance.CreateSprite(info.BlockKey);

            // Set up our timeout
            CountingDown     = true;
            SecondsRemaining = Constants.NewStageDisplay;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the stage penalty descriptions from the given XML
        /// file and sets up the internal structures.
        /// </summary>
        static StagePenaltyInfo()
        {
            try
            {
                // Get the manifest string
                Stream stream = typeof(StagePenaltyInfo).Assembly
                                .GetManifestResourceStream("CuteGod.penalties.xml");

                // Create an XML reader out of it
                XmlTextReader    xml  = new XmlTextReader(stream);
                StagePenaltyInfo sp   = null;
                StagePenaltyType type = StagePenaltyType.Maximum;

                // Loop through the file
                while (xml.Read())
                {
                    // See if we finished a node
                    if (xml.NodeType == XmlNodeType.EndElement &&
                        xml.LocalName == "penalty")
                    {
                        hash[type] = sp;
                        sp         = null;
                    }

                    // Ignore all but start elements
                    if (xml.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    // Check for name
                    if (xml.LocalName == "penalty")
                    {
                        sp   = new StagePenaltyInfo();
                        type = (StagePenaltyType)Enum
                               .Parse(typeof(StagePenaltyType), xml["type"]);
                        sp.type = type;
                    }
                    else if (xml.LocalName == "title")
                    {
                        sp.Title = xml.ReadString();
                    }
                    else if (xml.LocalName == "block")
                    {
                        sp.BlockKey = xml.ReadString();
                    }
                    else if (xml.LocalName == "description")
                    {
                        sp.Description = xml.ReadString();
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error(typeof(StagePenaltyInfo),
                             "Cannot load penalties: {0}", e.Message);
                throw e;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads the stage penalty descriptions from the given XML
        /// file and sets up the internal structures.
        /// </summary>
        static StagePenaltyInfo()
        {
            try
            {
                // Get the manifest string
                Stream stream = typeof(StagePenaltyInfo).Assembly
                    .GetManifestResourceStream("CuteGod.penalties.xml");

                // Create an XML reader out of it
                XmlTextReader xml = new XmlTextReader(stream);
                StagePenaltyInfo sp = null;
                StagePenaltyType type = StagePenaltyType.Maximum;

                // Loop through the file
                while (xml.Read())
                {
                    // See if we finished a node
                    if (xml.NodeType == XmlNodeType.EndElement &&
                        xml.LocalName == "penalty")
                    {
                        hash[type] = sp;
                        sp = null;
                    }

                    // Ignore all but start elements
                    if (xml.NodeType != XmlNodeType.Element)
                        continue;

                    // Check for name
                    if (xml.LocalName == "penalty")
                    {
                        sp = new StagePenaltyInfo();
                        type = (StagePenaltyType) Enum
                            .Parse(typeof(StagePenaltyType), xml["type"]);
                        sp.type = type;
                    }
                    else if (xml.LocalName == "title")
                        sp.Title = xml.ReadString();
                    else if (xml.LocalName == "block")
                        sp.BlockKey = xml.ReadString();
                    else if (xml.LocalName == "description")
                        sp.Description = xml.ReadString();
                }
            }
            catch (Exception e)
            {
                Logger.Error(typeof(StagePenaltyInfo),
                    "Cannot load penalties: {0}", e.Message);
                throw e;
            }
        }