Пример #1
0
        /*
         * switch(this.v_direction)
         * {
         *      case Direction.SOUTH:
         *      break;
         *      case Direction.SOUTHWEST:
         *      break;
         *      case Direction.WEST:
         *      break;
         *      case Direction.NORTHWEST:
         *      break;
         *      case Direction.NORTH:
         *      break;
         *      case Direction.NORTHEAST:
         *      break;
         *      case Direction.EAST:
         *      break;
         *      case Direction.SOUTHEAST:
         *      break;
         * }
         */

        public Soldier(
            Spartacus.Database.Generic p_database,
            TeamColor p_color,
            string p_name,
            int p_mapx,
            int p_mapy
            )
        {
            Spartacus.Game.Animation v_animation;

            Direction[] v_directions = new Direction[]
            {
                Direction.SOUTH,
                Direction.SOUTHWEST,
                Direction.WEST,
                Direction.NORTHWEST,
                Direction.NORTH,
                Direction.NORTHEAST,
                Direction.EAST,
                Direction.SOUTHEAST
            };
            int k, f;

            this.v_color = p_color;
            switch (p_color)
            {
            case TeamColor.GREEN:
                this.v_prefix = "soldiers/green/";
                break;

            case TeamColor.RED:
                this.v_prefix = "soldiers/red/";
                break;

            case TeamColor.BLUE:
                this.v_prefix = "soldiers/blue/";
                break;

            case TeamColor.YELLOW:
                this.v_prefix = "soldiers/yellow/";
                break;

            default:
                break;
            }

            this.v_mapx     = p_mapx;
            this.v_mapy     = p_mapy;
            this.v_name     = p_name;
            this.v_health   = 100;
            this.v_actions  = 5;
            this.v_stamina  = 100;
            this.v_ammo     = 20;
            this.v_grenades = 2;

            this.v_object = new Spartacus.Game.Object(p_name, 0, 0, 96, 96);

            foreach (System.Data.DataRow r in p_database.Query("select * from animations order by id", "ANIMATIONS").Rows)
            {
                if (r["id"].ToString() == "1")
                {
                    k = 0;
                    foreach (Direction d in v_directions)
                    {
                        this.v_object.AddImage(this.v_prefix + r["name"].ToString() + string.Format("{0:0000}", k) + ".png", true);
                        k++;
                    }
                }
                else
                {
                    foreach (Direction d in v_directions)
                    {
                        v_animation = new Spartacus.Game.Animation(r["name"].ToString(), false);
                        k           = 0;
                        f           = 2;
                        for (int s = 0; s < int.Parse(r["steps"].ToString()); s++)
                        {
                            this.v_object.AddImage(this.v_prefix + r["name"].ToString() + "_" + this.DirectionToString(d) + string.Format("{0:0000}", k) + ".png", true);
                            v_animation.AddStep(this.v_object.v_images.Count - 1, f);
                            k++;
                            f += 2;
                        }
                        switch (d)
                        {
                        case Direction.SOUTH:
                            v_animation.AddStep(0, f);
                            break;

                        case Direction.SOUTHWEST:
                            v_animation.AddStep(1, f);
                            break;

                        case Direction.WEST:
                            v_animation.AddStep(2, f);
                            break;

                        case Direction.NORTHWEST:
                            v_animation.AddStep(3, f);
                            break;

                        case Direction.NORTH:
                            v_animation.AddStep(4, f);
                            break;

                        case Direction.NORTHEAST:
                            v_animation.AddStep(5, f);
                            break;

                        case Direction.EAST:
                            v_animation.AddStep(6, f);
                            break;

                        case Direction.SOUTHEAST:
                            v_animation.AddStep(7, f);
                            break;
                        }
                        this.v_object.AddAnimation(v_animation);
                    }
                }
            }

            this.v_random = new System.Random();

            this.v_direction = v_directions[this.v_random.Next(v_directions.Length)];
            this.Start();
        }
 public void AddAnimation(Spartacus.Game.Animation p_animation)
 {
     this.v_animations.Add(p_animation);
 }