当前位置: 首页>>代码示例>>C#>>正文


C# Floor.create_new_projectile方法代码示例

本文整理汇总了C#中Floor.create_new_projectile方法的典型用法代码示例。如果您正苦于以下问题:C# Floor.create_new_projectile方法的具体用法?C# Floor.create_new_projectile怎么用?C# Floor.create_new_projectile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Floor的用法示例。


在下文中一共展示了Floor.create_new_projectile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: target_bonespear


//.........这里部分代码省略.........
             * [_][M][M]
             * [_][M][M]
             */
            if (pl_x_dir != 0 && pl_y_dir != 0)
            {
                int target_index = -1;
                if (pl_x_dir == -1 && pl_y_dir == -1)
                    target_index = 0;
                else if (pl_x_dir == 1 && pl_y_dir == -1)
                    target_index = 1;
                else if (pl_x_dir == -1 && pl_y_dir == 1)
                    target_index = 2;
                else if (pl_x_dir == 1 && pl_y_dir == 1)
                    target_index = 3;

                gridCoordinate start_coord = new gridCoordinate(my_grid_coords[target_index].x + pl_x_dir,
                                                                my_grid_coords[target_index].y + pl_y_dir);
                if (spear1)
                    c_bspear_target_startp = start_coord;
                else
                    c_bspear_target_startp_2 = start_coord;
                //Then we make a list of endpoints based on that. It will need two for loops;
                //One for the X-axis and one for the Y-axis
                //5/5 offset
                endPoints.Add(new gridCoordinate(start_coord.x + (pl_x_dir * 5), start_coord.y + (pl_y_dir * 5)));
                //5/4 offsets
                endPoints.Add(new gridCoordinate(start_coord.x + (pl_x_dir * 4), start_coord.y + (pl_y_dir * 5)));
                endPoints.Add(new gridCoordinate(start_coord.x + (pl_x_dir * 5), start_coord.y + (pl_y_dir * 4)));
                //5/3 offsets
                endPoints.Add(new gridCoordinate(start_coord.x + (pl_x_dir * 3), start_coord.y + (pl_y_dir * 5)));
                endPoints.Add(new gridCoordinate(start_coord.x + (pl_x_dir * 5), start_coord.y + (pl_y_dir * 3)));
                //5/2 offsets
                endPoints.Add(new gridCoordinate(start_coord.x + (pl_x_dir * 2), start_coord.y + (pl_y_dir * 5)));
                endPoints.Add(new gridCoordinate(start_coord.x + (pl_x_dir * 5), start_coord.y + (pl_y_dir * 2)));
                //5/1 offsets
                endPoints.Add(new gridCoordinate(start_coord.x + (pl_x_dir * 1), start_coord.y + (pl_y_dir * 5)));
                endPoints.Add(new gridCoordinate(start_coord.x + (pl_x_dir * 5), start_coord.y + (pl_y_dir * 1)));
                //I avoided doing this in a for loop because I want the boneyard to prioritize shooting the spear
                //diagonally if it can and doing it with loops would shoot it either vertically or horizontally.

                List<VisionRay> bspear_rays = new List<VisionRay>();
                for (int i = 0; i < endPoints.Count; i++)
                    bspear_rays.Add(new VisionRay(start_coord, endPoints[i]));

                bool found_player = false;
                while (bspear_rays.Count > 0)
                {
                    for (int i = 0; i < bspear_rays.Count; i++)
                    {
                        bool remove = false;
                        int c_x_coord = (int)bspear_rays[i].my_current_position.X / 32;
                        int c_y_coord = (int)bspear_rays[i].my_current_position.Y / 32;
                        gridCoordinate c_coord = new gridCoordinate(c_x_coord, c_y_coord);

                        if (!fl.is_tile_passable(c_coord) || bspear_rays[i].is_at_end())
                            remove = true;

                        if (target_loc.x == c_coord.x && target_loc.y == c_coord.y)
                        {
                            if(spear1)
                                c_bspear_target_endp = new gridCoordinate((int)bspear_rays[i].my_end_position.X / 32,
                                                                          (int)bspear_rays[i].my_end_position.Y / 32);
                            else
                                c_bspear_target_endp_2 = new gridCoordinate((int)bspear_rays[i].my_end_position.X / 32,
                                                                            (int)bspear_rays[i].my_end_position.Y / 32);
                            found_player = true;
                        }

                        if (remove)
                            bspear_rays.RemoveAt(i);
                        else
                            bspear_rays[i].update();

                        if (found_player)
                            bspear_rays.Clear();
                    }
                }
            }

            //Don't try to create a projectile if the endpoint is null. This means that it hasn't found the player.
            if (c_bspear_target_endp != null)
            {
                Projectile prj = new Projectile(c_bspear_target_startp, c_bspear_target_endp, Projectile.projectile_type.Blank,
                                            ref cont, true, Scroll.Atk_Area_Type.piercingBolt, false);
                prj.set_special_anim(Projectile.special_anim.Alert);
                prj.set_damage_range(0, 0);
                prj.set_damage_type(bone_spear_dmgtyp);
                fl.create_new_projectile(prj);
            }

            if (c_bspear_target_endp_2 != null)
            {
                Projectile prj2 = new Projectile(c_bspear_target_startp_2, c_bspear_target_endp_2, Projectile.projectile_type.Blank,
                                            ref cont, true, Scroll.Atk_Area_Type.piercingBolt, false);
                prj2.set_special_anim(Projectile.special_anim.Alert);
                prj2.set_damage_range(0, 0);
                prj2.set_damage_type(bone_spear_dmgtyp);
                fl.create_new_projectile(prj2);
            }
        }
开发者ID:Chupaflor,项目名称:Cronkpit_Samples,代码行数:101,代码来源:Boneyard.cs

示例2: fire_singletarget_bonespear

 public void fire_singletarget_bonespear(Floor fl, gridCoordinate target_GC)
 {
     fl.addmsg("The Boneyard spits a bone spear at you!");
     Projectile bs = new Projectile(randomly_chosen_personal_coord(), target_GC,
                                    Projectile.projectile_type.Bonespear, ref cont, true,
                                    Scroll.Atk_Area_Type.singleTile);
     bs.set_damage_range(bone_spear_mindmg, bone_spear_maxdmg);
     bs.set_damage_type(bone_spear_dmgtyp);
     fl.create_new_projectile(bs);
 }
开发者ID:Chupaflor,项目名称:Cronkpit_Samples,代码行数:10,代码来源:Boneyard.cs

示例3: fire_bonespear

        public void fire_bonespear(Floor fl, bool spear1)
        {
            gridCoordinate start_point = null;
            gridCoordinate end_point = null;

            if (spear1)
            {
                start_point = c_bspear_target_startp;
                end_point = c_bspear_target_endp;
            }
            else
            {
                start_point = c_bspear_target_startp_2;
                end_point = c_bspear_target_endp_2;
            }

            //Don't try to create a projectile if the endpoint is null. This means that it hasn't found the player.
            if (c_bspear_target_endp != null)
            {
                Projectile boneSpear = new Projectile(start_point, end_point,
                                                      Projectile.projectile_type.Bonespear, ref cont,
                                                      true, Scroll.Atk_Area_Type.piercingBolt);
                boneSpear.set_damage_type(bone_spear_dmgtyp);
                boneSpear.set_damage_range(bone_spear_mindmg, bone_spear_maxdmg);
                fl.create_new_projectile(boneSpear);
            }
        }
开发者ID:Chupaflor,项目名称:Cronkpit_Samples,代码行数:27,代码来源:Boneyard.cs

示例4: bloodspray


//.........这里部分代码省略.........
                pl_y_dir = -1;

            List<gridCoordinate> potential_spray_targets = new List<gridCoordinate>();
            List<gridCoordinate> blood_spray_targets = new List<gridCoordinate>();

            if (pl_x_dir == 0)
            {
                int y_coord = top_left.y;
                if (pl_y_dir > 0)
                    y_coord = bottom_right.y;

                for (int x = top_left.x - 1; x <= bottom_right.x + 1; x++)
                    for (int y = y_coord + (pl_y_dir * 2); y != y_coord + (pl_y_dir * 4); y += pl_y_dir)
                        potential_spray_targets.Add(new gridCoordinate(x, y));
            }
            else if (pl_y_dir == 0)
            {
                int x_coord = top_left.x;
                if (pl_x_dir > 0)
                    x_coord = bottom_right.x;

                for (int x = x_coord + (pl_x_dir * 2); x != x_coord + (pl_x_dir * 4); x += pl_x_dir)
                    for (int y = top_left.y - 1; y <= bottom_right.y + 1; y++)
                        potential_spray_targets.Add(new gridCoordinate(x, y));
            }
            else
            {
                for(int i = 0; i < my_grid_coords.Count; i++)
                    potential_spray_targets.Add(new gridCoordinate(my_grid_coords[i].x + (pl_x_dir*3),
                                                                   my_grid_coords[i].y + (pl_y_dir*3)));

                int upper_x = 0;
                int lower_x = 0;
                if (pl_x_dir == 1)
                {
                    upper_x = 0;
                    lower_x = 2;
                }
                else if (pl_x_dir == -1)
                {
                    upper_x = 1;
                    lower_x = 3;
                }

                int left_y = 0;
                int right_y = 0;
                if (pl_y_dir == 1)
                {
                    left_y = 0;
                    right_y = 1;
                }
                else if (pl_y_dir == -1)
                {
                    left_y = 2;
                    right_y = 3;
                }

                //The above code gives us a 2x2 zone. For this, we want to extend the zone by one
                //x tile and y tile in the opposite direction of where the player is relative to the boneyard
                //That's why the above code picks out the 2 coordinates from the x axis and y axis, because
                potential_spray_targets.Add(new gridCoordinate(potential_spray_targets[upper_x].x + (pl_x_dir*-1),
                                                                   potential_spray_targets[upper_x].y));
                potential_spray_targets.Add(new gridCoordinate(potential_spray_targets[lower_x].x + (pl_x_dir*-1),
                                                               potential_spray_targets[lower_x].y));
                potential_spray_targets.Add(new gridCoordinate(potential_spray_targets[left_y].x,
                                                                   potential_spray_targets[left_y].y + (pl_y_dir*-1)));
                potential_spray_targets.Add(new gridCoordinate(potential_spray_targets[right_y].x,
                                                               potential_spray_targets[right_y].y + (pl_y_dir*-1)));
            }

            int potential_targets = 3;
            //for (int i = 0; i < potential_spray_targets.Count; i++)
                //fl.set_tile_aura(potential_spray_targets[i], Tile.Aura.SmellTarget);
            for (int i = 0; i < potential_targets; i++)
            {
                bool found_valid_target = false;
                while (!found_valid_target && potential_spray_targets.Count > 0)
                {
                    int chosen_coord = rGen.Next(potential_spray_targets.Count);
                    if (can_i_see_point(fl, potential_spray_targets[chosen_coord]))
                    {
                        blood_spray_targets.Add(potential_spray_targets[chosen_coord]);
                        found_valid_target = true;
                    }
                    potential_spray_targets.RemoveAt(chosen_coord);
                }
            }

            for (int i = 0; i < blood_spray_targets.Count; i++)
            {
                Projectile bspray = new Projectile(randomly_chosen_personal_coord(), blood_spray_targets[i],
                                                   Projectile.projectile_type.Bloody_AcidCloud, ref cont,
                                                   true, Scroll.Atk_Area_Type.cloudAOE, true);
                bspray.set_damage_type(blood_spray_dmgtyp);
                bspray.set_damage_range(blood_spray_mindmg, blood_spray_maxdmg);
                bspray.set_special_anim(Projectile.special_anim.BloodAcid);
                bspray.set_AOE_size(1);
                fl.create_new_projectile(bspray);
            }
        }
开发者ID:Chupaflor,项目名称:Cronkpit_Samples,代码行数:101,代码来源:Boneyard.cs

示例5: cast_spell

        public void cast_spell(Scroll s, Floor fl, gridCoordinate spell_target, int target_monster_ID, int target_Doodad_ID)
        {
            string spell_name = s.get_my_name();
            Projectile.projectile_type prj_type = s.get_assoc_projectile();
            Attack.Damage spell_dmg_type = s.get_damage_type();
            gridCoordinate starting_coord = my_grid_coord;
            Projectile.special_anim spec_prj_anim = s.get_spec_impact_anim();

            c_energy -= s.get_manaCost();
            max_energy += s.get_en_cap_adj();

            if (max_energy > 100)
                max_energy = 100;
            if (max_energy < 0)
                max_energy = 0;

            if (s.get_spell_type() == Scroll.Atk_Area_Type.piercingBolt)
            {
                int spell_range = s.get_range();
                int relative_x = (spell_target.x - my_grid_coord.x) * spell_range;
                int relative_y = (spell_target.y - my_grid_coord.y) * spell_range;
                starting_coord = new gridCoordinate(spell_target);
                spell_target = new gridCoordinate(my_grid_coord.x + relative_x, my_grid_coord.y + relative_y);
            }

            if (s.get_spell_type() != Scroll.Atk_Area_Type.personalBuff)
            {
                Projectile prj = new Projectile(starting_coord, spell_target, prj_type,
                                                 ref cont, false, s.get_spell_type());
                prj.attach_scroll(s);
                prj.set_wall_destroying(s.spell_destroys_walls());
                prj.set_special_anim(spec_prj_anim);

                if (s.get_spell_type() == Scroll.Atk_Area_Type.enemyDebuff)
                {
                    prj.attach_status_effect(s.get_status_effect(), s.get_duration(), s.does_spell_buff_count_down(), s.get_cost_per_turn(), s.get_cost_per_turn_per_turn());
                }

                if (s.get_spell_type() == Scroll.Atk_Area_Type.cloudAOE ||
                    s.get_spell_type() == Scroll.Atk_Area_Type.solidblockAOE ||
                    s.get_spell_type() == Scroll.Atk_Area_Type.randomblockAOE)
                    prj.set_AOE_size(s.get_aoe_size());

                if (s.get_spell_type() == Scroll.Atk_Area_Type.chainedBolt)
                {
                    prj.set_bounce(s.get_range());
                    prj.set_bounces_left(s.get_t_impacts());
                }

                if (String.Compare(s.get_my_name(), "Earthquake") == 0)
                    prj.set_special_anim(Projectile.special_anim.Earthquake);

                prj.set_talisman_effects(s.get_my_equipped_talismans());
                fl.create_new_projectile(prj);
            }
            else
            {
                int base_buff_time = s.get_duration();
                int modified_buff_time = base_buff_time;
                if (my_character == Character.Petaer)
                {
                    double buff_time_bonus = (double)modified_buff_time * .3;
                    modified_buff_time = (int)Math.Ceiling((double)modified_buff_time + buff_time_bonus);
                }
                add_single_statusEffect(new StatusEffect(s.get_status_effect(), modified_buff_time+1, s.does_spell_buff_count_down(), s.get_cost_per_turn(), s.get_cost_per_turn_per_turn(), false));
            }
        }
开发者ID:Chupaflor,项目名称:Cronkpit_Samples,代码行数:67,代码来源:Player.cs

示例6: bow_attack

        public void bow_attack(Floor fl, ref ContentManager Secondary_cManager, gridCoordinate attack_location, int monsterID, int DoodadID)
        {
            Weapon Bow = null;
            if (main_hand != null && (main_hand.get_my_weapon_type() == Weapon.Type.Bow ||
                                     main_hand.get_my_weapon_type() == Weapon.Type.Crossbow))
                Bow = main_hand;
            else if (off_hand != null && (off_hand.get_my_weapon_type() == Weapon.Type.Bow ||
                                          off_hand.get_my_weapon_type() == Weapon.Type.Crossbow))
                Bow = off_hand;

            gridCoordinate opposition_coord = new gridCoordinate(-1, -1);
            if (monsterID != -1)
                opposition_coord = attack_location;
            else
                opposition_coord = fl.Doodad_by_index(DoodadID).get_g_coord();

            int cbow_xsplash = 0;
            int cbow_ysplash = 0;
            if (opposition_coord.x < my_grid_coord.x)
                cbow_xsplash = -1;
            else if (opposition_coord.x > my_grid_coord.x)
                cbow_xsplash = 1;

            if (opposition_coord.y < my_grid_coord.y)
                cbow_ysplash = -1;
            else if (opposition_coord.y > my_grid_coord.y)
                cbow_ysplash = 1;
            gridCoordinate splash_coord = new gridCoordinate(opposition_coord.x + cbow_xsplash, opposition_coord.y + cbow_ysplash);

            int base_min_dmg_to_monster = Bow.specific_damage_val(false);
            int base_max_dmg_to_monster = Bow.specific_damage_val(true);

            int max_dmg_to_monster = (int)base_max_dmg_to_monster;
            int min_dmg_to_monster = (int)base_min_dmg_to_monster;

            if (is_cbow_equipped() && my_character == Character.Falsael)
            {
                max_dmg_to_monster = (int)Math.Ceiling(base_max_dmg_to_monster * 1.2);
                min_dmg_to_monster = (int)Math.Ceiling(base_min_dmg_to_monster * 1.2);
            }

            if (Bow.get_my_weapon_type() == Weapon.Type.Bow)
            {
                Projectile prj = new Projectile(get_my_grid_C(), opposition_coord, Projectile.projectile_type.Arrow, ref Secondary_cManager, false, Scroll.Atk_Area_Type.singleTile);
                prj.attach_weapon(Bow);
                fl.create_new_projectile(prj);
            }
            else if(Bow.get_my_weapon_type() == Weapon.Type.Crossbow)
            {
                Projectile prj = new Projectile(get_my_grid_C(), opposition_coord, Projectile.projectile_type.Crossbow_Bolt, ref Secondary_cManager, false, Scroll.Atk_Area_Type.smallfixedAOE);
                List<gridCoordinate> crossbow_aoe = new List<gridCoordinate>();
                crossbow_aoe.Add(opposition_coord);
                crossbow_aoe.Add(splash_coord);
                prj.set_small_AOE_matrix(crossbow_aoe);
                prj.attach_weapon(Bow);
                fl.create_new_projectile(prj);
            }

            string attack_msg = "";
            if (monsterID != -1)
                attack_msg = "You attack the " + fl.badguy_by_monster_id(monsterID).my_name + " with your " + Bow.get_my_name() + "!";
            else
                attack_msg = "You attack the " + fl.Doodad_by_index(DoodadID).my_name() + " with your " + Bow.get_my_name() + "!";
            message_buffer.Add(attack_msg);

            total_sound += my_sound_value() + (my_sound_value() / 2);
            total_scent += my_scent_value();

            if (my_class == Chara_Class.Warrior)
            {
                c_energy += 6;
            }
        }
开发者ID:Chupaflor,项目名称:Cronkpit_Samples,代码行数:73,代码来源:Player.cs


注:本文中的Floor.create_new_projectile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。