Exemplo n.º 1
0
        /// <summary>
        /// Creates Fraction Mortality Prior to Spawn DataTable with non-null values.
        /// </summary>
        /// <param name="yearSeq">Array of subsequent years in the projection</param>
        public void CreateFallbackTSpawnTable(string[] yearSeq)
        {
            if (TSpawn != null)
            {
                //Clear out data
                TSpawn.Reset();
            }

            DataTable fallbackTSpawn = new DataTable();

            if (TimeVarying)
            {
                for (int icol = 0; icol < yearSeq.Count(); icol++)
                {
                    _ = fallbackTSpawn.Columns.Add(yearSeq[icol]);
                }
            }
            else
            {
                _ = fallbackTSpawn.Columns.Add("All Years");
            }

            //Add the Fraction Prior to Spawn
            _ = fallbackTSpawn.Rows.Add();
            _ = fallbackTSpawn.Rows.Add();

            TSpawn = Extensions.FillDBNullCellsWithZero(fallbackTSpawn);
        }
Exemplo n.º 2
0
        public void Play(bool first)
        {
            timer1.Enabled = false;

            iAnimationStep = 0;
            hwndWindow     = (IntPtr)0;

            TSpawn spawn = Animations.GetRandomSpawn();

            Top     = spawn.Start.Y.GetValue();
            Left    = spawn.Start.X.GetValue();
            Visible = true;
            SetNewAnimation(spawn.Next);

            timer1.Enabled = true;
        }
Exemplo n.º 3
0
        public void loadAnimations(Animations animations)
        {
            XmlNodeList nodes = xmlDoc.SelectNodes("//pet:animations/pet:animation", xmlNS);

            foreach (XmlNode node in nodes)
            {
                int        id  = int.Parse(node.Attributes["id"].InnerText);
                TAnimation ani = animations.AddAnimation(id, id.ToString());
                ani.Border  = false;
                ani.Gravity = false;
                foreach (XmlNode node2 in node.ChildNodes)
                {
                    switch (node2.Name)
                    {
                    case "name":
                        ani.Name = node2.InnerText;
                        switch (ani.Name)
                        {
                        case "fall": animations.AnimationFall = id; break;

                        case "drag": animations.AnimationDrag = id; break;

                        case "kill": animations.AnimationKill = id; break;

                        case "sync": animations.AnimationSync = id; break;
                        }
                        break;

                    case "start":
                        ani.Start.X.Compute        = node2.SelectSingleNode(".//pet:x", xmlNS).InnerText;
                        ani.Start.X.Random         = (ani.Start.X.Compute.IndexOf("random") >= 0);
                        ani.Start.X.Value          = parseValue(ani.Start.X.Compute);
                        ani.Start.Y.Compute        = node2.SelectSingleNode(".//pet:y", xmlNS).InnerText;
                        ani.Start.Y.Random         = (ani.Start.Y.Compute.IndexOf("random") >= 0);
                        ani.Start.Y.Value          = parseValue(ani.Start.Y.Compute);
                        ani.Start.Interval.Compute = node2.SelectSingleNode(".//pet:interval", xmlNS).InnerText;
                        ani.Start.Interval.Random  = (ani.Start.Interval.Compute.IndexOf("random") >= 0);
                        ani.Start.Interval.Value   = parseValue(ani.Start.Interval.Compute);
                        break;

                    case "end":
                        ani.End.X.Compute        = node2.SelectSingleNode(".//pet:x", xmlNS).InnerText;
                        ani.End.X.Random         = (ani.End.X.Compute.IndexOf("random") >= 0);
                        ani.End.X.Value          = parseValue(ani.End.X.Compute);
                        ani.End.Y.Compute        = node2.SelectSingleNode(".//pet:y", xmlNS).InnerText;
                        ani.End.Y.Random         = (ani.End.Y.Compute.IndexOf("random") >= 0);
                        ani.End.Y.Value          = parseValue(ani.End.Y.Compute);
                        ani.End.Interval.Compute = node2.SelectSingleNode(".//pet:interval", xmlNS).InnerText;
                        ani.End.Interval.Random  = (ani.End.Interval.Compute.IndexOf("random") >= 0);
                        ani.End.Interval.Value   = parseValue(ani.End.Interval.Compute);
                        break;

                    case "sequence":
                        ani.Sequence.RepeatFrom     = int.Parse(node2.Attributes["repeatfrom"].InnerText);
                        ani.Sequence.Repeat.Compute = node2.Attributes["repeat"].InnerText;
                        if (node2.SelectSingleNode(".//pet:action", xmlNS) != null)
                        {
                            ani.Sequence.Action = node2.SelectSingleNode(".//pet:action", xmlNS).InnerText;
                        }
                        ani.Sequence.Repeat.Random = (ani.Sequence.Repeat.Compute.IndexOf("random") >= 0);
                        ani.Sequence.Repeat.Value  = parseValue(ani.Sequence.Repeat.Compute);
                        foreach (XmlNode node3 in node2.SelectNodes(".//pet:frame", xmlNS))
                        {
                            ani.Sequence.Frames.Add(int.Parse(node3.InnerText));
                        }
                        if (ani.Sequence.RepeatFrom > 0)
                        {
                            ani.Sequence.TotalSteps = ani.Sequence.Frames.Count + (ani.Sequence.Frames.Count - ani.Sequence.RepeatFrom - 1) * ani.Sequence.Repeat.Value;
                        }
                        else
                        {
                            ani.Sequence.TotalSteps = ani.Sequence.Frames.Count + ani.Sequence.Frames.Count * ani.Sequence.Repeat.Value;
                        }
                        foreach (XmlNode node3 in node2.SelectNodes(".//pet:next", xmlNS))
                        {
                            TNextAnimation.TOnly where = TNextAnimation.TOnly.NONE;
                            if (node3.Attributes["only"] != null)
                            {
                                switch (node3.Attributes["only"].InnerText)
                                {
                                case "taskbar": where = TNextAnimation.TOnly.TASKBAR; break;

                                case "window": where = TNextAnimation.TOnly.WINDOW; break;

                                case "horizontal": where = TNextAnimation.TOnly.HORIZONTAL; break;

                                case "horizontal+": where = TNextAnimation.TOnly.HORIZONTAL_; break;

                                case "vertical": where = TNextAnimation.TOnly.VERTICAL; break;
                                }
                            }
                            ani.EndAnimation.Add(
                                new TNextAnimation(
                                    int.Parse(node3.InnerText),
                                    int.Parse(node3.Attributes["probability"].InnerText),
                                    where
                                    )
                                );
                        }
                        break;

                    case "border":
                        foreach (XmlNode node3 in node2.SelectNodes(".//pet:next", xmlNS))
                        {
                            TNextAnimation.TOnly where = TNextAnimation.TOnly.NONE;
                            if (node3.Attributes["only"] != null)
                            {
                                switch (node3.Attributes["only"].InnerText)
                                {
                                case "taskbar": where = TNextAnimation.TOnly.TASKBAR; break;

                                case "window": where = TNextAnimation.TOnly.WINDOW; break;

                                case "horizontal": where = TNextAnimation.TOnly.HORIZONTAL; break;

                                case "horizontal+": where = TNextAnimation.TOnly.HORIZONTAL_; break;

                                case "vertical": where = TNextAnimation.TOnly.VERTICAL; break;
                                }
                            }
                            ani.Border = true;
                            ani.EndBorder.Add(
                                new TNextAnimation(
                                    int.Parse(node3.InnerText),
                                    int.Parse(node3.Attributes["probability"].InnerText),
                                    where
                                    )
                                );
                        }
                        break;

                    case "gravity":
                        foreach (XmlNode node3 in node2.SelectNodes(".//pet:next", xmlNS))
                        {
                            TNextAnimation.TOnly where = TNextAnimation.TOnly.NONE;
                            if (node3.Attributes["only"] != null)
                            {
                                switch (node3.Attributes["only"].InnerText)
                                {
                                case "taskbar": where = TNextAnimation.TOnly.TASKBAR; break;

                                case "window": where = TNextAnimation.TOnly.WINDOW; break;

                                case "horizontal": where = TNextAnimation.TOnly.HORIZONTAL; break;

                                case "horizontal+": where = TNextAnimation.TOnly.HORIZONTAL_; break;

                                case "vertical": where = TNextAnimation.TOnly.VERTICAL; break;
                                }
                            }
                            ani.Gravity = true;
                            ani.EndGravity.Add(
                                new TNextAnimation(
                                    int.Parse(node3.InnerText),
                                    int.Parse(node3.Attributes["probability"].InnerText),
                                    where
                                    )
                                );
                        }
                        break;
                    }
                }
                animations.SaveAnimation(ani, id);
            }

            nodes = xmlDoc.SelectNodes("//pet:animations/pet:spawn", xmlNS);
            foreach (XmlNode node in nodes)
            {
                int    id  = int.Parse(node.Attributes["id"].InnerText);
                TSpawn ani = animations.AddSpawn(id, int.Parse(node.Attributes["probability"].InnerText), id.ToString());

                foreach (XmlNode node2 in node.ChildNodes)
                {
                    switch (node2.Name)
                    {
                    case "x":
                        ani.Start.X.Compute = node2.InnerText;
                        ani.Start.X.Random  = (ani.Start.X.Compute.IndexOf("random") >= 0);
                        ani.Start.X.Value   = parseValue(ani.Start.X.Compute);
                        break;

                    case "y":
                        ani.Start.Y.Compute = node2.InnerText;
                        ani.Start.Y.Random  = (ani.Start.Y.Compute.IndexOf("random") >= 0);
                        ani.Start.Y.Value   = parseValue(ani.Start.Y.Compute);
                        break;

                    case "direction":
                        string sDirection = node2.InnerText;
                        ani.MoveLeft = (sDirection == "left");
                        break;

                    case "next":
                        ani.Next = int.Parse(node2.InnerText);
                        break;
                    }
                }
                animations.SaveSpawn(ani, id);
            }
        }