示例#1
0
        public static void Do(Level lvl, ref PhysInfo C)
        {
            Random rand = lvl.physRandom;
            ushort x = C.X, y = C.Y, z = C.Z;

            // Make zombie fall down
            if (lvl.IsAirAt(x, (ushort)(y - 1), z))
            {
                lvl.AddUpdate(C.Index, Block.ZombieHead);
                lvl.AddUpdate(lvl.IntOffset(C.Index, 0, -1, 0), C.Block);
                lvl.AddUpdate(lvl.IntOffset(C.Index, 0, 1, 0), Block.Air);
                return;
            }
            bool   checkTime = true;
            Player closest   = HunterPhysics.ClosestPlayer(lvl, x, y, z);

            if (closest != null && rand.Next(1, 20) < 18)
            {
                ushort xx, zz;
                if (rand.Next(1, 7) <= 3)
                {
                    xx = (ushort)(x + Math.Sign(closest.Pos.BlockX - x));
                    if (xx != x && MoveZombie(lvl, ref C, xx, y, z))
                    {
                        return;
                    }

                    zz = (ushort)(z + Math.Sign(closest.Pos.BlockZ - z));
                    if (zz != z && MoveZombie(lvl, ref C, x, y, zz))
                    {
                        return;
                    }
                }
                else
                {
                    zz = (ushort)(z + Math.Sign(closest.Pos.BlockZ - z));
                    if (zz != z && MoveZombie(lvl, ref C, x, y, zz))
                    {
                        return;
                    }

                    xx = (ushort)(x + Math.Sign(closest.Pos.BlockX - x));
                    if (xx != x && MoveZombie(lvl, ref C, xx, y, z))
                    {
                        return;
                    }
                }
                checkTime = false;
            }

            if (checkTime && C.Data.Data < 3)
            {
                C.Data.Data++;
                return;
            }

            int dirsVisited = 0;

            switch (rand.Next(1, 13))
            {
            case 1:
            case 2:
            case 3:
                if (MoveZombie(lvl, ref C, (ushort)(x - 1), y, z))
                {
                    return;
                }

                dirsVisited++;
                if (dirsVisited >= 4)
                {
                    return;
                }
                goto case 4;

            case 4:
            case 5:
            case 6:
                if (MoveZombie(lvl, ref C, (ushort)(x + 1), y, z))
                {
                    return;
                }

                dirsVisited++;
                if (dirsVisited >= 4)
                {
                    return;
                }
                goto case 7;

            case 7:
            case 8:
            case 9:
                if (MoveZombie(lvl, ref C, x, y, (ushort)(z + 1)))
                {
                    return;
                }

                dirsVisited++;
                if (dirsVisited >= 4)
                {
                    return;
                }
                goto case 10;

            case 10:
            case 11:
            case 12:
                if (MoveZombie(lvl, ref C, x, y, (ushort)(z - 1)))
                {
                    return;
                }

                dirsVisited++;
                if (dirsVisited >= 4)
                {
                    return;
                }
                goto case 1;
            }
            lvl.AddUpdate(C.Index, Block.Air, default(PhysicsArgs));
            lvl.AddUpdate(lvl.IntOffset(C.Index, 0, 1, 0), Block.Air, default(PhysicsArgs));
        }
示例#2
0
        public static void Do(Level lvl, ref PhysInfo C)
        {
            Random rand = lvl.physRandom;
            ushort x = C.X, y = C.Y, z = C.Z;
            int    dirsVisited = 0;
            Player closest     = HunterPhysics.ClosestPlayer(lvl, x, y, z);

            if (closest != null && rand.Next(1, 20) < 19)
            {
                switch (rand.Next(1, 10))
                {
                case 1:
                case 2:
                case 3:
                    ushort xx = (ushort)(x + Math.Sign(closest.Pos.BlockX - x));
                    if (xx != x && MoveSnake(lvl, ref C, xx, y, z))
                    {
                        return;
                    }

                    dirsVisited++;
                    if (dirsVisited >= 3)
                    {
                        break;
                    }
                    goto case 4;

                case 4:
                case 5:
                case 6:
                    ushort yy = (ushort)(y + Math.Sign(closest.Pos.BlockY - y));
                    if (yy != y && MoveSnakeY(lvl, ref C, x, yy, z))
                    {
                        return;
                    }

                    dirsVisited++;
                    if (dirsVisited >= 3)
                    {
                        break;
                    }
                    goto case 7;

                case 7:
                case 8:
                case 9:
                    ushort zz = (ushort)(z + Math.Sign(closest.Pos.BlockZ - z));
                    if (zz != z && MoveSnake(lvl, ref C, x, y, zz))
                    {
                        return;
                    }

                    dirsVisited++;
                    if (dirsVisited >= 3)
                    {
                        break;
                    }
                    goto case 1;
                }
            }

            dirsVisited = 0;
            switch (rand.Next(1, 13))
            {
            case 1:
            case 2:
            case 3:
                if (MoveSnake(lvl, ref C, (ushort)(x - 1), y, z))
                {
                    return;
                }

                dirsVisited++;
                if (dirsVisited >= 4)
                {
                    return;
                }
                goto case 4;

            case 4:
            case 5:
            case 6:
                if (MoveSnake(lvl, ref C, (ushort)(x + 1), y, z))
                {
                    return;
                }

                dirsVisited++;
                if (dirsVisited >= 4)
                {
                    return;
                }
                goto case 7;

            case 7:
            case 8:
            case 9:
                if (MoveSnake(lvl, ref C, x, y, (ushort)(z + 1)))
                {
                    return;
                }

                dirsVisited++;
                if (dirsVisited >= 4)
                {
                    return;
                }
                goto case 10;

            case 10:
            case 11:
            case 12:
            default:
                if (MoveSnake(lvl, ref C, x, y, (ushort)(z - 1)))
                {
                    return;
                }

                dirsVisited++;
                if (dirsVisited >= 4)
                {
                    return;
                }
                goto case 1;
            }
        }