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


C# Floor.is_tile_passable方法代码示例

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


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

示例1: bite_alert

 public void bite_alert(Floor fl)
 {
     for (int x = my_grid_coords[0].x - 2; x <= my_grid_coords[1].x + 2; x++)
         for (int y = my_grid_coords[0].y - 2; y <= my_grid_coords[2].y + 2; y++)
         {
             gridCoordinate target_coord = new gridCoordinate(x, y);
             if (x > 0 && x < fl.get_fl_size() &&
                y > 0 && y < fl.get_fl_size() &&
                fl.is_tile_passable(target_coord) &&
                !occupies_tile(target_coord))
                 fl.add_specific_effect(Floor.specific_effect.Alert, new gridCoordinate(x, y));
         }
 }
开发者ID:Chupaflor,项目名称:Cronkpit_Samples,代码行数:13,代码来源:Boneyard.cs

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

示例3: return_spear_patterns

        public List<gridCoordinate> return_spear_patterns(gridCoordinate pl_gc, gridCoordinate monster_gc, List<gridCoordinate> coord_list, Floor fl, bool mainHand)
        {
            int x_difference = monster_gc.x - pl_gc.x;
            int y_difference = monster_gc.y - pl_gc.y;

            int spear_range;
            if (mainHand)
            {
                if (x_difference == 0 || y_difference == 0)
                    spear_range = main_hand.get_my_range();
                else
                    spear_range = Math.Max(1, (main_hand.get_my_range()-1));
            }
            else
            {
                if (x_difference == 0 || y_difference == 0)
                    spear_range = off_hand.get_my_range();
                else
                    spear_range = Math.Max(1, (off_hand.get_my_range()-1));
            }

            bool blocked = false;
            for (int i = 0; i < spear_range; i++)
            {
                gridCoordinate square_to_attack = new gridCoordinate(pl_gc.x + (x_difference*(i+1)), pl_gc.y + (y_difference*(i+1)));
                if(fl.is_tile_passable(square_to_attack) && !blocked)
                    coord_list.Add(square_to_attack);
                else
                    blocked = true;
            }

            return coord_list;
        }
开发者ID:Chupaflor,项目名称:Cronkpit_Samples,代码行数:33,代码来源:Player.cs


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