コード例 #1
0
        /// <summary>
        /// Returns true if vehicle cannot traverse over or under the tile located at (x, y).
        /// A tile is considered to be blocked if it's low and high physics encompass the vehicles.
        /// </summary>
        /// <param name="x">x-coordinate of the tile</param>
        /// <param name="y">y-coordinate of the tile</param>
        /// <returns>True if tile is impassable</returns>
        public bool isTileBlocked(int x, int y, VehInfo vehicle)
        {
            if (vehicle == null)
            {
                return(false);
            }
            bool blocked = isTileBlocked(x, y);

            if (blocked)
            {
                x /= 16;
                y /= 16;
                int   phy  = Tiles[y * Width + x].Physics;
                short low  = PhysicsLow[phy];
                short high = PhysicsHigh[phy];

                //Typical man vehicle: LowZ = 0 HighZ = 55
                //Physic (Green): LowZ = 0 HighZ = 16

                //Can we pass under or over?
                if (vehicle.LowZ < low && vehicle.HighZ < high || vehicle.LowZ > low)
                {
                    blocked = false;   //Not blocked
                }
            }
            return(blocked);
        }
コード例 #2
0
ファイル: LvlInfo.cs プロジェクト: mizzouse/FreeInfantry
        /// <summary>
        /// Returns true if vehicle cannot traverse over the tile located at (x, y).
        /// A tile is considered to be blocked if it's low and high physics encompass the vehicles.
        /// </summary>
        /// <param name="x">x-coordinate of the tile</param>
        /// <param name="y">y-coordinate of the tile</param>
        /// <returns>True if tile is impassable</returns>
        public bool isTileBlocked(int x, int y, VehInfo vehicle)
        {
            if (vehicle == null)
            {
                return(false);
            }
            bool blocked = isTileBlocked(x, y);

            //Is this vehicle low enough to run under?
            if (blocked)
            {
                x /= 16;
                y /= 16;
                int   phy  = Tiles[y * Width + x].Physics;
                short low  = PhysicsLow[phy];
                short high = PhysicsHigh[phy];
                if (vehicle.LowZ <= low || vehicle.HighZ >= high)
                {
                    blocked = !blocked;
                }
            }
            return(blocked);
        }