Esempio n. 1
0
 public void SetKiller(MobType type)
 {
     if (killer == MobType.NONE)
     {
         killer = type;
     }
 }
        protected override Task SendSpawnPacket(ClientPlayPacketGenerator generator)
        {
            MobType type = AttachedObject.GetComponent <MobTypeComponent>().MobType;

            return(generator.SpawnMob(AttachedObject.EntityId, AttachedObject.UUID, (byte)type, AttachedObject.Position, AttachedObject.Pitch, AttachedObject.Yaw, new EntityMetadata.Entity {
            }));
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new Mob object based on MobType and provided data
        /// </summary>
        /// <param name="world"></param>
        /// <param name="entityId"></param>
        /// <param name="type"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static Mob CreateMob(Chraft.World.WorldManager world, int entityId, MobType type, Chraft.Net.MetaData data = null)
        {
            // TODO: extensibility point to allow plugin to return custom class as Mobs instead of the built-in classes
            Mob mob = null;

            // If a custom Mob has not been created, return a built-in Mob
            if (mob == null)
            {
                switch (type)
                {
                    case MobType.Cow:
                        mob = new Cow(world, entityId, data);
                        break;
                    case MobType.Creeper:
                        mob = new Creeper(world, entityId, data);
                        break;
                    case MobType.Ghast:
                        mob = new Ghast(world, entityId, data);
                        break;
                    case MobType.Giant:
                        mob = new GiantZombie(world, entityId, data);
                        break;
                    case MobType.Hen:
                        mob = new Hen(world, entityId, data);
                        break;
                    case MobType.Pig:
                        mob = new Pig(world, entityId, data);
                        break;
                    case MobType.PigZombie:
                        mob = new ZombiePigman(world, entityId, data);
                        break;
                    case MobType.Sheep:
                        mob = new Sheep(world, entityId, data);
                        break;
                    case MobType.Skeleton:
                        mob = new Skeleton(world, entityId, data);
                        break;
                    case MobType.Slime:
                        mob = new Slime(world, entityId, data);
                        break;
                    case MobType.Spider:
                        mob = new Spider(world, entityId, data);
                        break;
                    case MobType.Squid:
                        mob = new Squid(world, entityId, data);
                        break;
                    case MobType.Wolf:
                        mob = new Wolf(world, entityId, data);
                        break;
                    case MobType.Zombie:
                        mob = new Zombie(world, entityId, data);
                        break;
                    default:
                        mob = null;
                        break;
                }
            }

            return mob;
        }
    public override string ToChatString(GameWorldController gameWorldController)
    {
        MobData mobData = gameWorldController.Model.GetMobData(MobId);
        MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name);

        return(base.ToChatString(gameWorldController) + mobType.Name + " spotted an energy tank");
    }
Esempio n. 5
0
    public override string ToChatString(GameWorldController gameWorldController)
    {
        MobData mobData  = gameWorldController.Model.GetMobData(MobID);
        MobType mobType  = MobTypeManager.GetMobTypeByName(mobData.mob_type_name);
        float   distance = Point3d.Distance(FromPosition, ToPosition);

        MathConstants.eDirection direction = MathConstants.GetDirectionForAngle(ToAngle);
        string facing = "";

        switch (direction)
        {
        case MathConstants.eDirection.none:
            facing = "South";
            break;

        case MathConstants.eDirection.right:
            facing = "East";
            break;

        case MathConstants.eDirection.up:
            facing = "North";
            break;

        case MathConstants.eDirection.left:
            facing = "West";
            break;

        case MathConstants.eDirection.down:
            facing = "South";
            break;
        }

        return(base.ToChatString(gameWorldController) + mobType.Name + " moved " + distance.ToString("F1") + " feet, now facing " + facing);
    }
Esempio n. 6
0
 internal Mob(Coords coords, MobType type)
     : base(ref coords)
 {
     Type = type;
     WorldData.Mobs.TryAdd(Id, this);
     WorldData.Chunks[coords].Mobs.Add(this);
 }
Esempio n. 7
0
    public void OnMobDeath(MobType mobType, Vector3 mobPosition)
    {
        //Debugging Code
        if (SoundManager.Instance == null)
        {
            Debug.LogError("SoundManager Null!");
        }
        else
        {
            SoundManager.Instance.PlaySoundEffect(SoundEffect.MobDeath);
        }

        spawnDrop(mobType, mobPosition);

        MobWave currentWave = Waves[currentWaveIndex];

        activeMobs -= 1;
        OnMobKilled.Invoke(currentWave.PointsPerKill);

        if (activeMobs == 0)
        {
            //Debug.LogWarning("All mobs dead. Spawning next wave!");

            OnWaveCompleted.Invoke(currentWave.WaveValue);
            currentWaveIndex += 1;
            SpawnWave();
        }
    }
Esempio n. 8
0
        public Entity(Simulation s, MobType type, int level, int armor = 0, int maxLife = 1, Dictionary <School, int> magicResist = null)
            : base(s)
        {
            Type    = type;
            Level   = level;
            Armor   = armor;
            MaxLife = maxLife;

            ResistChances = new Dictionary <School, Dictionary <double, double> >();
            MagicResist   = new Dictionary <School, int>();
            if (magicResist == null)
            {
                foreach (School school in (School[])Enum.GetValues(typeof(School)))
                {
                    MagicResist.Add(school, 0);
                    ResistChances.Add(school, Simulation.ResistChances(MagicResist[school]));
                }
            }
            else
            {
                foreach (School school in (School[])Enum.GetValues(typeof(School)))
                {
                    MagicResist.Add(school, Math.Max(0, magicResist.ContainsKey(school) ? magicResist[school] : (magicResist.ContainsKey(School.Magical) ? magicResist[School.Magical] : 0)));
                    ResistChances.Add(school, Simulation.ResistChances(MagicResist[school]));
                }
            }

            Reset();
        }
Esempio n. 9
0
 private MobInfo(int id, byte tier, MobType mobType, HarvestableMobType harvestableMobType)
 {
     this.id                 = id;
     this.tier               = tier;
     this.mobType            = mobType;
     this.harvestableMobType = harvestableMobType;
 }
Esempio n. 10
0
 public MobtypeEntry(string type, string flags)
 {
     Flags = flags;
     switch (type)
     {
         case "MONSTER":
             AnimationType = MobType.Monster;
             break;
         case "ANIMAL":
             AnimationType = MobType.Animal;
             break;
         case "SEA_MONSTER":
             AnimationType = MobType.Monster;
             break;
         case "HUMAN":
             AnimationType = MobType.Humanoid;
             break;
         case "EQUIPMENT":
             AnimationType = MobType.Humanoid;
             break;
         default:
             AnimationType = MobType.Null;
             break;
     }
 }
Esempio n. 11
0
        public MobtypeEntry(string type, string flags)
        {
            Flags = flags;
            switch (type)
            {
            case "MONSTER":
                AnimationType = MobType.Monster;
                break;

            case "ANIMAL":
                AnimationType = MobType.Animal;
                break;

            case "SEA_MONSTER":
                AnimationType = MobType.Monster;
                break;

            case "HUMAN":
                AnimationType = MobType.Humanoid;
                break;

            case "EQUIPMENT":
                AnimationType = MobType.Humanoid;
                break;

            default:
                AnimationType = MobType.Null;
                break;
            }
        }
Esempio n. 12
0
        //リストから削除
        public void RemoveMob(string zoneName, MobType mobType, string name)
        {
            if (AddMob(zoneName, mobType, name) == false)
            {
                foreach (ZoneMobData zoneData in area.zones)
                {
                    if (zoneData.name == zoneName)
                    {
                        switch (mobType)
                        {
                        case MobType.S:
                            zoneData.s.Remove(name);  break;

                        case MobType.A:
                            zoneData.a.Remove(name); break;

                        case MobType.B:
                            zoneData.b.Remove(name); break;

                        case MobType.ETC:
                            zoneData.etc.Remove(name); break;
                        }
                        return;
                    }
                }
            }
        }
Esempio n. 13
0
 public Mob(string name, Vector pos, Animation aniNone,
            Animation aniMove, Animation aniMelee, Animation aniRanged,
            MobType type, Vector goal, int hp,
            int atk, int def, double spd, double sight)
     : base(name, pos, aniNone)
 {
     Type         = type;
     Goal         = goal;
     Home         = goal;
     this.hp      = hp;
     Attack       = atk;
     Defense      = def;
     Speed        = spd;
     SightRange   = sight;
     Velocity     = new Vector(0, 0);
     this.aniMove = aniMove;
     if (aniMove != null)
     {
         aniMove.AddLocateable(this);
     }
     this.aniMelee = aniMelee;
     if (aniMelee != null)
     {
         aniMelee.AddLocateable(this);
     }
     this.aniRanged = aniRanged;
     if (aniRanged != null)
     {
         aniRanged.AddLocateable(this);
     }
 }
    public override string ToChatString(GameWorldController gameWorldController)
    {
        MobData mobData       = gameWorldController.Model.GetMobData(MobId);
        MobType mobType       = MobTypeManager.GetMobTypeByName(mobData.mob_type_name);
        string  characterName = gameWorldController.Model.GetCharacterData(CharacterID).character_name;

        return(base.ToChatString(gameWorldController) + mobType.Name + " spotted " + characterName);
    }
Esempio n. 15
0
 internal Ocelot(WorldManager world, int entityId, MobType type, MetaData data)
     : base(world, entityId, type, data)
 {
     Data.IsSitting    = false;
     Data.IsTamed      = false;
     Data.IsAggressive = false;
     FishUntilTamed    = Server.Rand.Next(20);
 }
Esempio n. 16
0
 protected Mob(WorldManager world, int entityId, MobType type, MetaData data)
     : base(world.Server, entityId, data)
 {
     this.Type = type;
     this.World = world;
     this.MobUpdateFrequency = 1;
     this.Speed = 0.7;
 }
Esempio n. 17
0
 protected Mob(WorldManager world, int entityId, MobType type, MetaData data)
     : base(world.Server, entityId, data)
 {
     this.Type  = type;
     this.World = world;
     this.MobUpdateFrequency = 1;
     this.Speed = 0.7;
 }
Esempio n. 18
0
    private GameObject FindSpaceShipByEnum(MobType type)
    {
        GameObject spaceShip = null;

        m_sourceSpaceShips.TryGetValue(EnumToStr(type), out spaceShip);

        return(spaceShip);
    }
Esempio n. 19
0
 internal Ocelot(WorldManager world, int entityId, MobType type, MetaData data)
     : base(world, entityId, type, data)
 {
     Data.IsSitting = false;
     Data.IsTamed = false;
     Data.IsAggressive = false;
     FishUntilTamed = Server.Rand.Next(20);
 }
    public override string ToChatString(GameWorldController gameWorldController)
    {
        MobData mobData = gameWorldController.Model.GetMobData(MobId);
        MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name);

        // TODO: Display what the mob ID attacked
        return(base.ToChatString(gameWorldController) + " " + mobType.Name + " attacked");
    }
Esempio n. 21
0
    void spawnDrop(MobType mobType, Vector3 position)
    {
        ItemPickUps_SO item = getDrop(mobType);

        if (item != null)
        {
            Instantiate(item.itemSpawnObject, position, Quaternion.identity);
        }
    }
Esempio n. 22
0
File: Mob.cs Progetto: Smjert/c-raft
        public Vector3 gotoPos; // Location entity should move towards

        #endregion Fields

        #region Constructors

        protected Mob(WorldManager world, int entityId, MobType type, MetaData data)
            : base(world.Server, entityId)
        {
            if (data == null)
                data = new MetaData();
            this.Data = data;
            this.Type = type;
            this.World = world;
            this.Health = this.MaxHealth;
        }
Esempio n. 23
0
    private static bool ParseMobTypes(MobTypeManager mobTypeManager)
    {
        bool   success        = true;
        string mob_types_path = mobTypeManager.mobTypePath;
        Dictionary <string, MobType> mobTypes = new Dictionary <string, MobType>();

        try
        {
            string   mob_types_json = File.ReadAllText(mob_types_path);
            JsonData jsonObject     = JsonMapper.ToObject(mob_types_json);
            JsonData mobTypeSet     = jsonObject["mob_types_set"];

            if (mobTypeSet != null && mobTypeSet.Count > 0)
            {
                for (int mobTypeIndex = 0; mobTypeIndex < mobTypeSet.Count; ++mobTypeIndex)
                {
                    JsonData jsonEntry = mobTypeSet[mobTypeIndex];
                    MobType  mobType   = MobType.FromObject(jsonEntry);

                    if (ValidateMobType(mobType, mobTypes))
                    {
                        mobTypes.Add(mobType.Name, mobType);
                    }
                    else
                    {
                        Debug.LogError("MobTypeImporter: ERROR: Problem(s) validating mob type: " + mobType.Name);
                        success = false;
                    }
                }
            }
            else
            {
                Debug.LogError("MobTypeImporter: ERROR: No mob types found in file:" + mob_types_path);
                success = false;
            }
        }
        catch (Exception ex)
        {
            Debug.LogError("MobTypeImporter: ERROR: Failed to parse mob types: " + ex.Message);
            Debug.LogException(ex);
            success = false;
        }

        // Store the mob types into the mob type manager
        if (success)
        {
            MobType[] mobTypeArray = new MobType[mobTypes.Count];

            mobTypes.Values.CopyTo(mobTypeArray, 0);
            mobTypeManager.CacheMobTypes(mobTypeArray);
            Log(string.Format("MobTypeImporter: Caching {0} mob types(s) in mob manager.", mobTypes.Count));
        }

        return(success);
    }
Esempio n. 24
0
        protected Unit(MobType type)
        {
            switch (type)
            {
            case MobType.Zerg: SPEED = 1; HEALTH = 20; break;

            case MobType.Roach: SPEED = 4; HEALTH = 20; break;

            case MobType.Ghost: SPEED = 3; HEALTH = 30; break;
            }
        }
    public override string ToChatString(GameWorldController gameWorldController)
    {
        string speakerName = "";

        MobData mobData = gameWorldController.Model.GetMobData(MobId);
        MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name);

        speakerName = mobType.Name;

        return(base.ToChatString(gameWorldController) + speakerName + " said \"" + Dialog + "\"");
    }
Esempio n. 26
0
        public INonPlayerCharacter CreateNonplayerCharacter(MobType typeOfMob, int level = 0)
        {
            INonPlayerCharacter npc = new NonPlayerCharacter();

            npc.Id        = NpcId++;
            npc.Zone      = Zone.Id;
            npc.TypeOfMob = typeOfMob;
            npc.Level     = level;

            return(npc);
        }
Esempio n. 27
0
        private void CreateAi(MobType mobType)
        {
            Func <CreatureState>   getter = () => AttachedObject.GetValue(CreatureStateProperty);
            Action <CreatureState> setter = v => AttachedObject.SetLocalValue(CreatureStateProperty, v);
            CreatureAi             ai;

            switch (mobType)
            {
            case Entities.MobType.Chicken:
                ai = new AiChicken(getter, setter);
                break;

            case Entities.MobType.Cow:
                ai = new AiCow(getter, setter);
                break;

            case Entities.MobType.Creeper:
                ai = new AiCreeper(getter, setter);
                break;

            case Entities.MobType.Pig:
                ai = new AiPig(getter, setter);
                break;

            case Entities.MobType.Sheep:
                ai = new AiSheep(getter, setter);
                break;

            case Entities.MobType.Skeleton:
                ai = new AiSkeleton(getter, setter);
                break;

            case Entities.MobType.Spider:
                ai = new AiSpider(getter, setter);
                break;

            case Entities.MobType.Squid:
                // TODO new ai for squid
                ai = new AiChicken(getter, setter);
                break;

            case Entities.MobType.Zombie:
                ai = new AiZombie(getter, setter);
                break;

            default:
                // TODO add more ai
                Logger.LogWarning("AI of this mob has not been implemented: {0}.", mobType);
                ai = null;
                break;
            }

            _ai = ai;
        }
Esempio n. 28
0
        public static int[] texture = new int[6]; //массив текстур для монстров
        public Mob(MobType type, int level) : base(type)
        {
            _Level         = level;
            x              = 0;
            y              = 0;
            NextPointIndex = 1;

            StepTimer          = new Timer();
            StepTimer.Elapsed += new ElapsedEventHandler(StepTimerTick);
            StepTimer.Interval = 100.0 / _Speed;
        }
Esempio n. 29
0
    public static MobType GetMobTypeByName(string typeName)
    {
        MobType mobType = null;

        if (!m_instance.m_mobTypesDictionary.TryGetValue(typeName, out mobType))
        {
            Debug.LogError("MobTypeManager: Unknown mob type: " + typeName);
        }

        return(mobType);
    }
Esempio n. 30
0
        public static bool CalculateTypeAdvantage(MobType caster, MobType target)
        {
            int totalTypes = Enum.GetNames(typeof(MobType)).Length;

            int strongIndex = (int)caster + 1;

            if (strongIndex == totalTypes)
            {
                strongIndex = 0; //make a cycle
            }
            //Console.WriteLine("DEBUG comparing {0} with {1}, looking for strong index {2}", caster, target, (MobType)strongIndex);
            return((MobType)strongIndex == target);
        }
Esempio n. 31
0
 public static MobEntity onMobAttemptSpawn(MobManager inst, MobType type, Segment segment, long x, long y, long z, Vector3 blockOffset, Vector3 look)
 {
     if (type == MobType.WormBossLava)
     {
         Debug.Log("Intercepted lava worm spawn; has a " + wormSpawnSuccessChance * 100 + "% chance of success");
         if (UnityEngine.Random.Range(0F, 1F) > wormSpawnSuccessChance)
         {
             Debug.Log("Spawn cancelled.");
             return(null);
         }
     }
     return(inst.SpawnMob(type, segment, x, y, z, blockOffset, look));
 }
Esempio n. 32
0
 public Mob(uint id, string name, uint type, uint level, uint health, uint divinity, uint atk1, uint atk2, uint atk3, uint drop1, uint drop2) {
     mobID = id;
     mobName = name;
     mobType = (MobType)type;
     mobLevel = level;
     mobHealth = health;
     mobDivinity = divinity;
     mobAtk1 = atk1;
     mobAtk2 = atk2;
     mobAtk3 = atk3;
     mobDrop1 = drop1;
     mobDrop2 = drop2;
 }
Esempio n. 33
0
 public Mob(string name, Board board, Point position, Item offensiveItem, Item defensiveItem, int health, int attackStat, int defensiveStat, int experience, char character, ConsoleColor fontColor, MobType race)
 {
     this.Name = name;
     this.Position = position;
     this.OffensiveSlot = offensiveItem;
     this.DefensiveSlot = defensiveItem;
     this.FontColor = fontColor;
     this.Health = health;
     this.Experience = experience;
     this.Character = character;
     this.Race = race;
     this.AttackStat = attackStat;
     this.DefenseStat = defensiveStat;
 }
Esempio n. 34
0
        public Mob(MobData data)
        {
            this.baseStats   = data.stats;
            this.skills      = data.skills;
            this.items       = data.items;
            this.equipments  = data.equipments;
            this.battleStyle = data.battleStyle;
            this.rewardExp   = data.rewardExp;
            this.rewardGold  = data.rewardGold;
            this.rewardItem  = data.rewardItem;
            this.mobType     = data.mobType;

            CalcStat();
        }
Esempio n. 35
0
 public Mob(MobType type, Vector pos, Vector vel,
            double spd, double sight,
            Vector goal)
 {
     Type     = type;
     Position = pos;
     Velocity = vel;
     Angle    = Velocity.Angle;
     if (type == MobType.Human)
     {
         Img = Properties.Resources.Link;
         HP  = 1000;
     }
     else if (type == MobType.Dragon)
     {
         Img = Properties.Resources.Dragon;
         HP  = 200;
     }
     else if (type == MobType.Ghost)
     {
         Img = Properties.Resources.Ghost;
         HP  = 80;
     }
     else if (type == MobType.Goblin)
     {
         Img = Properties.Resources.Goblin;
         HP  = 10;
     }
     else if (type == MobType.Orc)
     {
         Img = Properties.Resources.Orc;
         HP  = 20;
     }
     else if (type == MobType.Skeleton)
     {
         Img = Properties.Resources.Skeleton;
         HP  = 5;
     }
     if (HP < 5)
     {
         Damage = 1;
     }
     else
     {
         Damage = HP / 5;
     }
     Speed      = spd;
     SightRange = sight;
     Goal       = goal;
 }
Esempio n. 36
0
        private void AddDeadMob(MobType type)
        {
            var mob = new Mob
            {
                Id         = Guid.NewGuid().ToString(),
                Alive      = false,
                KilledDate = DateTime.UtcNow,
                MobTypeId  = type.Id,
                MobType    = type,
                Special    = false
            };

            _mobs.Add(mob);
        }
Esempio n. 37
0
        public Universe(ISaveFile saveFile, Mod mod)
        {
            SaveFile = saveFile;
            _mod     = mod;

            _startWorld           = new World(this);
            _startWorld.Generator = new WorldGenerator(_startWorld);

            _modData = new ModData
            {
                Materials = mod.Materials.Values.Select((m, i) =>
                {
                    m.Index = i;
                    return(m);
                }).ToList(),

                Models = mod.MobTypes.Values.Select((m, i) =>
                {
                    m.Model.Index = i;
                    return(m.Model);
                }).ToList(),
            };

            for (int i = 0; i < 20; ++i)
            {
                MobType type = null;
                if (_mod.MobTypes.Count > 0)
                {
                    string nextMobType = _mod.MobTypes.Keys.ElementAt(i % _mod.MobTypes.Count);
                    type = _mod.MobTypes[nextMobType];
                }

                var e = new Entity()
                {
                    PositionData   = new PositionData(),
                    IsAiControlled = true,
                    MobName        = type?.Name,
                    ModelIndex     = type?.Model.Index
                };

                Movement.Respawn(e.PositionData);
                _entities.Add(e);
            }

            var thread = new Thread(() => RunUniverse());

            thread.IsBackground = true;
            thread.Start();
        }
Esempio n. 38
0
        public static void SetCloak(Client player, string type)
        {
            if (type == null)
            {
                player.Settings.Cloaked = null;
            }
            else
            {
                try
                {
                    MobType mt = (MobType)Enum.Parse(typeof(MobType), type);
                    player.Settings.Cloaked = mt.ToString();

                    cloakBack.Remove(player.MinecraftUsername);
                    cloakBack.Add(player.MinecraftUsername, player.Session.Position);
                } catch (Exception)
                {
                    player.TellSystem(Chat.DarkRed, "Unknown mob: " + type);
                }
            }
            player.SaveProxyPlayer();

            VanillaSession rs = player.Session as VanillaSession;

            if (rs != null)
            {
                if (player.Settings.Cloaked == null)
                {
                    SpawnPlayer spawnNamedEntity = new SpawnPlayer(rs.EID, player);
                    spawnNamedEntity.Position = rs.Position;
                    spawnNamedEntity.Pitch    = rs.Pitch;
                    spawnNamedEntity.Yaw      = rs.Yaw;
                    PlayerList.QueueToAll(spawnNamedEntity);
                    player.Queue.Queue(new DestroyEntities(rs.EID));

                    player.Session.World.Send("gamemode 0 " + player.MinecraftUsername);
                }
                else
                {
                    PlayerList.QueueToAll(new DestroyEntities(rs.EID));

                    player.Session.World.Send("gamemode 1 " + player.MinecraftUsername);
                }
            }

            TellMode(player);

            PlayerList.UpdateTabPlayers();
        }
Esempio n. 39
0
 public SpawnMob(MobType type)
 {
     Type = type;
     Pos = new CoordDouble();
     Metadata = new Metadata();
     Metadata.SetByte(17, 0);
     Metadata.SetByte(0, 0);
     Metadata.SetByte(16, -1);
     Metadata.SetShort(1, 300);
     Metadata.SetFloat(6, 20);
     Metadata.SetInt(7, 0);
     Metadata.SetByte(8, 0);
     Metadata.SetByte(9, 0);
     Metadata.SetString(10, "");
     Metadata.SetByte(11, 0);
 }
Esempio n. 40
0
        /// <summary>
        /// Create a new Mob object based on MobType and provided data
        /// </summary>
        /// <param name="world"></param>
        /// <param name="entityId"></param>
        /// <param name="type"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static Mob CreateMob(Chraft.World.WorldManager world, int entityId, MobType type, Chraft.Net.MetaData data = null)
        {
            Type mobType = GetMobClass(world, type);

            if (mobType != null)
            {
                ConstructorInfo ci =
                    mobType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null,
                                           new Type[]
                                            {
                                                typeof (Chraft.World.WorldManager), typeof (int),
                                                typeof (Chraft.Net.MetaData)
                                            }, null);
                if (ci != null)
                    return (Mob)ci.Invoke(new object[] {world, entityId, data});
            }

            return null;
        }
Esempio n. 41
0
 public void SpawnMobAtPosition(MobType type, Vector3 position)
 {
     var go = InstantiateMobType(type);
     go.transform.position = position;
     m_mobs.Add(go);
 }
Esempio n. 42
0
        public void SpawnMob(UniversalCoords coords, MobType type = MobType.Pig)
        {
            if (type == MobType.Pig) // Type has not been forced.
            {
                switch (Server.Rand.Next(4))
                {
                    case 0: type = MobType.Zombie; break;
                    case 1: type = MobType.Skeleton; break;
                    case 2: type = MobType.Creeper; break;
                    case 3: type = MobType.Spider; break; // TODO: Check space is larger than 1x2
                }
            }

            Mob mob = MobFactory.CreateMob(this, this.Server.AllocateEntity(), type);

            mob.Position = new Location(new Vector3(coords.WorldX + 0.5, coords.WorldY, coords.WorldZ + 0.5));
            mob.World = this;

            mob.Hunter = true;
            mob.Hunting = false;

            //Event
            EntitySpawnEventArgs e = new EntitySpawnEventArgs(mob, mob.Position.Vector);
            Server.PluginManager.CallEvent(Plugins.Events.Event.ENTITY_SPAWN, e);
            if (e.EventCanceled) return;
            mob.Position.Vector = e.Location;
            //End Event

            //mob.Data // Set accessor is inaccebile?
            Server.AddEntity(mob); // TODO: Limit this in some way.
        }
Esempio n. 43
0
    public static MobType FromObject(JsonData jsonData)
    {
        MobType mobType = new MobType();

        mobType.m_mob_type_name = JsonUtilities.ParseString(jsonData, "mob_type_name");
        mobType.m_mob_label = JsonUtilities.ParseString(jsonData, "label");
        mobType.m_max_health = JsonUtilities.ParseInt(jsonData, "max_health");
        mobType.m_max_energy = JsonUtilities.ParseInt(jsonData, "max_energy");
        mobType.m_speed = JsonUtilities.ParseFloat(jsonData, "speed");

        {
            JsonData visionCone = jsonData["vision_cone"];

            mobType.m_vision_cone_distance = JsonUtilities.ParseFloat(visionCone, "distance");
            mobType.m_vision_cone_radians = JsonUtilities.ParseFloat(visionCone, "angle")*MathConstants.DEGREES_TO_RADIANS;
        }

        return mobType;
    }
Esempio n. 44
0
 internal Mooshroom(WorldManager world, int entityId, MobType type, MetaData data)
     : base(world, entityId, type, data)
 {
     Data.Sheared = false;
 }
Esempio n. 45
0
        public int SightRange; // Clients within this range will be hunted

        #endregion Fields

        #region Constructors

        public Mob(Server server, int entityId, MobType type)
            : this(server, entityId, type, new MetaData())
        {
        }
Esempio n. 46
0
 public Mob(Server server, int entityId, MobType type, MetaData data)
     : base(server, entityId)
 {
     Data = data;
     Type = type;
 }
Esempio n. 47
0
 public Mob(int eid, MobType type) : base (eid)
 {
     this.Type = type;
 }
Esempio n. 48
0
        private static bool CanMobTypeSpawnAtLocation(MobType mobType, WorldManager world, int worldX, int worldY, int worldZ)
        {
            Chunk chunk = world.GetChunkFromWorld(worldX, worldZ) as Chunk;
            if (chunk == null)
                return false;

            BlockBase blockClassCurrent = BlockHelper.Instance.CreateBlockInstance((byte)chunk.GetType(worldX & 0xF, worldY, worldZ & 0xF));
            BlockBase blockClassUp = BlockHelper.Instance.CreateBlockInstance((byte)chunk.GetType(worldX & 0xF, worldY + 1, worldZ & 0xF));

            if (mobType == MobType.Squid)
            {
                return (blockClassCurrent.IsLiquid && !blockClassCurrent.IsOpaque) // Is Water
                    && !blockClassUp.IsOpaque; // Has either water or air above it
            }

            BlockBase blockClassDown = BlockHelper.Instance.CreateBlockInstance((byte)chunk.GetType(worldX & 0xF, worldY - 1, worldZ & 0xF));

            return blockClassDown.IsOpaque && blockClassDown.IsSolid && // Is solid underneath
                    !blockClassCurrent.IsOpaque && !blockClassCurrent.IsSolid && !blockClassCurrent.IsLiquid && // Is not solid or liquid where spawning
                    !blockClassUp.IsOpaque && !blockClassUp.IsSolid; // Is not solid 1 block above
        }
Esempio n. 49
0
File: Bat.cs Progetto: TheaP/c-raft
 internal Bat(WorldManager world, int entityId, MobType type, MetaData data)
     : base(world, entityId, type, data)
 {
     MaxExp = 0;
     MinExp = 0;
 }
Esempio n. 50
0
 protected Animal(WorldManager world, int entityId, MobType type, MetaData data)
     : base(world, entityId, type, data)
 {
 }
Esempio n. 51
0
        public Vector3 gotoPos; // Location entity should move towards

        #endregion Fields

        #region Constructors

        protected Mob(WorldManager world, int entityId, MobType type, MetaData data)
            : base(world.Server, entityId, data)
        {
            this.Type = type;
            this.World = world;
        }
Esempio n. 52
0
        /// <summary>
        /// Create a new Mob object based on MobType and provided data
        /// </summary>
        /// <param name="world"></param>
        /// <param name="entityId"></param>
        /// <param name="type"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public IMob CreateMob(IWorldManager world, IServer iServer, MobType type, IMetaData data = null)
        {
            Type mobType = GetMobClass(world, type);
            Server server = iServer as Server;
            if (mobType != null)
            {

                ConstructorInfo ci =
                    mobType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null,
                                           new Type[]
                                            {
                                                typeof (WorldManager), typeof (int),
                                                typeof (MetaData)
                                            }, null);
                if (ci != null)
                    return (Mob)ci.Invoke(new object[] {world, server.AllocateEntity(), data});
            }

            return null;
        }
Esempio n. 53
0
 void AddScoreForMobType(MobType type)
 {
     switch(type) {
     case MobType.Grunt:
         m_score += 75;
         break;
     case MobType.Robot:
         m_score += 125;
         break;
     case MobType.Spawner:
         m_score += 275;
         break;
     case MobType.Exploder:
         m_score += 350;
         break;
     }
 }
Esempio n. 54
0
 public void CacheMobTypes(MobType[] mobTypes)
 {
     m_mobTypesList = mobTypes;
 }
Esempio n. 55
0
        public void SpawnMob(int X, int Y, int Z, MobType type = MobType.Pig)
        {
            if (type == MobType.Pig) // Type has not been forced.
            {
                switch (Server.Rand.Next(4))
                {
                    case 0: type = MobType.Zombie; break;
                    case 1: type = MobType.Skeleton; break;
                    case 2: type = MobType.Creeper; break;
                    case 3: type = MobType.Spider; break; // TODO: Check space is larger than 1x2
                }
            }

            Mob mob = new Mob(Server, Server.AllocateEntity(), type);

            switch (type) // Assign type specific stats
            {
                case MobType.Zombie: mob.Health = 10; break;
                case MobType.Skeleton: mob.Health = 10; break;
                case MobType.Creeper: mob.Health = 10; break;
                case MobType.Spider: mob.Health = 10; break;
                case MobType.Ghast: mob.Health = 10; break;
                case MobType.Giant: mob.Health = 10; break;
                case MobType.Slime: mob.Health = 10; break;
            }

            mob.Position = new World.Vector3(X + 0.5, Y, Z + 0.5);
            mob.World = this;

            mob.Hunter = true;
            mob.Hunting = false;
            mob.AttackRange = 10;

            //Event
            EntitySpawnEventArgs e = new EntitySpawnEventArgs(mob, mob.Position);
            Server.PluginManager.CallEvent(Plugins.Events.Event.ENTITY_SPAWN, e);
            if (e.EventCanceled) return;
            mob.Position = e.Location;
            //End Event

            //mob.Data // Set accessor is inaccebile?
            Server.AddEntity(mob); // TODO: Limit this in some way.
        }
Esempio n. 56
0
        public static Type GetMobClass(Chraft.World.WorldManager world, MobType type)
        {
            // TODO: extension point to allow plugin to override class for MobType for world
            Type mobType = null;

            // If a custom Mob has not been created, return a built-in Mob
            if (mobType == null)
            {
                switch (type)
                {
                    case MobType.Cow:
                        mobType = typeof(Cow);
                        break;
                    case MobType.Creeper:
                        mobType = typeof(Creeper);
                        break;
                    case MobType.Ghast:
                        mobType = typeof(Ghast);
                        break;
                    case MobType.Giant:
                        mobType = typeof(GiantZombie);
                        break;
                    case MobType.Hen:
                        mobType = typeof(Hen);
                        break;
                    case MobType.Pig:
                        mobType = typeof(Pig);
                        break;
                    case MobType.PigZombie:
                        mobType = typeof(ZombiePigman);
                        break;
                    case MobType.Sheep:
                        mobType = typeof(Sheep);
                        break;
                    case MobType.Skeleton:
                        mobType = typeof(Skeleton);
                        break;
                    case MobType.Slime:
                        mobType = typeof(Slime);
                        break;
                    case MobType.Spider:
                        mobType = typeof(Spider);
                        break;
                    case MobType.Squid:
                        mobType = typeof(Squid);
                        break;
                    case MobType.Wolf:
                        mobType = typeof(Wolf);
                        break;
                    case MobType.Zombie:
                        mobType = typeof(Zombie);
                        break;
                    default:
                        mobType = null;
                        break;
                }
            }

            if (mobType != null && typeof(Mob).IsAssignableFrom(mobType) && mobType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Chraft.World.WorldManager), typeof(int), typeof(Chraft.Net.MetaData) }, null) != null)
            {
                return mobType;
            }

            return null;
        }
Esempio n. 57
0
 protected Monster(WorldManager world, int entityId, MobType type, MetaData data)
     : base(world, entityId, type, data)
 {
     MinExp = 5;
     MaxExp = 5;
 }
Esempio n. 58
0
 GameObject InstantiateMobType(MobType type)
 {
     switch(type) {
     case MobType.Robot:
         return (GameObject)GameObject.Instantiate(m_robotPrefab);
     case MobType.Tank:
         return (GameObject)GameObject.Instantiate(m_tankPrefab);
     case MobType.Spawner:
         return (GameObject)GameObject.Instantiate(m_spawnerPrefab);
     case MobType.Exploder:
         return (GameObject)GameObject.Instantiate(m_exploderPrefab);
     default:
     case MobType.Grunt:
         return (GameObject)GameObject.Instantiate(m_gruntPrefab);
     }
 }