Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.Alpha0))
     {
         Creeper[] creepers = GameObject.FindObjectsOfType(typeof(Creeper)) as Creeper[];
         if (creepers.Length != 0)
         {
             bool    foundRight = false;
             Creeper creeper    = null;
             while (!foundRight)
             {
                 if (creepers.Length < 2)
                 {
                     foundRight = true;
                 }
                 creeper = creepers[Random.Range(0, creepers.Length)];
                 if (creeper.health > 0)
                 {
                     foundRight = true;
                 }
             }
             if (creeper.health > 0)
             {
                 creeper.doExplosion(creeper.health);
             }
         }
     }
 }
        public static void onStart(MCCSAPI api)
        {
            Creeper creeper = new Creeper(api);                                 //传递API参数

            api.addBeforeActListener(EventKey.onLevelExplode, creeper.Explode); //添加爆炸监听
            api.logout("苦力怕防爆插件加载成功 1.0 By:科幻大脑");
        }
Ejemplo n.º 3
0
        static void Main()
        {
            var profile = new SocialMediaProfile("Niki");

            var creeper = new Creeper();
            profile.Accept(creeper);
            Console.WriteLine(profile);

            var stalker = new Stalker();
            profile.Accept(stalker);
            Console.WriteLine(profile);
        }
Ejemplo n.º 4
0
        static void Main()
        {
            var profile = new SocialMediaProfile("MitioPishtovaPrezident");

            var creeper = new Creeper();

            profile.Accept(creeper);
            Console.WriteLine(profile);

            var stalker = new Stalker();

            profile.Accept(stalker);
            Console.WriteLine(profile);
        }
Ejemplo n.º 5
0
        static void Main()
        {
            var profile = new SocialMediaProfile("Niki");

            var creeper = new Creeper();

            profile.Accept(creeper);
            Console.WriteLine(profile);

            var stalker = new Stalker();

            profile.Accept(stalker);
            Console.WriteLine(profile);
        }
Ejemplo n.º 6
0
        public SummonControl()
        {
            InitializeComponent();
            this.DataContext = viewModel;

            Creeper creeper = new Creeper();

            creeper.Id = new TagString("id", "creeper");
            viewModel.Entities.Add(creeper);
            viewModel.Entities.Add(creeper);
            viewModel.Entities.Add(creeper);
            viewModel.Entities.Add(creeper);
            viewModel.Entities.Add(creeper);
            viewModel.Entities.Add(creeper);
            viewModel.Entities.Add(creeper);
            viewModel.Entities.Add(creeper);
        }
Ejemplo n.º 7
0
        public static Entity Create(this EntityType entityType, World world)
        {
            Entity entity = null;

            switch (entityType)
            {
            case EntityType.None:
                return(null);

            case EntityType.Chicken:
                entity = new Chicken(world);
                break;

            case EntityType.Cow:
                entity = new Cow(world);
                break;

            case EntityType.Pig:
                entity = new Pig(world);
                break;

            case EntityType.Sheep:
                entity = new Sheep(world);
                break;

            case EntityType.Wolf:
                entity = new Wolf(world);
                break;

            case EntityType.Villager:
                entity = new Villager(world);
                break;

            case EntityType.MushroomCow:
                entity = new Mooshroom(world);
                break;

            case EntityType.Squid:
                entity = new Squid(world);
                break;

            case EntityType.Rabbit:
                entity = new Rabbit(world);
                break;

            case EntityType.Bat:
                entity = new Bat(world);
                break;

            case EntityType.IronGolem:
                entity = new VillagerGolem(world);
                break;

            case EntityType.SnowGolem:
                entity = new Snowman(world);
                break;

            case EntityType.Ocelot:
                entity = new Ocelot(world);
                break;

            case EntityType.Zombie:
                entity = new Zombie(world);
                break;

            case EntityType.Creeper:
                entity = new Creeper(world);
                break;

            case EntityType.Skeleton:
                entity = new Skeleton(world);
                break;

            case EntityType.Spider:
                entity = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                entity = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                entity = new Slime(world);
                break;

            case EntityType.Endermite:
                entity = new Endermite(world);
                break;

            case EntityType.Enderman:
                entity = new Enderman(world);
                break;

            case EntityType.Silverfish:
                entity = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                entity = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                entity = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                entity = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                entity = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                entity = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                entity = new Witch(world);
                break;

            case EntityType.Stray:
                entity = new Stray(world);
                break;

            case EntityType.Husk:
                entity = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                entity = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                entity = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                entity = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                entity = new Horse(world);
                break;

            case EntityType.ZombieHorse:
                entity = new ZombieHorse(world);
                break;

            case EntityType.PolarBear:
                entity = new PolarBear(world);
                break;

            case EntityType.Shulker:
                entity = new Shulker(world);
                break;

            case EntityType.EnderDragon:
                entity = new EnderDragon(world);
                break;

            case EntityType.SkeletonHorse:
                entity = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                entity = new Wither(world);
                break;

            case EntityType.Evoker:
                entity = new EvocationIllager(world);
                break;

            case EntityType.Vindicator:
                entity = new VindicationIllager(world);
                break;

            case EntityType.Vex:
                entity = new Vex(world);
                break;

            case EntityType.FallingBlock:
                entity = new EntityFallingBlock(world, null);
                break;

            case EntityType.ArmorStand:
                entity = new EntityArmorStand(world, null);
                break;

            case EntityType.Arrow:
                entity = new ArrowEntity(world, null);
                break;

            case EntityType.Item:
                entity = new ItemEntity(world, null);
                break;

            case EntityType.Mooshroom:
                entity = new Mooshroom(world);
                break;

            case EntityType.Snowball:
                entity = new SnowballEntity(world, null);
                break;

            case EntityType.ThrownEgg:
                entity = new EggEntity(world, null);
                break;

            case EntityType.Salmon:
                entity = new Salmon(world);
                break;

            case EntityType.Donkey:
                entity = new Donkey(world);
                break;

            case EntityType.Llama:
                entity = new Llama(world);
                break;

            case EntityType.Mule:
                entity = new Mule(world);
                break;

            case EntityType.Fox:
                entity = new Fox(world);
                break;

            case EntityType.Parrot:
                entity = new Parrot(world);
                break;

            case EntityType.Phantom:
                entity = new Phantom(world);
                break;

            case EntityType.Bee:
                entity = new Bee(world);
                break;

            case EntityType.LlamaSpit:
                entity = new LlamaSpit(world);
                break;

            //case EntityType.Human:
            //entity = new PlayerMob("test", world, );
            //	break;
            default:
                return(null);
            }

            return(entity);
        }
Ejemplo n.º 8
0
        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            var coordinates = GetNewCoordinatesFromFace(blockCoordinates, face);

            Mob mob = null;

            EntityType type = (EntityType)Metadata;

            switch (type)
            {
            case EntityType.Chicken:
                mob = new Chicken(world);
                break;

            case EntityType.Cow:
                mob = new Cow(world);
                break;

            case EntityType.Pig:
                mob = new Pig(world);
                break;

            case EntityType.Sheep:
                mob = new Sheep(world);
                break;

            case EntityType.Wolf:
                mob = new Wolf(world);
                break;

            case EntityType.Npc:
                mob = new Villager(world);
                break;

            case EntityType.MushroomCow:
                mob = new MushroomCow(world);
                break;

            case EntityType.Squid:
                mob = new Squid(world);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(world);
                break;

            case EntityType.Bat:
                mob = new Bat(world);
                break;

            case EntityType.IronGolem:
                mob = new IronGolem(world);
                break;

            case EntityType.SnowGolem:
                mob = new SnowGolem(world);
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(world);
                break;

            case EntityType.Zombie:
                mob = new Zombie(world);
                break;

            case EntityType.Creeper:
                mob = new Creeper(world);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(world);
                break;

            case EntityType.Spider:
                mob = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                mob = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                mob = new Slime(world);
                break;

            case EntityType.Enderman:
                mob = new Enderman(world);
                break;

            case EntityType.Silverfish:
                mob = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                mob = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                mob = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                mob = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                mob = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                mob = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                mob = new Witch(world);
                break;
            }

            if (mob == null)
            {
                return;
            }

            mob.KnownPosition = new PlayerLocation(coordinates.X, coordinates.Y, coordinates.Z);
            mob.SpawnEntity();

            Log.WarnFormat("Player {0} spawned Mob #{1}.", player.Username, Metadata);
        }
Ejemplo n.º 9
0
        public void Summon(Player player, EntityTypeEnum entityType, bool noAi = true, BlockPos spawnPos = null)
        {
            EntityType petType;

            try
            {
                petType = (EntityType)Enum.Parse(typeof(EntityType), entityType.Value, true);
            }
            catch (ArgumentException e)
            {
                return;
            }

            if (!Enum.IsDefined(typeof(EntityType), petType))
            {
                player.SendMessage("No entity found");
                return;
            }

            var coordinates = player.KnownPosition;

            if (spawnPos != null)
            {
                if (spawnPos.XRelative)
                {
                    coordinates.X += spawnPos.X;
                }
                else
                {
                    coordinates.X = spawnPos.X;
                }

                if (spawnPos.YRelative)
                {
                    coordinates.Y += spawnPos.Y;
                }
                else
                {
                    coordinates.Y = spawnPos.Y;
                }

                if (spawnPos.ZRelative)
                {
                    coordinates.Z += spawnPos.Z;
                }
                else
                {
                    coordinates.Z = spawnPos.Z;
                }
            }

            var world = player.Level;

            Mob    mob    = null;
            Entity entity = null;

            EntityType type = (EntityType)(int)petType;

            switch (type)
            {
            case EntityType.Chicken:
                mob = new Chicken(world);
                break;

            case EntityType.Cow:
                mob = new Cow(world);
                break;

            case EntityType.Pig:
                mob = new Pig(world);
                break;

            case EntityType.Sheep:
                mob = new Sheep(world);
                break;

            case EntityType.Wolf:
                mob = new Wolf(world)
                {
                    Owner = player
                };
                break;

            case EntityType.Villager:
                mob = new Villager(world);
                break;

            case EntityType.MushroomCow:
                mob = new MushroomCow(world);
                break;

            case EntityType.Squid:
                mob = new Squid(world);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(world);
                break;

            case EntityType.Bat:
                mob = new Bat(world);
                break;

            case EntityType.IronGolem:
                mob = new IronGolem(world);
                break;

            case EntityType.SnowGolem:
                mob = new SnowGolem(world);
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(world);
                break;

            case EntityType.Zombie:
                mob = new Zombie(world);
                break;

            case EntityType.Creeper:
                mob = new Creeper(world);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(world);
                break;

            case EntityType.Spider:
                mob = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                mob = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                mob = new Slime(world);
                break;

            case EntityType.Enderman:
                mob = new Enderman(world);
                break;

            case EntityType.Silverfish:
                mob = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                mob = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                mob = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                mob = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                mob = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                mob = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                mob = new Witch(world);
                break;

            case EntityType.Stray:
                mob = new Stray(world);
                break;

            case EntityType.Husk:
                mob = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                mob = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                mob = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                mob = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                var random = new Random();
                mob = new Horse(world, random.NextDouble() < 0.10, random);
                break;

            case EntityType.PolarBear:
                mob = new PolarBear(world);
                break;

            case EntityType.Shulker:
                mob = new Shulker(world);
                break;

            case EntityType.Dragon:
                mob = new Dragon(world);
                break;

            case EntityType.SkeletonHorse:
                mob = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                mob = new Wither(world);
                break;

            case EntityType.Evoker:
                mob = new Evoker(world);
                break;

            case EntityType.Vindicator:
                mob = new Vindicator(world);
                break;

            case EntityType.Vex:
                mob = new Vex(world);
                break;

            case EntityType.Npc:
                if (Config.GetProperty("EnableEdu", false))
                {
                    mob = new Npc(world);
                }
                else
                {
                    mob = new PlayerMob("test", world);
                }
                break;

            case EntityType.Boat:
                entity = new Boat(world);
                break;
            }

            if (mob != null)
            {
                mob.NoAi = noAi;
                var direction = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f;
                mob.KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw, coordinates.Yaw);
                mob.SpawnEntity();
            }
            else if (entity != null)
            {
                entity.NoAi = noAi;
                var direction = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f;
                entity.KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw, coordinates.Yaw);
                entity.SpawnEntity();
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (GH_Document.IsEscapeKeyDown())
            {
                GH_Document GHDocument = OnPingDocument();
                GHDocument.RequestAbortSolution();
                return;
            }

            ikvm.runtime.Startup.addBootClassPathAssemby(Assembly.Load("culebra"));
            ikvm.runtime.Startup.addBootClassPathAssemby(Assembly.Load("IKVM.OpenJDK.Core"));

            bool           reset           = new bool();
            int            iterations      = new int();
            List <object>  init_Settings   = new List <object>();
            List <object>  move_Settings   = new List <object>();
            IGH_VisualData visual_Settings = null;

            object behavioral_Settings = null;

            if (!DA.GetDataList(0, init_Settings) || init_Settings.Count == 0 || init_Settings == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Init Settings Detected, please connect Init Settings to enable the component");
                return;
            }
            if (!DA.GetDataList(1, move_Settings) || move_Settings.Count == 0 || move_Settings == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Move Settings Detected, please connect Move Settings to enable the component");
                return;
            }
            if (!DA.GetData(3, ref visual_Settings) || visual_Settings == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Visual Settings Detected, please connect Visual Settings to enable the component");
                return;
            }
            if (!DA.GetData(4, ref iterations))
            {
                return;
            }
            if (!DA.GetData(5, ref reset))
            {
                return;
            }
            Random rnd = new Random();

            if (!DA.GetData(2, ref behavioral_Settings) || behavioral_Settings == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Input Object is Null");
                return;
            }
            string objtype = behavioral_Settings.GetType().Name.ToString();

            if (!(behavioral_Settings.GetType() == typeof(IGH_BehaviorData)))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "You did not input a Behavior Data Object, please ensure input is Behavior Data Object and not " + objtype);
                return;
            }
            else
            {
                #region Initialize / Data Parse
                //------------------------Init Settings--------------------------
                if (init_Settings.Count != 0)
                {
                    String init_Convert = "";
                    if (init_Settings[0].GetType() == typeof(GH_String))
                    {
                        GH_String value = (GH_String)init_Settings[0];
                        init_Convert = value.Value;
                    }
                    if (init_Convert == "Box")
                    {
                        this.spawnData = "box";
                        GH_Convert.ToBox_Primary(init_Settings[3], ref this.box);
                        GH_Convert.ToInt32(init_Settings[4], out this.spawnType, GH_Conversion.Primary);
                        GH_Convert.ToInt32(init_Settings[5], out this.pointCount, GH_Conversion.Primary);
                        GH_Convert.ToInt32(init_Settings[1], out this.dimensions, GH_Conversion.Primary);
                    }
                    else if (init_Convert == "Points")
                    {
                        this.spawnData = "Points";
                        var wrapperToGoo = GH_Convert.ToGoo(init_Settings[3]);
                        wrapperToGoo.CastTo <List <Point3d> >(out this.ptList);
                        GH_Convert.ToInt32(init_Settings[1], out this.dimensions, GH_Conversion.Primary);
                        GH_Convert.ToBox_Primary(init_Settings[4], ref this.box);
                    }
                    GH_Convert.ToInt32(init_Settings[2], out this.bounds, GH_Conversion.Primary);
                }
                //------------------------Move Settings--------------------------
                Vector3d initialVector = new Vector3d();
                if (move_Settings.Count != 0)
                {
                    if (move_Settings[0].GetType() == typeof(GH_Vector))
                    {
                        GH_Vector value = (GH_Vector)move_Settings[0];
                        initialVector = value.Value;
                    }
                    else if (move_Settings[0].GetType() == typeof(GH_Number))
                    {
                        GH_Number value = (GH_Number)move_Settings[0];
                        this.initialSpeed = value.Value;
                    }
                    GH_Convert.ToDouble(move_Settings[1], out this.maxSpeed, GH_Conversion.Primary);
                    GH_Convert.ToDouble(move_Settings[2], out this.maxForce, GH_Conversion.Primary);
                    GH_Convert.ToDouble(move_Settings[3], out this.velMultiplier, GH_Conversion.Primary);
                }
                //------------------------Visual Settings--------------------------
                TrailData td = visual_Settings.Value.trailData;
                ColorData cd = visual_Settings.Value.colorData;
                this.trail           = td.createTrail;
                this.displayMode     = visual_Settings.Value.displayMode;
                this.trailStep       = td.trailStep;
                this.maxTrailSize    = td.maxTrailSize;
                this.particleTexture = cd.particleTexture;
                this.graphicType     = cd.colorDataType;
                this.useTexture      = visual_Settings.Value.useTexture;
                if (cd.colorDataType == "Gradient")
                {
                    this.maxthick       = cd.maxThickness;
                    this.minthick       = cd.minThickness;
                    this.redValues[0]   = cd.redChannel[0];
                    this.redValues[1]   = cd.redChannel[1];
                    this.greenValues[0] = cd.greenChannel[0];
                    this.greenValues[1] = cd.greenChannel[1];
                    this.blueValues[0]  = cd.blueChannel[0];
                    this.blueValues[1]  = cd.blueChannel[1];
                }
                else if (cd.colorDataType == "GraphicPolyline")
                {
                    this.polylineColor = cd.color;
                    this.dotted        = cd.dotted;
                    this.maxthick      = cd.maxThickness;
                }
                else if (cd.colorDataType == "Disco")
                {
                    this.maxthick = cd.maxThickness;
                    this.minthick = cd.minThickness;
                }
                else if (cd.colorDataType == "Base")
                {
                    this.maxthick = 3;
                    this.minthick = 1;
                }
                //-----------------------------------------------------------------
                IGH_PreviewObject comp = (IGH_PreviewObject)this;
                if (comp.Hidden && (this.displayMode == 0))
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Component preview must be enabled to see Graphic Mode on Canvas, right click on component and set preview on");
                }
                #endregion
                #region Pre Simulation Code
                //------------------------RESET STARTS HERE--------------------------
                if (reset)
                { //We are using the reset to reinitialize all the variables and positions
                    //-----------------------------------------------------------------
                    this.bb = new BoundingBox();
                    int  loopCount = new int();
                    bool create    = new bool();
                    if (this.spawnData == "box")
                    {
                        this.bb   = this.box.BoundingBox;
                        loopCount = this.pointCount;
                        create    = true;
                    }
                    else if (this.spawnData == "Points")
                    {
                        loopCount = this.ptList.Count;
                        create    = false;
                        this.bb   = this.box.BoundingBox;
                    }
                    //-----------------------------------------------------------------
                    this.moveList       = new List <Vector3d>();
                    this.startList      = new List <Vector3d>();
                    this.creepList      = new List <CulebraObject>();
                    this.currentPosList = new List <Point3d>();
                    this.networkList    = new List <Line>();
                    flattenedTrails     = new List <Vector3d>();

                    for (int i = 0; i < loopCount; i++)
                    {
                        if (this.dimensions == 0)
                        { //If we want 2D
                            General.setViewport("Top", "Shaded");
                            if (create)
                            { //If are creating random points inside bbox
                                if (this.spawnType == 0 || this.spawnType == 2)
                                {
                                    this.startPos = new Vector3d((int)bb.Min[0], rnd.Next((int)bb.Min[1], (int)bb.Max[1]), 0); //spawn along the y axis of the bounding area
                                }
                                else if (this.spawnType == 1 || this.spawnType == 3)
                                {
                                    this.startPos = new Vector3d(rnd.Next((int)bb.Min[0], (int)bb.Max[0]), rnd.Next((int)bb.Min[1], (int)bb.Max[1]), 0); //spawn randomly inside the bounding area
                                }
                                if (initialVector.Length > 0)
                                {
                                    this.moveVec = initialVector; //move in the user specified direction
                                }
                                else
                                {
                                    this.moveVec = new Vector3d(rnd.Next(-1, 2) * initialSpeed, rnd.Next(-1, 2) * initialSpeed, 0); //move randomly in any direction 2d
                                }
                            }
                            else
                            { //If we are using user defined points
                                this.startPos = (Vector3d)this.ptList[i];
                                if (initialVector.Length > 0)
                                {
                                    this.moveVec = initialVector; //move in the user specified direction
                                }
                                else
                                {
                                    this.moveVec = new Vector3d(rnd.Next(-1, 2) * initialSpeed, rnd.Next(-1, 2) * initialSpeed, 0); //move randomly in any direction 2d
                                }
                            }
                            this.creep = new Creeper(this.startPos, this.moveVec, true, false);
                            this.creepList.Add(this.creep);
                        }
                        else
                        { //If we want 3D
                            General.setViewport("Perspective", "Shaded");
                            if (create)
                            { //If are creating random points inside bbox
                                if (this.spawnType == 0 || this.spawnType == 2)
                                {
                                    this.startPos = new Vector3d(rnd.Next((int)bb.Min[0], (int)bb.Max[0]), rnd.Next((int)bb.Min[1], (int)bb.Max[1]), (int)bb.Min[2]); //start randomly on the lowest plane of the 3d bounds
                                    if (initialVector.Length > 0)
                                    {
                                        this.moveVec = initialVector; //move in the user specified direction
                                    }
                                    else
                                    {
                                        this.moveVec = new Vector3d(rnd.Next(-2, 2) * initialSpeed, rnd.Next(-2, 2) * initialSpeed, 1 * initialSpeed); //move randomly in the xy axis and up in the z axis
                                    }
                                }
                                else if (this.spawnType == 1 || this.spawnType == 3)
                                {
                                    this.startPos = new Vector3d(rnd.Next((int)bb.Min[0], (int)bb.Max[0]), rnd.Next((int)bb.Min[1], (int)bb.Max[1]), rnd.Next((int)bb.Min[2], (int)bb.Max[2])); //start randomly inside the 3d bounds
                                    if (initialVector.Length > 0)
                                    {
                                        this.moveVec = initialVector; //move in the user specified direction
                                    }
                                    else
                                    {
                                        this.moveVec = new Vector3d(rnd.Next(-2, 2) * initialSpeed, rnd.Next(-2, 2) * initialSpeed, rnd.Next(-2, 2) * initialSpeed); //move randomly in any direction 3d
                                    }
                                }
                            }
                            else
                            { //If we are using user defined points
                                this.startPos = (Vector3d)this.ptList[i];
                                if (initialVector.Length > 0)
                                {
                                    this.moveVec = initialVector; //move in the user specified direction
                                }
                                else
                                {
                                    this.moveVec = new Vector3d(rnd.Next(-2, 2) * initialSpeed, rnd.Next(-2, 2) * initialSpeed, rnd.Next(-2, 2) * initialSpeed); //move randomly in any direction 3d
                                }
                            }
                            this.creep = new Creeper(this.startPos, this.moveVec, true, true);
                            this.creepList.Add(this.creep);
                        }
                        this.startList.Add(this.startPos); //add the initial starting positions to the list to pass once we start running
                        this.moveList.Add(this.moveVec);   //add the initial move vectors to the list to pass once we start running
                    }
                    #endregion
                    #region Simulation Code
                    this.trailTree    = new DataTree <Point3d>();
                    this.globalEngine = new Engine_Global();
                    for (int z = 0; z < iterations; z++)
                    {
                        this.particleSet    = new DataTree <Point3d>();
                        this.currentPosList = new List <Point3d>();

                        this.trailTree.Clear();
                        this.networkTree.Clear();
                        this.trailTree.TrimExcess();
                        this.networkTree.TrimExcess();

                        if (this.moveList == null)
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Please Reset the CreepyCrawlers Component"); return;
                        }
                        try
                        {
                            globalEngine.Action(this.creepList, this.dimensions, behavioral_Settings, this.displayMode, this.networkList,
                                                this.maxSpeed, this.maxForce, this.velMultiplier, this.flattenedTrails, this.particleList, this.particleSet, networkTree, trailStep, maxTrailSize, bounds, bb, currentPosList, trail, trailTree);
                        }
                        catch (Exception e)
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message.ToString());
                            return;
                        }

                        this.flattenedTrails.Clear();
                        this.flattenedTrails.TrimExcess();

                        #endregion
                    }
                    DA.SetDataList(0, this.currentPosList);
                    DA.SetDataTree(2, networkTree);
                    if (this.displayMode == 1 && this.trail)
                    {
                        DA.SetDataTree(1, trailTree);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        private bool Spawn(PlayerLocation position, EntityType entityType)
        {
            Level world = Level;
            Mob   mob   = null;

            switch (entityType)
            {
            case EntityType.Chicken:
                mob      = new Chicken(world);
                mob.NoAi = true;
                break;

            case EntityType.Cow:
                mob      = new Cow(world);
                mob.NoAi = true;
                break;

            case EntityType.Pig:
                mob      = new Pig(world);
                mob.NoAi = true;
                break;

            case EntityType.Sheep:
                mob      = new Sheep(world);
                mob.NoAi = true;
                break;

            case EntityType.Wolf:
                mob      = new Wolf(world);
                mob.NoAi = true;
                break;

            case EntityType.Horse:
                mob      = new Horse(world);
                mob.NoAi = true;
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(world);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(world);
                break;

            case EntityType.Spider:
                mob = new Spider(world);
                break;

            case EntityType.Zombie:
                mob = new Zombie(world);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(world);
                break;

            case EntityType.Enderman:
                mob = new Enderman(world);
                break;

            case EntityType.Creeper:
                mob = new Creeper(world);
                break;
            }

            if (mob == null)
            {
                return(false);
            }

            mob.DespawnIfNotSeenPlayer = true;
            mob.KnownPosition          = position;
            var bbox = mob.GetBoundingBox();

            if (!SpawnAreaClear(bbox))
            {
                return(false);
            }

            ThreadPool.QueueUserWorkItem(state => mob.SpawnEntity());

            if (Log.IsDebugEnabled)
            {
                Log.Warn($"Spawn mob {entityType}");
            }
            return(true);
        }
Ejemplo n.º 12
0
 public void CreeperArrived(Creeper creeper)
 {
     CreeperDied(creeper, 0);
     lives--;
     if(lives <= 0)
     {
         EndGame();
     }
     //var creeperObj = GameObject.Instantiate(creeper1Prefab) as GameObject;
     //var p = creeperStartPosition;
     //p.y = creeperObj.transform.position.y;
     //creeperObj.transform.position = p;
     //allCreepers.Add(creeperObj.GetComponent<Creeper>());
 }
Ejemplo n.º 13
0
        public static Entity Create(this EntityType entityType, Level world)
        {
            Entity entity = null;

            switch (entityType)
            {
            case EntityType.None:
                return(null);

            case EntityType.Chicken:
                entity = new Chicken(world);
                break;

            case EntityType.Cow:
                entity = new Cow(world);
                break;

            case EntityType.Pig:
                entity = new Pig(world);
                break;

            case EntityType.Sheep:
                entity = new Sheep(world);
                break;

            case EntityType.Wolf:
                entity = new Wolf(world);
                break;

            case EntityType.Villager:
                entity = new Villager(world);
                break;

            case EntityType.MushroomCow:
                entity = new MushroomCow(world);
                break;

            case EntityType.Squid:
                entity = new Squid(world);
                break;

            case EntityType.Rabbit:
                entity = new Rabbit(world);
                break;

            case EntityType.Bat:
                entity = new Bat(world);
                break;

            case EntityType.IronGolem:
                entity = new IronGolem(world);
                break;

            case EntityType.SnowGolem:
                entity = new SnowGolem(world);
                break;

            case EntityType.Ocelot:
                entity = new Ocelot(world);
                break;

            case EntityType.Zombie:
                entity = new Zombie(world);
                break;

            case EntityType.Creeper:
                entity = new Creeper(world);
                break;

            case EntityType.Skeleton:
                entity = new Skeleton(world);
                break;

            case EntityType.Spider:
                entity = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                entity = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                entity = new Slime(world);
                break;

            case EntityType.Enderman:
                entity = new Enderman(world);
                break;

            case EntityType.Silverfish:
                entity = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                entity = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                entity = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                entity = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                entity = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                entity = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                entity = new Witch(world);
                break;

            case EntityType.Stray:
                entity = new Stray(world);
                break;

            case EntityType.Husk:
                entity = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                entity = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                entity = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                entity = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                var random = new Random();
                entity = new Horse(world, random.NextDouble() < 0.10, random);
                break;

            case EntityType.PolarBear:
                entity = new PolarBear(world);
                break;

            case EntityType.Shulker:
                entity = new Shulker(world);
                break;

            case EntityType.Dragon:
                entity = new Dragon(world);
                break;

            case EntityType.SkeletonHorse:
                entity = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                entity = new Wither(world);
                break;

            case EntityType.Evoker:
                entity = new Evoker(world);
                break;

            case EntityType.Vindicator:
                entity = new Vindicator(world);
                break;

            case EntityType.Vex:
                entity = new Vex(world);
                break;

            case EntityType.Npc:
                entity = new PlayerMob("test", world);
                break;

            default:
                return(null);
            }

            return(entity);
        }
Ejemplo n.º 14
0
        public void CommandSpawnMob(MiNET.Player player, string entityName, string mobName = "", string mobScale = "")
        {
            if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin))
            {
                player.SendMessage("§c§l(!)§r §cYou do not have permission for this command.");
                return;
            }

            entityName = entityName.ToLower();
            entityName = entityName.Substring(0, 1).ToUpper() + entityName.Substring(1);

            if (!Enum.TryParse(entityName, out EntityType entityType))
            {
                player.SendMessage($"§c§l(!) §r§cUnknown EntityType '{entityName}'");
                return;
            }

            Level level = player.Level;

            Mob mob = null;

            switch (entityType)
            {
            case EntityType.Chicken:
                mob = new Chicken(level);
                break;

            case EntityType.Cow:
                mob = new Cow(level);
                break;

            case EntityType.Pig:
                mob = new Pig(level);
                break;

            case EntityType.Sheep:
                mob = new Sheep(level);
                break;

            case EntityType.Wolf:
                mob = new Wolf(level)
                {
                    Owner = player
                };
                break;

            case EntityType.Villager:
                mob = new Villager(level);
                break;

            case EntityType.MushroomCow:
                mob = new MushroomCow(level);
                break;

            case EntityType.Squid:
                mob = new Squid(level);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(level);
                break;

            case EntityType.Bat:
                mob = new Bat(level);
                break;

            case EntityType.IronGolem:
                mob = new IronGolem(level);
                break;

            case EntityType.SnowGolem:
                mob = new SnowGolem(level);
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(level);
                break;

            case EntityType.Zombie:
                mob = new Zombie(level);
                break;

            case EntityType.Creeper:
                mob = new Creeper(level);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(level);
                break;

            case EntityType.Spider:
                mob = new Spider(level);
                break;

            case EntityType.ZombiePigman:
                mob = new ZombiePigman(level);
                break;

            case EntityType.Slime:
                mob = new MiNET.Entities.Hostile.Slime(level);
                break;

            case EntityType.Enderman:
                mob = new Enderman(level);
                break;

            case EntityType.Silverfish:
                mob = new Silverfish(level);
                break;

            case EntityType.CaveSpider:
                mob = new CaveSpider(level);
                break;

            case EntityType.Ghast:
                mob = new Ghast(level);
                break;

            case EntityType.MagmaCube:
                mob = new MagmaCube(level);
                break;

            case EntityType.Blaze:
                mob = new Blaze(level);
                break;

            case EntityType.ZombieVillager:
                mob = new ZombieVillager(level);
                break;

            case EntityType.Witch:
                mob = new Witch(level);
                break;

            case EntityType.Stray:
                mob = new Stray(level);
                break;

            case EntityType.Husk:
                mob = new Husk(level);
                break;

            case EntityType.WitherSkeleton:
                mob = new WitherSkeleton(level);
                break;

            case EntityType.Guardian:
                mob = new Guardian(level);
                break;

            case EntityType.ElderGuardian:
                mob = new ElderGuardian(level);
                break;

            case EntityType.Horse:
                mob = new Horse(level);
                break;

            case EntityType.PolarBear:
                mob = new PolarBear(level);
                break;

            case EntityType.Shulker:
                mob = new Shulker(level);
                break;

            case EntityType.Dragon:
                mob = new Dragon(level);
                break;

            case EntityType.SkeletonHorse:
                mob = new SkeletonHorse(level);
                break;

            case EntityType.Wither:
                mob = new Wither(level);
                break;

            case EntityType.Evoker:
                mob = new Evoker(level);
                break;

            case EntityType.Vindicator:
                mob = new Vindicator(level);
                break;

            case EntityType.Vex:
                mob = new Vex(level);
                break;

            case EntityType.Npc:
                mob = new PlayerMob("test", level);
                break;
            }

            if (!String.IsNullOrEmpty(mobName))
            {
                mob.NameTag          = mobName.Replace("&", "§");
                mob.HideNameTag      = false;
                mob.IsAlwaysShowName = true;
            }

            if (!String.IsNullOrEmpty(mobScale))
            {
                try
                {
                    mob.Scale = Double.Parse(mobScale);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }

            mob.KnownPosition = (PlayerLocation)player.KnownPosition.Clone();
            mob.SpawnEntity();

            player.SendMessage($"§e§l(!) §r§eSpawned new {entityType}");
        }
Ejemplo n.º 15
0
 public CreeperSwellBehavior(Creeper entity)
 {
     this._entity = entity;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Filters through the Controller Data
        /// </summary>
        private void FilterBehaviors(Creeper c, List <CulebraObject> creepList, object behavioral_Settings, int dimensions, List <Vector3d> childSpawners, List <int> childSpawnType, List <Vector3d> totTail)
        {
            IGH_BehaviorData igh_Behavior = (IGH_BehaviorData)behavioral_Settings;

            foreach (string s in igh_Behavior.Value.dataOrder)
            {
                if (s == "Flocking")
                {
                    if (dimensions == 0)
                    {
                        if (igh_Behavior.Value.flockData.colorMesh != null)
                        {
                            c.behaviors.Flock2D(igh_Behavior.Value.flockData.searchRadius, igh_Behavior.Value.flockData.cohesion_Value, igh_Behavior.Value.flockData.separation_Value, igh_Behavior.Value.flockData.alignment_Value, igh_Behavior.Value.flockData.viewAngle, creepList,
                                                igh_Behavior.Value.flockData.network, igh_Behavior.Value.flockData.mapAlignment, igh_Behavior.Value.flockData.mapSeparation, igh_Behavior.Value.flockData.mapCohesion, igh_Behavior.Value.flockData.colorMesh);
                        }
                        else
                        {
                            c.behaviors.Flock2D(igh_Behavior.Value.flockData.searchRadius, igh_Behavior.Value.flockData.cohesion_Value, igh_Behavior.Value.flockData.separation_Value, igh_Behavior.Value.flockData.alignment_Value, igh_Behavior.Value.flockData.viewAngle, creepList, igh_Behavior.Value.flockData.network);
                        }
                    }
                    else if (dimensions == 1)
                    {
                        if (igh_Behavior.Value.flockData.colorMesh != null)
                        {
                            c.behaviors.Flock3D(igh_Behavior.Value.flockData.searchRadius, igh_Behavior.Value.flockData.cohesion_Value, igh_Behavior.Value.flockData.separation_Value, igh_Behavior.Value.flockData.alignment_Value, igh_Behavior.Value.flockData.viewAngle, creepList,
                                                igh_Behavior.Value.flockData.network, igh_Behavior.Value.flockData.mapAlignment, igh_Behavior.Value.flockData.mapSeparation, igh_Behavior.Value.flockData.mapCohesion, igh_Behavior.Value.flockData.colorMesh);
                        }
                        else
                        {
                            c.behaviors.Flock3D(igh_Behavior.Value.flockData.searchRadius, igh_Behavior.Value.flockData.cohesion_Value, igh_Behavior.Value.flockData.separation_Value, igh_Behavior.Value.flockData.alignment_Value, igh_Behavior.Value.flockData.viewAngle, creepList, igh_Behavior.Value.flockData.network);
                        }
                    }
                }
                else if (s == "Bundling")
                {
                    throw new Exception("You have input bundling behavior, Creepers engine cannot run bundling behavior, please use Bundling Engine");
                }
                else if (s == "Wandering")
                {
                    if (dimensions == 0)
                    {
                        if (igh_Behavior.Value.wanderData.wanderingType == "Wander")
                        {
                            if (igh_Behavior.Value.wanderData.colorMesh != null)
                            {
                                c.behaviors.Wander2D(igh_Behavior.Value.wanderData.randomize, igh_Behavior.Value.wanderData.addHeading, igh_Behavior.Value.wanderData.change, igh_Behavior.Value.wanderData.wanderingRadius, igh_Behavior.Value.wanderData.wanderingDistance,
                                                     igh_Behavior.Value.wanderData.mapChange, igh_Behavior.Value.wanderData.mapRadius, igh_Behavior.Value.wanderData.mapDistance, igh_Behavior.Value.wanderData.colorMesh);
                            }
                            else
                            {
                                c.behaviors.Wander2D(igh_Behavior.Value.wanderData.randomize, igh_Behavior.Value.wanderData.addHeading, igh_Behavior.Value.wanderData.change, igh_Behavior.Value.wanderData.wanderingRadius, igh_Behavior.Value.wanderData.wanderingDistance);
                            }
                        }
                        else
                        {
                            c.behaviors.SuperWander2D(igh_Behavior.Value.wanderData.change, igh_Behavior.Value.wanderData.wanderingRadius, igh_Behavior.Value.wanderData.wanderingDistance, igh_Behavior.Value.wanderData.rotationTrigger);
                        }
                    }
                    else if (dimensions == 1)
                    {
                        if (igh_Behavior.Value.wanderData.wanderingType == "SuperWander_B")
                        {
                            c.behaviors.Wander3D_subA(igh_Behavior.Value.wanderData.change, igh_Behavior.Value.wanderData.wanderingRadius, igh_Behavior.Value.wanderData.wanderingDistance, igh_Behavior.Value.wanderData.rotationTrigger);
                        }
                        else if (igh_Behavior.Value.wanderData.wanderingType == "SuperWander_C")
                        {
                            c.behaviors.Wander3D_subB(igh_Behavior.Value.wanderData.change, igh_Behavior.Value.wanderData.wanderingRadius, igh_Behavior.Value.wanderData.wanderingDistance, igh_Behavior.Value.wanderData.rotationTrigger);
                        }
                        else
                        {
                            if (igh_Behavior.Value.wanderData.colorMesh != null)
                            {
                                c.behaviors.Wander3D(igh_Behavior.Value.wanderData.change, igh_Behavior.Value.wanderData.wanderingRadius, igh_Behavior.Value.wanderData.wanderingDistance, igh_Behavior.Value.wanderData.rotationTrigger,
                                                     igh_Behavior.Value.wanderData.mapChange, igh_Behavior.Value.wanderData.mapRadius, igh_Behavior.Value.wanderData.mapDistance, false, igh_Behavior.Value.wanderData.colorMesh);
                            }
                            else
                            {
                                c.behaviors.Wander3D(igh_Behavior.Value.wanderData.change, igh_Behavior.Value.wanderData.wanderingRadius, igh_Behavior.Value.wanderData.wanderingDistance, igh_Behavior.Value.wanderData.rotationTrigger);
                            }
                        }
                    }
                }
                else if (s == "Tracking")
                {
                    if (igh_Behavior.Value.trackingData.triggerBabies)
                    {
                        if (igh_Behavior.Value.trackingData.colorMesh != null)
                        {
                            c.behaviors.MultiPolylineTrackerBabyMaker(igh_Behavior.Value.trackingData.polylines, igh_Behavior.Value.trackingData.pathThreshold, igh_Behavior.Value.trackingData.projectionDistance, igh_Behavior.Value.trackingData.pathRadius,
                                                                      igh_Behavior.Value.trackingData.triggerBabies, igh_Behavior.Value.trackingData.maxChildren, true, childSpawners, childSpawnType,
                                                                      igh_Behavior.Value.trackingData.mapThreshold, igh_Behavior.Value.trackingData.mapProjection, igh_Behavior.Value.trackingData.mapRadius, igh_Behavior.Value.trackingData.colorMesh);
                            this.childSpawners  = c.behaviors.GetChildStartPositions();
                            this.childSpawnType = c.behaviors.GetChildSpawnTypes();
                        }
                        else
                        {
                            c.behaviors.MultiPolylineTrackerBabyMaker(igh_Behavior.Value.trackingData.polylines, igh_Behavior.Value.trackingData.pathThreshold, igh_Behavior.Value.trackingData.projectionDistance, igh_Behavior.Value.trackingData.pathRadius,
                                                                      igh_Behavior.Value.trackingData.triggerBabies, igh_Behavior.Value.trackingData.maxChildren, true, childSpawners, childSpawnType);
                            this.childSpawners  = c.behaviors.GetChildStartPositions();
                            this.childSpawnType = c.behaviors.GetChildSpawnTypes();
                        }
                    }
                    else
                    {
                        if (igh_Behavior.Value.trackingData.colorMesh != null)
                        {
                            c.behaviors.MultiPolylineTracker(igh_Behavior.Value.trackingData.polylines, igh_Behavior.Value.trackingData.pathThreshold, igh_Behavior.Value.trackingData.projectionDistance, igh_Behavior.Value.trackingData.pathRadius,
                                                             igh_Behavior.Value.trackingData.mapThreshold, igh_Behavior.Value.trackingData.mapProjection, igh_Behavior.Value.trackingData.mapRadius, igh_Behavior.Value.trackingData.colorMesh);
                        }
                        else
                        {
                            c.behaviors.MultiPolylineTracker(igh_Behavior.Value.trackingData.polylines, igh_Behavior.Value.trackingData.pathThreshold, igh_Behavior.Value.trackingData.projectionDistance, igh_Behavior.Value.trackingData.pathRadius);
                        }
                    }
                }
                else if (s == "Crawl")
                {
                    if (igh_Behavior.Value.meshCrawlData.triggerBabies)
                    {
                        c.behaviors.MeshWalk(igh_Behavior.Value.meshCrawlData.mesh, igh_Behavior.Value.meshCrawlData.meshThreshold, igh_Behavior.Value.meshCrawlData.meshProjectionDistance, igh_Behavior.Value.meshCrawlData.multiplier, igh_Behavior.Value.meshCrawlData.triggerBabies, true, igh_Behavior.Value.meshCrawlData.maxChildren, childSpawners, childSpawnType);
                        this.childSpawners  = c.behaviors.GetMeshCrawler().GetChildStartPositions();
                        this.childSpawnType = c.behaviors.GetMeshCrawler().GetChildSpawnType();
                    }
                    else
                    {
                        c.behaviors.MeshWalk(igh_Behavior.Value.meshCrawlData.mesh, igh_Behavior.Value.meshCrawlData.meshThreshold, igh_Behavior.Value.meshCrawlData.meshProjectionDistance, igh_Behavior.Value.meshCrawlData.multiplier);
                    }
                }
                else if (s == "Stigmergy")
                {
                    totTail.AddRange(c.attributes.GetTrailVectors());
                    c.behaviors.SelfTailChase(igh_Behavior.Value.stigmergyData.viewAngle, igh_Behavior.Value.stigmergyData.cohesionMagnitude, igh_Behavior.Value.stigmergyData.cohesionRange, igh_Behavior.Value.stigmergyData.separationMagnitude, igh_Behavior.Value.stigmergyData.separationRange, totTail);
                }
                else if (s == "Noise")
                {
                    if (igh_Behavior.Value.noiseData.colorMesh != null)
                    {
                        c.behaviors.Perlin2DMap(igh_Behavior.Value.noiseData.scale, igh_Behavior.Value.noiseData.strength, igh_Behavior.Value.noiseData.multiplier, igh_Behavior.Value.noiseData.velocity,
                                                igh_Behavior.Value.noiseData.mapStrength, igh_Behavior.Value.noiseData.mapStrength, igh_Behavior.Value.noiseData.mapMultiplier, igh_Behavior.Value.noiseData.colorMesh);
                    }
                    else
                    {
                        c.behaviors.Perlin(igh_Behavior.Value.noiseData.scale, igh_Behavior.Value.noiseData.strength, igh_Behavior.Value.noiseData.multiplier, igh_Behavior.Value.noiseData.velocity);
                    }
                }
                else if (s == "Separation")
                {
                    c.behaviors.Separate(igh_Behavior.Value.separationData.maxSeparation, creepList);
                }
                else if (s == "Force")
                {
                    int forceAmount = igh_Behavior.Value.forceData.Count;
                    for (int i = 0; i < forceAmount; i++)
                    {
                        if (igh_Behavior.Value.forceData[i].forceType == "Attract")
                        {
                            int attCount = 0;
                            foreach (Point3d p in igh_Behavior.Value.forceData[i].targets)
                            {
                                c.behaviors.Attract((Vector3d)p, igh_Behavior.Value.forceData[i].thresholds[attCount], igh_Behavior.Value.forceData[i].attractionValue, igh_Behavior.Value.forceData[i].maxAttraction);
                                attCount++;
                            }
                        }
                        else if (igh_Behavior.Value.forceData[i].forceType == "Repel")
                        {
                            int attCount = 0;
                            foreach (Point3d p in igh_Behavior.Value.forceData[i].targets)
                            {
                                c.behaviors.Repel((Vector3d)p, igh_Behavior.Value.forceData[i].thresholds[attCount], igh_Behavior.Value.forceData[i].repelValue, igh_Behavior.Value.forceData[i].maxRepel);
                                attCount++;
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception("Houston we have a problem, no behavior data read");
                }
            }
        }
Ejemplo n.º 17
0
 // GET: api/Singer
 public SearchData Get([FromBody] string keyword)
 {
     return(Creeper.GetSearchResult(keyword));
 }
Ejemplo n.º 18
0
    void Attack()
    {
        GameObject e = GetAttackedEnemy();

        if (e.GetComponent <Enemy>().Script.GetType().Equals(typeof(Zombie)))
        {
            Zombie enemy = e.GetComponent <Enemy>().Script as Zombie;

            if (LeftMousePressed)
            {
                if (CanAttack && (GameManager._Instance.PlayerPosition - e.transform.position).magnitude < 2f)
                {
                    int dam = BlockRegistry._RegisteredBlocks[PStatus.ToolBox9[PStatus.CurrentItem].BlockID].GetHitDamage(PStatus.ToolBox9[PStatus.CurrentItem].Level);
                    if (LastAttacked != null && !LastAttacked.Equals(e))
                    {
                        if (LastAttacked.GetComponent <Enemy>().Script.GetType().Equals(typeof(Zombie)))
                        {
                            (LastAttacked.GetComponent <Enemy>().Script as Zombie).DisableHealthBar();
                        }
                        else if (LastAttacked.GetComponent <Enemy>().Script.GetType().Equals(typeof(Creeper)))
                        {
                            (LastAttacked.GetComponent <Enemy>().Script as Creeper).DisableHealthBar();
                        }
                        else if (LastAttacked.GetComponent <Enemy>().Script.GetType().Equals(typeof(EnderMan)))
                        {
                            (LastAttacked.GetComponent <Enemy>().Script as EnderMan).DisableHealthBar();
                        }
                        //dodac kolejne jak beda
                    }

                    if (enemy.TakeDamage(dam))
                    {
                        PStatus.Points += 50;

                        PlayerStatus.AddBlock(Zombie_IDS[new System.Random().Next(0, Zombie_IDS.Length)]);
                    }
                    LastAttacked = e;
                    CanAttack    = false;
                }
            }
        }
        else if (e.GetComponent <Enemy>().Script.GetType().Equals(typeof(Creeper)))
        {
            Creeper enemy = e.GetComponent <Enemy>().Script as Creeper;

            if (LeftMousePressed)
            {
                if (CanAttack && (GameManager._Instance.PlayerPosition - e.transform.position).magnitude < 2f)
                {
                    int dam = BlockRegistry._RegisteredBlocks[PStatus.ToolBox9[PStatus.CurrentItem].BlockID].GetHitDamage(PStatus.ToolBox9[PStatus.CurrentItem].Level);
                    if (LastAttacked != null && !LastAttacked.Equals(e))
                    {
                        if (LastAttacked.GetComponent <Enemy>().Script.GetType().Equals(typeof(Zombie)))
                        {
                            (LastAttacked.GetComponent <Enemy>().Script as Zombie).DisableHealthBar();
                        }
                        else if (LastAttacked.GetComponent <Enemy>().Script.GetType().Equals(typeof(Creeper)))
                        {
                            (LastAttacked.GetComponent <Enemy>().Script as Creeper).DisableHealthBar();
                        }
                        else if (LastAttacked.GetComponent <Enemy>().Script.GetType().Equals(typeof(EnderMan)))
                        {
                            (LastAttacked.GetComponent <Enemy>().Script as EnderMan).DisableHealthBar();
                        }
                        //dodac kolejne jak beda
                    }

                    if (enemy.TakeDamage(dam))
                    {
                        PStatus.Points += 50;

                        PlayerStatus.AddBlock(Creeper_IDS[new System.Random().Next(0, Creeper_IDS.Length)]);
                    }
                    LastAttacked = e;
                    CanAttack    = false;
                }
            }
        }
        else if (e.GetComponent <Enemy>().Script.GetType().Equals(typeof(EnderMan)))
        {
            EnderMan enemy = e.GetComponent <Enemy>().Script as EnderMan;

            if (LeftMousePressed)
            {
                if (CanAttack && (GameManager._Instance.PlayerPosition - e.transform.position).magnitude < 2f)
                {
                    int dam = BlockRegistry._RegisteredBlocks[PStatus.ToolBox9[PStatus.CurrentItem].BlockID].GetHitDamage(PStatus.ToolBox9[PStatus.CurrentItem].Level);
                    if (LastAttacked != null && !LastAttacked.Equals(e))
                    {
                        if (LastAttacked.GetComponent <Enemy>().Script.GetType().Equals(typeof(Zombie)))
                        {
                            (LastAttacked.GetComponent <Enemy>().Script as Zombie).DisableHealthBar();
                        }
                        else if (LastAttacked.GetComponent <Enemy>().Script.GetType().Equals(typeof(Creeper)))
                        {
                            (LastAttacked.GetComponent <Enemy>().Script as Creeper).DisableHealthBar();
                        }
                        else if (LastAttacked.GetComponent <Enemy>().Script.GetType().Equals(typeof(EnderMan)))
                        {
                            (LastAttacked.GetComponent <Enemy>().Script as EnderMan).DisableHealthBar();
                        }
                        //dodac kolejne jak beda
                    }

                    if (enemy.TakeDamage(dam))
                    {
                        PStatus.Points += 50;

                        PlayerStatus.AddBlock(Enderman_IDS[new System.Random().Next(0, Enderman_IDS.Length)]);
                    }
                    LastAttacked = e;
                    CanAttack    = false;
                }
            }
        }
    }
Ejemplo n.º 19
0
        public override void PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            Log.WarnFormat("Player {0} trying to spawn Mob #{1}.", player.Username, Metadata);

            var coordinates = GetNewCoordinatesFromFace(blockCoordinates, face);

            Mob mob = null;

            EntityType type = (EntityType)Metadata;

            switch (type)
            {
            case EntityType.Chicken:
                mob = new Chicken(world);
                break;

            case EntityType.Cow:
                mob = new Cow(world);
                break;

            case EntityType.Pig:
                mob = new Pig(world);
                break;

            case EntityType.Sheep:
                mob = new Sheep(world);
                break;

            case EntityType.Wolf:
                mob = new Wolf(world)
                {
                    Owner = player
                };
                break;

            case EntityType.Villager:
                mob = new Villager(world);
                break;

            case EntityType.MushroomCow:
                mob = new MushroomCow(world);
                break;

            case EntityType.Squid:
                mob = new Squid(world);
                break;

            case EntityType.Rabbit:
                mob = new Rabbit(world);
                break;

            case EntityType.Bat:
                mob = new Bat(world);
                break;

            case EntityType.IronGolem:
                mob = new IronGolem(world);
                break;

            case EntityType.SnowGolem:
                mob = new SnowGolem(world);
                break;

            case EntityType.Ocelot:
                mob = new Ocelot(world);
                break;

            case EntityType.Zombie:
                mob = new Zombie(world);
                break;

            case EntityType.Creeper:
                mob = new Creeper(world);
                break;

            case EntityType.Skeleton:
                mob = new Skeleton(world);
                break;

            case EntityType.Spider:
                mob = new Spider(world);
                break;

            case EntityType.ZombiePigman:
                mob = new ZombiePigman(world);
                break;

            case EntityType.Slime:
                mob = new Slime(world);
                break;

            case EntityType.Enderman:
                mob = new Enderman(world);
                break;

            case EntityType.Silverfish:
                mob = new Silverfish(world);
                break;

            case EntityType.CaveSpider:
                mob = new CaveSpider(world);
                break;

            case EntityType.Ghast:
                mob = new Ghast(world);
                break;

            case EntityType.MagmaCube:
                mob = new MagmaCube(world);
                break;

            case EntityType.Blaze:
                mob = new Blaze(world);
                break;

            case EntityType.ZombieVillager:
                mob = new ZombieVillager(world);
                break;

            case EntityType.Witch:
                mob = new Witch(world);
                break;

            case EntityType.Stray:
                mob = new Stray(world);
                break;

            case EntityType.Husk:
                mob = new Husk(world);
                break;

            case EntityType.WitherSkeleton:
                mob = new WitherSkeleton(world);
                break;

            case EntityType.Guardian:
                mob = new Guardian(world);
                break;

            case EntityType.ElderGuardian:
                mob = new ElderGuardian(world);
                break;

            case EntityType.Horse:
                var random = new Random();
                mob = new Horse(world, random.NextDouble() < 0.10, random);
                break;

            case EntityType.PolarBear:
                mob = new PolarBear(world);
                break;

            case EntityType.Shulker:
                mob = new Shulker(world);
                break;

            case EntityType.Dragon:
                mob = new Dragon(world);
                break;

            case EntityType.SkeletonHorse:
                mob = new SkeletonHorse(world);
                break;

            case EntityType.Wither:
                mob = new Wither(world);
                break;

            case EntityType.Evoker:
                mob = new Evoker(world);
                break;

            case EntityType.Vindicator:
                mob = new Vindicator(world);
                break;

            case EntityType.Vex:
                mob = new Vex(world);
                break;

            case EntityType.Npc:
                mob = new PlayerMob("test", world);
                break;
            }

            if (mob == null)
            {
                return;
            }

            mob.KnownPosition = new PlayerLocation(coordinates.X, coordinates.Y, coordinates.Z);
            mob.NoAi          = true;
            mob.SpawnEntity();

            Log.WarnFormat("Player {0} spawned Mob #{1}.", player.Username, Metadata);

            if (player.GameMode == GameMode.Survival)
            {
                var itemInHand = player.Inventory.GetItemInHand();
                itemInHand.Count--;
                player.Inventory.SetInventorySlot(player.Inventory.InHandSlot, itemInHand);
            }
        }
Ejemplo n.º 20
0
 public void CreeperDied(Creeper creeper, float reward)
 {
     if (allCreepers.Contains(creeper))
     {
         money += reward;
         allCreepers.Remove(creeper);
     }
 }