Beispiel #1
0
        public CWeapon(TGCGame p_game, GraphicsDevice p_device, ContentManager p_content, string p_folder)
        {
            game      = p_game;
            device    = p_device;
            Content   = p_content;
            cs_folder = p_folder;

            // Arma
            String[] W =
            {
                "v_pist_usp",       "idle",       "reload",       "shoot1",
                "v_pist_glock18",   "glock_idle", "glock_reload", "glock_firesingle",
                "v_pist_fiveseven", "idle",       "reload",       "shoot1",
                "v_pist_elite",     "idle",       "reload",       "shoot_left1",
                "v_357",            "idle01",     "reload",       "fire",
                "v_snip_awp",       "awm_idle",   "awm_reload",   "awm_fire",
                "v_smg_mp5",        "idle",       "reload1",      "shoot1",
                "v_smg_mac10",      "mac10_idle", "mac10_reload", "mac10_fire",
                "v_shot_m3super90", "idle",       "start_reload", "shoot1",
                "v_rif_sg552",      "idle",       "reload",       "shoot1",
                "v_rif_m4a1",       "idle",       "reload",       "shoot1",
                "v_rif_famas",      "idle",       "reload",       "shoot1",
                "v_rif_aug",        "idle",       "reload",       "shoot1",
                "v_rif_ak47",       "ak47_idle",  "ak47_reload",  "ak47_fire1",
                "v_rif_galil",      "idle",       "reload",       "shoot1",
                "v_pist_deagle",    "idle1",      "reload",       "shoot1",
                "v_knife_t",        "idle",       "draw",         "stab"
            };

            int t = 0;

            while (t < W.Length)
            {
                String weapon_name = W[t++];
                String file_name   = "weapons\\" + weapon_name + "\\" + weapon_name;
                weapons[cant_weapons++] = new weapon_reference(file_name, device, Content, cs_folder,
                                                               W[t++], W[t++], W[t++]);
            }


            int k = 0;


            //v_pist_usp
            weapons[k].pitch             = 73;
            weapons[k].yaw               = 14;
            weapons[k].desf              = new Vector3(-4.7f, -4, -4);
            weapons[k].scale             = new Vector3(1, 1, -1);
            weapons[k].muzzle_attachment = 1;
            weapons[k].muzzle_pos        = new Vector3(0, 2.75f, 6.5f);
            k++;

            // v_pist_glock18
            weapons[k].pitch             = 73;
            weapons[k].yaw               = 14;
            weapons[k].desf              = new Vector3(-4.7f, -4, -4);
            weapons[k].scale             = new Vector3(1, 1, -1);
            weapons[k].muzzle_attachment = 4;
            weapons[k].muzzle_pos        = new Vector3(0, 0, 6);
            k++;

            // v_pist_fiveseven
            weapons[k].pitch             = 73;
            weapons[k].yaw               = 14;
            weapons[k].desf              = new Vector3(-4.7f, -4, -4);
            weapons[k].scale             = new Vector3(1, 1, -1);
            weapons[k].muzzle_attachment = 1;
            weapons[k].muzzle_pos        = new Vector3(0, 2.2f, 7.5f);
            k++;


            // v_pist_elite
            weapons[k].pitch             = 73;
            weapons[k].yaw               = 14;
            weapons[k].desf              = new Vector3(-4.7f, -4, -4);
            weapons[k].scale             = new Vector3(1, 1, -1);
            weapons[k].muzzle_attachment = 22;
            k++;

            //v_357
            weapons[k].pitch             = 73;
            weapons[k].yaw               = 14;
            weapons[k].desf              = new Vector3(-17, -6, -3);
            weapons[k].scale             = new Vector3(1, 1, -1);
            weapons[k].muzzle_attachment = 22;
            k++;

            //v_snip_awp
            weapons[k].pitch      = 73;
            weapons[k].yaw        = 14;
            weapons[k].desf       = new Vector3(-4.7f, -4, -4);
            weapons[k].scale      = new Vector3(1, 1, -1);
            weapons[k].muzzle_pos = new Vector3(0, 3.5f, 28);
            k++;

            //v_smg_mp5
            weapons[k].pitch      = 73;
            weapons[k].yaw        = 14;
            weapons[k].desf       = new Vector3(-4.7f, -4, -4);
            weapons[k].scale      = new Vector3(1, 1, -1);
            weapons[k].muzzle_pos = new Vector3(3, 6, 27.5f);
            k++;

            //v_smg_mac10
            weapons[k].pitch      = 73;
            weapons[k].yaw        = 14;
            weapons[k].desf       = new Vector3(-4.7f, -4, -4);
            weapons[k].scale      = new Vector3(1, 1, -1);
            weapons[k].muzzle_pos = new Vector3(0, 3, 5);
            k++;

            // v_shot_m3super90
            weapons[k].pitch      = 73;
            weapons[k].yaw        = 14;
            weapons[k].desf       = new Vector3(-4.7f, -4, -4);
            weapons[k].scale      = new Vector3(1, 1, -1);
            weapons[k].muzzle_pos = new Vector3(2.724713f, 2.405631f, 16.455919f) + new Vector3(0, 3, 18);
            k++;

            //v_rif_sg552
            weapons[k].pitch      = 73;
            weapons[k].yaw        = 14;
            weapons[k].desf       = new Vector3(-4.7f, -4, -4);
            weapons[k].scale      = new Vector3(1, 1, -1);
            weapons[k].muzzle_pos = new Vector3(3, 5.5f, 34);
            k++;

            //v_rif_m4a1
            weapons[k].pitch      = 73;
            weapons[k].yaw        = 14;
            weapons[k].desf       = new Vector3(-4.7f, -4, -4);
            weapons[k].scale      = new Vector3(1, 1, -1);
            weapons[k].muzzle_pos = new Vector3(0.20f, 3.50f, 20.00f);
            k++;

            // famas
            weapons[k].pitch      = 79;
            weapons[k].yaw        = 14;
            weapons[k].desf       = new Vector3(-11, -3, -9);
            weapons[k].scale      = new Vector3(1, 1, -1);
            weapons[k].muzzle_pos = new Vector3(-7.7f, 0, 12f);
            k++;

            // aug
            weapons[k].pitch      = 76;
            weapons[k].yaw        = 14;
            weapons[k].desf       = new Vector3(-5, -6, -15);
            weapons[k].scale      = new Vector3(1, 1, -1);
            weapons[k].muzzle_pos = new Vector3(-1.70f, 2.70f, 15.00f);
            k++;

            // ak47
            weapons[k].pitch      = 76;
            weapons[k].yaw        = 14;
            weapons[k].desf       = new Vector3(-5, -6, -15);
            weapons[k].scale      = new Vector3(1, 1, -1);
            weapons[k].muzzle_pos = new Vector3(0, 3.50f, 19.00f);
            k++;

            // galil
            weapons[k].pitch      = 76;
            weapons[k].yaw        = 14;
            weapons[k].desf       = new Vector3(-5, -6, -15);
            weapons[k].muzzle_pos = new Vector3(1.6f, 3.87f, 31);
            k++;

            // pist Eagle
            weapons[k].pitch      = 71;
            weapons[k].yaw        = 10;
            weapons[k].desf       = new Vector3(-14, -1.5f, -14);
            weapons[k].muzzle_pos = new Vector3(0, 2.75f, 6.50f);
            //weapons[k].model.anim[2].frameRate = 10;


            // correccion muzzle_pos
            for (int i = 0; i < cant_weapons; ++i)
            {
                weapons[i].muzzle_pos = new Vector3(weapons[i].muzzle_pos.X, -weapons[i].muzzle_pos.Z, weapons[i].muzzle_pos.Y);
            }

            // otros efectos
            sp             = new CSprite("effects\\muzzleflashx", device, Content);
            sp.rendercolor = new Vector3(1, 1, 1);
            sp.scale       = 0.1f;
            sp.renderamt   = 1;


            cur_weapon = 9;
        }
Beispiel #2
0
        public void cargarEntidades(string fname)
        {
            string lumpname = map_folder + fname + ".ent";

            if (!File.Exists(lumpname))
            {
                return;
            }

            StreamReader reader;
            int          state = 0;
            string       key = "", value = "";
            Vector3      origin = new Vector3(0, 0, 0);
            Vector3      angles = new Vector3(0, 0, 0);
            Vector3      rendercolor = new Vector3(1, 1, 1);
            float        renderamt = 1;
            float        scale = 0;
            string       model = "", classname = "";

            reader = new StreamReader(lumpname);
            do
            {
                char ch = (char)reader.Read();
                switch (ch)
                {
                case '{':
                    state = 1;
                    break;

                case '"':
                    switch (state)
                    {
                    case 1:
                    case 5:
                        key   = "";
                        state = 2;                                              // input key
                        break;

                    case 2:
                        state = 3;
                        break;

                    case 3:
                        state = 4;
                        value = "";                                             // input value
                        break;

                    case 4:
                        state = 5;
                        // fin de entrada key , value
                        if (key == "origin")
                        {
                            origin = parseVector3(value);
                        }
                        else
                        if (key == "model" || key == "RopeMaterial" || key == "texture")
                        {
                            model = value;
                        }
                        else
                        if (key == "classname")
                        {
                            classname = value;
                        }
                        else
                        if (key == "angles")
                        {
                            angles = parseOrient(value);
                        }
                        else
                        if (key == "scale")
                        {
                            scale = float.Parse(value, CultureInfo.InvariantCulture.NumberFormat);
                        }
                        else
                        if (key == "rendercolor")
                        {
                            rendercolor = parseColor(value);
                        }
                        else
                        if (key == "renderamt")
                        {
                            renderamt = float.Parse(value, CultureInfo.InvariantCulture.NumberFormat) / 255.0f;
                        }
                        break;
                    }
                    break;

                case '}':
                    state = 0;
                    // fin de entidad
                    if (model.Contains(".mdl") && cant_modelos < MAX_MODELOS - 1)
                    {
                        model = model.Replace("models/", "").Replace(".mdl", "");
                        var p = modelos[cant_modelos++] = new bsp_model();
                        p.origin   = origin;
                        p.angles   = angles;
                        p.nro_mesh = mesh_pool.insert(model, device, Content, cs_folder);

                        if (classname == "prop_door_rotating")
                        {
                            // caso particular: es una puerta que gira
                            p.flags |= PROP_DOOR_ROTATING;
                        }



                        Debug.WriteLine(model + " " + origin + "  " + angles);
                    }
                    else
                    if ((classname == "env_sprite" || classname == "xkeyframe_rope") &&
                        cant_sprites < MAX_SPRITES - 1)
                    {
                        if (classname == "keyframe_rope")
                        {
                            rendercolor = new Vector3(1, 1, 1);
                            renderamt   = 1;
                        }
                        if (classname == "infodecal")
                        {
                            rendercolor = new Vector3(1, 1, 1);
                            renderamt   = 1;
                        }
                        model = model.Replace("materials/", "").Replace(".vmt", "");
                        var p = sprites[cant_sprites++] = new CSprite(model, device, Content);
                        p.origin = origin;
                        //p.scale = scale;
                        p.renderamt   = renderamt;
                        p.rendercolor = rendercolor;
                        Debug.WriteLine(model + " " + origin + "  " + angles);
                    }
                    else
                    if (classname == "infodecal" && cant_decals < MAX_DECALS - 1)
                    {
                        model = model.Replace("materials/", "").Replace(".vmt", "");
                        decals[cant_decals++] = new info_decal(this, origin, model, device);
                    }
                    else
                    if (classname == "info_player_start")
                    {
                        info_player_start_pos    = origin;
                        info_player_start_angles = angles;
                    }
                    else
                    if (classname == "hostage_entity")
                    {
                        var h = hostages[cant_hostages++] = new info_hostage();
                        h.origin = origin;
                        h.angles = angles;
                    }
                    break;

                default:
                    switch (state)
                    {
                    case 2:
                        key += ch;
                        break;

                    case 4:
                        value += ch;
                        break;
                    }
                    break;
                }
            } while (!reader.EndOfStream);
            reader.Close();
            reader.Dispose();
        }