Example #1
0
        private void buttonAddEntity_Click(object sender, EventArgs e)
        {
            Chiky entety = new Chiky()
            {
                mSpeedTime = 1
            };

            entety.Add(50, 50);
            this.entityList.Insert(this.entIndex, entety);
            this.pointIndex = 0;
            this.UpdateForm();
        }
Example #2
0
        // Example:
        // <?xml version="1.0" encoding="UTF-8"?>
        // <level r1="0" g1="138" b1="255" r2="0" g2="255" b2="255" bluebird="false">
        // <chiky name="tooflya.com" scale="0.5" minTime="0.1" maxTime="1.1" speedTime="0.5" offsetTime="0.3" isRTime="true" normalMaxTime="1" normalSpeedTime="0.5" unnormalMaxTime="0.5" unnormalSpeedTime="1" properties="3">
        // <ctrPoint x="10" y="50"/>
        // <ctrPoint x="90" y="50"/>
        // </chiky>
        // </level>
        private void buttonLoad_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                entityList.Clear();
                using (StreamReader sr = new StreamReader(this.openFileDialog.FileName))
                {
                    Chiky entity = null;
                    while (!sr.EndOfStream)
                    {
                        try
                        {
                            string entity_string = sr.ReadLine();
                            Dictionary <string, string> entity_dictionary = new Dictionary <string, string>();
                            int index;

                            entity_string = entity_string.Trim();
                            index         = entity_string.IndexOf(' ');
                            if (index < 0)
                            {
                                index = entity_string.IndexOf('>');
                            }
                            if (index > 0)
                            {
                                entity_dictionary.Add("type", entity_string.Substring(1, index - 1));
                                entity_string = entity_string.Remove(0, index + 1);

                                while (entity_string.Length > 2)
                                {
                                    entity_string = entity_string.TrimStart();
                                    index         = entity_string.IndexOf('=');
                                    string key = entity_string.Substring(0, index);
                                    entity_string = entity_string.Remove(0, index + 1);
                                    entity_string = entity_string.Remove(0, entity_string.IndexOf('"') + 1);
                                    index         = entity_string.IndexOf('"');
                                    string value = entity_string.Substring(0, index);
                                    entity_string = entity_string.Remove(0, index + 1);
                                    entity_dictionary.Add(key, value);
                                    entity_string = entity_string.TrimStart();
                                }
                            }

                            switch (entity_dictionary["type"])
                            {
                            case "chiky":
                                entity = new Chiky();

                                float scale = float.Parse(entity_dictionary["scale"]);
                                entity.setWidth(scale * entity.getBaseWidth());
                                entity.setHeight(scale * entity.getBaseWidth());

                                entity.mMinTime           = float.Parse(entity_dictionary["minTime"]);
                                entity.mMaxTime           = float.Parse(entity_dictionary["maxTime"]);
                                entity.mSpeedTime         = float.Parse(entity_dictionary["speedTime"]);
                                entity.mOffsetTime        = float.Parse(entity_dictionary["offsetTime"]);
                                entity.mIsReverseTime     = bool.Parse(entity_dictionary["isRTime"]);
                                entity.mNormalMaxTime     = float.Parse(entity_dictionary["normalMaxTime"]);
                                entity.mNormalSpeedTime   = float.Parse(entity_dictionary["normalSpeedTime"]);
                                entity.mUnnormalMaxTime   = float.Parse(entity_dictionary["unnormalMaxTime"]);
                                entity.mUnnormalSpeedTime = float.Parse(entity_dictionary["unnormalSpeedTime"]);
                                entity.mProperties        = int.Parse(entity_dictionary["properties"]);
                                break;

                            case "ctrPoint":
                                short x = short.Parse(entity_dictionary["x"]);
                                short y = short.Parse(entity_dictionary["y"]);
                                if (entity != null)
                                {
                                    entity.Add(x, y);
                                }
                                break;

                            case "/chiky":
                                entity.reset();
                                this.entityList.Add(entity);
                                break;
                            }
                        }
                        catch { }
                    }
                }
                if (this.entityList.Count < 1)
                {
                    this.entityList.Add(new Chiky());
                    this.entityList[0].Add(50, 50);
                }
                this.UpdateForm();
            }
        }
Example #3
0
        // Example:
        // <?xml version="1.0" encoding="UTF-8"?>
        // <level r1="0" g1="138" b1="255" r2="0" g2="255" b2="255" bluebird="false">
        // <chiky name="tooflya.com" scale="0.5" minTime="0.1" maxTime="1.1" speedTime="0.5" offsetTime="0.3" isRTime="true" normalMaxTime="1" normalSpeedTime="0.5" unnormalMaxTime="0.5" unnormalSpeedTime="1" properties="3">
        // <ctrPoint x="10" y="50"/>
        // <ctrPoint x="90" y="50"/>
        // </chiky>
        // </level>
        private void buttonLoad_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                entityList.Clear();
                using (StreamReader sr = new StreamReader(this.openFileDialog.FileName))
                {
                    Chiky entity = null;
                    while (!sr.EndOfStream)
                    {
                        try
                        {
                            string entity_string = sr.ReadLine();
                            Dictionary<string, string> entity_dictionary = new Dictionary<string, string>();
                            int index;

                            entity_string = entity_string.Trim();
                            index = entity_string.IndexOf(' ');
                            if (index < 0)
                            {
                                index = entity_string.IndexOf('>');
                            }
                            if (index > 0)
                            {
                                entity_dictionary.Add("type", entity_string.Substring(1, index - 1));
                                entity_string = entity_string.Remove(0, index + 1);

                                while (entity_string.Length > 2)
                                {
                                    entity_string = entity_string.TrimStart();
                                    index = entity_string.IndexOf('=');
                                    string key = entity_string.Substring(0, index);
                                    entity_string = entity_string.Remove(0, index + 1);
                                    entity_string = entity_string.Remove(0, entity_string.IndexOf('"') + 1);
                                    index = entity_string.IndexOf('"');
                                    string value = entity_string.Substring(0, index);
                                    entity_string = entity_string.Remove(0, index + 1);
                                    entity_dictionary.Add(key, value);
                                    entity_string = entity_string.TrimStart();
                                }
                            }

                            switch (entity_dictionary["type"])
                            {
                                case "chiky":
                                    entity = new Chiky();

                                    float scale = float.Parse(entity_dictionary["scale"]);
                                    entity.setWidth(scale * entity.getBaseWidth());
                                    entity.setHeight(scale * entity.getBaseWidth());

                                    entity.mMinTime = float.Parse(entity_dictionary["minTime"]);
                                    entity.mMaxTime = float.Parse(entity_dictionary["maxTime"]);
                                    entity.mSpeedTime = float.Parse(entity_dictionary["speedTime"]);
                                    entity.mOffsetTime = float.Parse(entity_dictionary["offsetTime"]);
                                    entity.mIsReverseTime = bool.Parse(entity_dictionary["isRTime"]);
                                    entity.mNormalMaxTime = float.Parse(entity_dictionary["normalMaxTime"]);
                                    entity.mNormalSpeedTime = float.Parse(entity_dictionary["normalSpeedTime"]);
                                    entity.mUnnormalMaxTime = float.Parse(entity_dictionary["unnormalMaxTime"]);
                                    entity.mUnnormalSpeedTime = float.Parse(entity_dictionary["unnormalSpeedTime"]);
                                    entity.mProperties = int.Parse(entity_dictionary["properties"]);
                                    break;
                                case "ctrPoint":
                                    short x = short.Parse(entity_dictionary["x"]);
                                    short y = short.Parse(entity_dictionary["y"]);
                                    if (entity != null)
                                    {
                                        entity.Add(x, y);
                                    }
                                    break;
                                case "/chiky":
                                    entity.reset();
                                    this.entityList.Add(entity);
                                    break;
                            }
                        }
                        catch { }
                    }
                }
                if (this.entityList.Count < 1)
                {
                    this.entityList.Add(new Chiky());
                    this.entityList[0].Add(50, 50);
                }
                this.UpdateForm();
            }
        }
Example #4
0
        private void Form_KeyDown(object sender, KeyEventArgs e)
        {
            int   pointCount;
            Chiky chiky = this.entityList[this.entIndex];

            switch (e.KeyCode)
            {
            case Keys.Escape:
                this.Close();
                break;

            case Keys.D1:
                chiky.mOffsetTime        = (float)this.rand.NextDouble();
                chiky.mSpeedTime         = (float)this.rand.NextDouble();
                chiky.mNormalMaxTime     = 3 * (float)this.rand.NextDouble();
                chiky.mNormalSpeedTime   = (float)this.rand.NextDouble();
                chiky.mUnnormalMaxTime   = 3 * (float)this.rand.NextDouble();
                chiky.mUnnormalSpeedTime = 2 * (float)this.rand.NextDouble();
                chiky.mProperties        = Chiky.isUnnormalMoveFlag;
                chiky.mListCount         = 0;
                pointCount = this.rand.Next(4) + 1;
                for (int i = 0; i < pointCount; ++i)
                {
                    chiky.Add((short)this.rand.Next(100), (short)this.rand.Next(100));
                }
                this.UpdateForm();
                break;

            case Keys.D2:
                pointCount = chiky.mListCount;
                for (int i = 0; i < pointCount; ++i)
                {
                    chiky.Add((short)(100 - chiky.mList[2 * (pointCount - i - 1)]), chiky.mList[2 * (pointCount - i - 1) + 1]);
                }
                this.UpdateForm();
                break;

            case Keys.D3:
                pointCount = chiky.mListCount;
                for (int i = 0; i < pointCount; ++i)
                {
                    chiky.Add((short)(100 - chiky.mList[2 * (pointCount - i - 1)]), (short)(100 - chiky.mList[2 * (pointCount - i - 1) + 1]));
                }
                this.UpdateForm();
                break;

            case Keys.D4:
                pointCount = chiky.mListCount;
                for (int i = 0; i < pointCount; ++i)
                {
                    chiky.Add(chiky.mList[2 * (pointCount - i - 1)], (short)(100 - chiky.mList[2 * (pointCount - i - 1) + 1]));
                }
                this.UpdateForm();
                break;

            case Keys.D5:
                pointCount = chiky.mListCount;
                for (int i = 0; i < pointCount; ++i)
                {
                    short t = chiky.mList[2 * (pointCount - i - 1)];
                    chiky.mList[2 * (pointCount - i - 1)]     = chiky.mList[2 * (pointCount - i - 1) + 1];
                    chiky.mList[2 * (pointCount - i - 1) + 1] = t;
                }
                this.UpdateForm();
                break;
            }
        }
Example #5
0
 private void buttonAddEntity_Click(object sender, EventArgs e)
 {
     Chiky entety = new Chiky() { mSpeedTime = 1 };
     entety.Add(50, 50);
     this.entityList.Insert(this.entIndex, entety);
     this.pointIndex = 0;
     this.UpdateForm();
 }