예제 #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();
        }
예제 #2
0
        /// <summary>
        /// Count all tables records.
        /// </summary>
        public System.Data.DataTable CountTablesRecords()
        {
            System.Data.DataTable v_tables = QueryTables(false);

            System.Data.DataTable v_count_total_table = new System.Data.DataTable();

            int v_timeout = v_connection.v_timeout;

            v_connection.SetTimeout(0);

            string v_sql = "";

            bool v_first = true;

            int v_block_counter = 0;

            for (int j = 0; j < v_tables.Rows.Count; j++)
            {
                if (!v_first)
                {
                    v_sql += " union all ";
                }

                v_first = false;

                v_block_counter++;


                string v_table_name = "";

                if (v_has_schema)
                {
                    v_table_name = v_schema + "." + v_tables.Rows [j] ["table_name"].ToString();
                }
                else
                {
                    v_table_name = v_tables.Rows [j] ["table_name"].ToString();
                }


                v_sql += "select count(*) as total, " + v_trim_function + "('" + v_tables.Rows [j] ["table_name"].ToString() + "') as table_name from " + v_table_name + " ";



                if (v_block_counter >= 50 || (j == v_tables.Rows.Count - 1))
                {
                    if (v_count_total_table == null)
                    {
                        v_count_total_table = v_connection.Query(v_sql, "t1");
                    }
                    else
                    {
                        v_count_total_table.Merge(v_connection.Query(v_sql, "t1"));
                    }
                    v_first         = true;
                    v_block_counter = 0;

                    v_sql = "";
                }
            }

            System.Data.DataTable dt2 = v_count_total_table.Clone();
            dt2.Columns["total"].DataType = Type.GetType("System.Int32");

            foreach (System.Data.DataRow dr in v_count_total_table.Rows)
            {
                dt2.ImportRow(dr);
            }

            dt2.AcceptChanges();
            System.Data.DataView dv = dt2.DefaultView;
            dv.Sort = "total DESC";

            v_count_total_table = dv.ToTable();

            v_connection.SetTimeout(v_timeout);

            return(v_count_total_table);
        }