예제 #1
0
            public void Apply(float interpolationFactor, bool isNewFrame, IMemento nextFrame)
            {
                Enemy target = (Enemy)Target;

                if (nextFrame != null)
                {
                    float        thisInterp = 1 - interpolationFactor;
                    float        nextInterp = interpolationFactor;
                    EnemyMemento next       = (EnemyMemento)nextFrame;
                    target.position = position * thisInterp + next.position * nextInterp;
                    deathEmitterMemento.Apply(interpolationFactor, isNewFrame, ((EnemyMemento)nextFrame).deathEmitterMemento);
                }
                else
                {
                    target.position = position;
                    deathEmitterMemento.Apply(interpolationFactor, isNewFrame, null);
                }
                target.state             = state;
                target.targetedAI.Target = AItarget;
                target.health            = health;
                target.direction         = direction;
                target.rotation          = rotation;
                target.dying             = dying;
                target.maskingColor      = Color.Lerp(Color.Black, Color.White, health / STARTING_HEALTH);
            }
예제 #2
0
 public void RestoreState(EnemyMemento memento)
 {
     this.id        = memento.id;
     this.HitPoints = memento.HitPoints;
     this.damage    = memento.damage;
     this.sprite    = memento.sprite;
     this.Name      = memento.Name;
 }
예제 #3
0
        public EnemyMemento[] ReadEnemyDataFromFile()
        {
            XmlElement xRoot = xDoc.DocumentElement;
            int        i     = 0;

            foreach (XmlNode node in xRoot["enemies"])
            {
                i++;
            }

            EnemyMemento[] enemies = new EnemyMemento[i];

            i = 0;
            foreach (XmlNode node in xRoot["enemies"])
            {
                string pathForEnemy1Back = System.IO.Path.GetFullPath(@"textures\enemies\enemy1\mole-walk-back-4.png");
                string pathForEnemy2Back = System.IO.Path.GetFullPath(@"textures\enemies\enemy2\treant-walk-back-3.png");
                string pathForBackground = System.IO.Path.GetFullPath(@"textures\blocks\sand-3.png");

                PictureBox sprite = new PictureBox();
                sprite.Size            = new Size(30, 30);
                sprite.BackgroundImage = Image.FromFile(pathForBackground);

                if (node["name"].InnerText == "enemy2")
                {
                    sprite.Image = Image.FromFile(pathForEnemy2Back);
                }
                else
                {
                    sprite.Image = Image.FromFile(pathForEnemy1Back);
                }

                sprite.SizeMode = PictureBoxSizeMode.StretchImage;
                sprite.Location = new Point(Convert.ToInt32(node["locationX"].InnerText), Convert.ToInt32(node["locationY"].InnerText));

                EnemyMemento enemy = new EnemyMemento(Convert.ToInt32(node["id"].InnerText), node["name"].InnerText, Convert.ToInt32(node["hitPoints"].InnerText), Convert.ToInt32(node["damage"].InnerText), sprite);

                enemies[i] = enemy;
                i++;
            }

            return(enemies);
        }