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


C# Projectile.set_damage_range方法代码示例

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


在下文中一共展示了Projectile.set_damage_range方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_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

示例3: 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

示例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


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