Exemple #1
0
        public static void CalculateDot(MobData mob, List <MobStatusEffectModel> effects, double delta, Action <int> towerkilledCallback)
        {
            if (effects == null)
            {
                return;
            }

            if (effects.Any(se => se.Type == MobStatusEffect.Dot))
            {
                effects.Where(se => se.Type == MobStatusEffect.Dot).ToList().ForEach(se =>
                {
                    if (se.TimeSinceLastTick <= EffectTicksMilliseconds)
                    {
                        se.TimeSinceLastTick += delta;
                        return;
                    }
                    mob.Hp -= se.Value;
                    if (mob.Hp <= 0)
                    {
                        if (towerkilledCallback != null)
                        {
                            towerkilledCallback(se.SenderTowerId);
                        }
                        else
                        {
                            TStuffLog.Debug("Tower Killed Callback is not Set");
                        }
                    }
                    se.TimeSinceLastTick = 0;
                });
            }
        }
    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");
    }
Exemple #3
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);
    }
        public ServerMob(GameSession session, MobData mobId, Tuple <MapTile, MapTile, MapTile> spawn, int toTeam, GameUser user)
        {
            _sender    = user;
            _session   = session;
            _wayPoints = spawn;

            SenderId = user.User.Id;

            user.MobsSend++;
            MobData      = mobId;
            StatusEffect = new List <MobStatusEffectModel>();
            TargetTeam   = toTeam;

            VisitedWayPoint = _wayPoints.Item2 == null;
            InstanceId      = InstanceHelper.GetNewInstanceId();

            X = spawn.Item1.X;
            Y = spawn.Item1.Y;

            MobId = mobId.MobId;
            Speed = (float)mobId.Speed;
            Hp    = mobId.Hp;

            TilePosX = spawn.Item1.X;
            TilePosY = spawn.Item1.Y;



            LastUpdate = 0;
            UpdatePath();
        }
Exemple #5
0
        public static void ParseMobTofile(byte[] data)
        {
            var temp = new MobData();

            using (var ms = new MemoryStream(data))
                using (var stream = new BinaryReader(ms, Encoding))
                {
                    stream.ReadBytes(12);
                    temp.MobModel = stream.ReadUInt32();
                    stream.ReadBytes(8);
                    temp.Unk7 = stream.ReadInt32();
                    stream.ReadBytes(12);
                    temp.Hp1 = stream.ReadUInt32();
                    temp.Hp2 = stream.ReadUInt32();
                    temp.Hp3 = stream.ReadUInt32();
                    stream.ReadBytes(5);
                    temp.Unk1 = stream.ReadByte();
                    temp.Unk2 = stream.ReadByte();
                    temp.Unk3 = stream.ReadByte();
                    stream.ReadBytes(9);
                    temp.Width = stream.ReadByte();
                    temp.Chest = stream.ReadByte();
                    temp.Leg   = stream.ReadByte();
                    stream.ReadBytes(2);
                    temp.Unk4  = stream.ReadByte();
                    temp.Unk5  = stream.ReadByte();
                    temp.MobId = stream.ReadUInt32();
                    temp.Unk6  = stream.ReadUInt32();
                }

            var pathFile = $"{Path}Mobs\\{temp.MobId}\\MobData.json";

            SaveToFile(pathFile, temp);
        }
Exemple #6
0
    public void Init(MobData aMobData)
    {
        this.pos                = aMobData.pos;
        this.size               = aMobData.size;
        this.facing             = aMobData.facing;
        this.transform.position = GameUtil.V2IOffsetV3(this.size, this.pos);
        Vector3 thiccness = new Vector3(0, 0, 2f);

        transform.localScale = GameUtil.V2IToV3(this.size) + thiccness;
        this.name            = "Mob: " + aMobData.mobPrefabName + " startingpos: " + this.pos;


        // foreach(System.Type componentType in aMobData.components) {
        //     IComponent component = gameObject.AddComponent(componentType) as IComponent;
        //     switch (componentType) {
        //         case System.Type IFallableType when IFallableType == typeof(IFallable):
        //             IFallable newIFallable = component as IFallable;
        //             newIFallable.fallTime = 1f;
        //             break;
        //         case System.Type IWalkableType when IWalkableType == typeof(IWalkable):
        //             IWalkable newIWalkable = component as IWalkable;
        //             newIWalkable.walkTime = 1f;
        //             break;
        //     }
        // }
        // PlayerSetup();
    }
Exemple #7
0
    // Parsing
    public static RoomData FromObject(JsonData jsonData)
    {
        RoomData roomData = new RoomData();

        int gameID = SessionData.GetInstance().GameID;
        int room_x = (int)jsonData["room_x"];
        int room_y = (int)jsonData["room_y"];
        int room_z = (int)jsonData["room_z"];

        float world_x = jsonData["world_x"].IsInt ? (float)((int)jsonData["world_x"]) : (float)((double)jsonData["world_x"]);
        float world_y = jsonData["world_y"].IsInt ? (float)((int)jsonData["world_y"]) : (float)((double)jsonData["world_y"]);
        float world_z = jsonData["world_z"].IsInt ? (float)((int)jsonData["world_z"]) : (float)((double)jsonData["world_z"]);

        roomData.RoomKey.Set(gameID, room_x, room_y, room_z);
        roomData.WorldPosition.Set(world_x, world_y, world_z);
        roomData.StaticRoomData = StaticRoomData.FromObject(roomData.RoomKey, jsonData["data"]);

        {
            JsonData portalList = jsonData["portals"];

            for (int portalIndex = 0; portalIndex < portalList.Count; portalIndex++)
            {
                JsonData   portalObject = portalList[portalIndex];
                RoomPortal portal       = RoomPortal.FromObject(portalObject);

                roomData.RoomPortals.Add(portal);
            }
        }

        {
            JsonData mobObjects = jsonData["mobs"];

            roomData.m_mobs = new Dictionary <int, MobData>();

            for (int mobIndex = 0; mobIndex < mobObjects.Count; mobIndex++)
            {
                JsonData mobObject = mobObjects[mobIndex];
                MobData  mobData   = MobData.FromObject(mobObject);

                roomData.SetMobById(mobData.mob_id, mobData);
            }
        }

        {
            JsonData energyTankObjects = jsonData["energyTanks"];

            roomData.m_energyTanks = new Dictionary <int, EnergyTankData>();

            for (int energyTankIndex = 0; energyTankIndex < energyTankObjects.Count; energyTankIndex++)
            {
                JsonData       energyTankObject = energyTankObjects[energyTankIndex];
                EnergyTankData energyTankData   = EnergyTankData.FromObject(energyTankObject);

                roomData.SetEnergyTankById(energyTankData.energy_tank_id, energyTankData);
            }
        }

        return(roomData);
    }
Exemple #8
0
 public MobFollowingState(MobData mobData, Transform transform, AudioSource audioS, List <AudioClip> clips)
 {
     mobData.isPlayerDetected = false;
     this.transform           = transform;
     this.audioSource         = audioS;
     this.clips = clips;
     OnEnter();
 }
    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);
    }
    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");
    }
Exemple #11
0
        public void Init()
        {
            CharacterData = new CharacterData(GetPath(Path.Combine("Character", "CharacterConfig")));
            _log.Info("Loaded CharacterConfig...");

            ItemsData = new ItemsData(GetPath(Path.Combine("Game", "ItemList.bin")));
            _log.Info("Loaded {0} items.", ItemsData.Count);

            MnData = new MnData(GetPath(Path.Combine("Game", "MN.bin")));
            _log.Info("Loaded {0} monster names.", MnData.Count);

            NpcData = new NpcData(GetPath("Npcs", false));
            _log.Info("Loaded {0} npcs.", NpcData.Count);

            MobData = new MobData(GetPath("Mobs", false));
            _log.Info("Loaded {0} mobs.", MobData.Count);

            QuestData = new QuestData(GetPath(Path.Combine("Game", "Quest.bin")));
            _log.Info("Loaded {0} quests.", QuestData.Count);

            SkillData = new SkillDataData(GetPath(Path.Combine("Game", "SkillData.bin")));
            _log.Info("Loaded {0} skills.", SkillData.Count);

            using (var connection = DatabaseManager.Instance.GetConnection())
            {
                ConvertCoreData = new ConvertCoreData(connection);
                _log.Info("Loaded {0} core converts.", ConvertCoreData.Count);

                GearCoresData = new GearCoresData(connection);
                _log.Info("Loaded {0} core upgrades.", GearCoresData.Count);

                ExpData = new ExpData(connection);
                _log.Info("Loaded {0} levels.", ExpData.Count);

                PranExpData = new ExpData(connection, true);
                _log.Info("Loaded {0} pran levels.", PranExpData.Count);

                MakeItemsData = new MakeItemsData(connection);
                _log.Info("Loaded {0} make items.", MakeItemsData.Count);

                MapsData = new MapsData(connection);
                _log.Info("Loaded {0} maps.", MapsData.Count);

                RecipesData = new RecipesData(connection);
                _log.Info("Loaded {0} recipes.", RecipesData.Count);

                ReinforceAData = new ReinforceAData(connection);
                ReinforceWData = new ReinforceWData(connection);
                _log.Info("Loaded {0} reinforce values.", ReinforceAData.Count + ReinforceWData.Count);

                SetsData = new SetsData(connection);
                _log.Info("Loaded {0} sets.", SetsData.Count);

                TitlesData = new TitlesData(connection);
                _log.Info("Loaded {0} titles.", TitlesData.Count);
            }
        }
Exemple #12
0
    public static void AddPlayer(int aX, int aY, LevelData aLevelData)
    {
        Vector2Int startingPos = new Vector2Int(aX, aY);
        MobData    playerData  = ScriptableObject.CreateInstance("MobData") as MobData;
        Vector2Int playerSize  = new Vector2Int(2, 3);

        playerData.Init(playerSize, startingPos, Vector2Int.right, "Player");
        aLevelData.mobDataList.Add(playerData);
    }
Exemple #13
0
 private void DoPostProcess()
 {
     MobData.PostProcess(this);
     SpellData.PostProcess(this);
     TuningData.PostProcess(this);
     CharacterData.PostProcess(this);
     World.PostProcess(this);
     WorldData.PostProcess(this);
 }
Exemple #14
0
    private void spawnMob(int id, Vector2 pos, float respawn_time)
    {
        MobData data = Config.Mobs[id];

        if (data != null)
        {
            mobs.Add(new Mob(data, this, new Vector3(pos.X, heightMap[(int)pos.X, (int)pos.Y], pos.Y), respawn_time, 0, false));
        }
    }
        public static int CalculateDamageForSplash(TowerData tower, MobData mob, List <MobStatusEffectModel> effectList)
        {
            var dmg = ReduceDamageByArmor(GetDamageByArmorAndAttack(tower.SplashDamage, mob.Armor, tower.DmgType), StatusCalculator.GetReducedArmorByStatus(mob, effectList));

            if (dmg <= 0)
            {
                return(1);
            }
            return(dmg);
        }
Exemple #17
0
 public void Init(MobData _data, int _mid, float _hp, float _maxHp, Vector3 _pos, int _focus, int _gid)
 {
     this.data     = _data;
     this.mid      = _mid;
     this.position = _pos;
     this.maxHp    = _maxHp;
     this.hp       = _hp;
     this.focus    = _focus;
     this.gid      = _gid;
 }
Exemple #18
0
        public ushort GetMobIDFromName(string name)
        {
            MobInfoServer mis = null;

            if (MobData.TryGetValue(name, out mis))
            {
                return((ushort)mis.ID);
            }
            return(0);
        }
 public void KilledMob(MobData mobId)
 {
     Kills++;
     Owner.Kills++;
     Owner.Money += mobId.GoldDrop;
     Xp          += mobId.XpDrop;
     Owner.Xp    += mobId.XpDrop;
     IsFire       = false;
     hasChanged   = true;
 }
Exemple #20
0
        public static int GetReducedArmorByStatus(MobData mob, List <MobStatusEffectModel> effects)
        {
            //Only use max value
            if (effects == null || mob.ArmorAmount == 0 || effects.All(a => a.Type != MobStatusEffect.ArmoreReduced))
            {
                return(mob.ArmorAmount);
            }
            var reduced = effects.Where(a => a.Type == MobStatusEffect.ArmoreReduced).Max(a => a.Value);

            return((int)Math.Round(mob.ArmorAmount - (mob.ArmorAmount * (reduced / 100f))));
        }
        private bool SpawnMob(double delta, MobData mobId, GameUser user)
        {
            //return false;
            if (!_allowSendEnemys)
            {
                return(false);
            }
            if (!_session.MapHandler.IsReady)
            {
                return(false);
            }
            if (_session.GameMobs.Count > _session.Setting.MaxMobs)
            {
                return(false);
            }
            if (_playerMobSpawnDelay[user.User.Id] < _session.Setting.MobSpawnDelay)
            {
                return(false);
            }
            if (user.Money < mobId.Cost)
            {
                return(false);
            }
            if (_session.GameMobs.Count(m => m.SenderTeamId == user.TeamId) > _session.Setting.MaxMobsPerTeam)
            {
                return(false);
            }

            user.Money -= mobId.Cost;

            user.Income += mobId.AddIncome;

            //Reset Values
            _playerMobSpawnDelay[user.User.Id] = 0;
            _session.Teams.Where(t => t.Value.Count > 0 && t.Key != user.TeamId).ToList().ForEach(t =>
            {
                if (_session.Setting.SpawnOnAll)
                {
                    _session.MapHandler.GetAllSpawns(t.Key).ForEach(m =>
                    {
                        var mob = new ServerMob(_session, mobId, m, t.Key, user);
                        _session.GameMobs.Add(mob);
                    });
                }
                else
                {
                    var mob = new ServerMob(_session, mobId, _session.MapHandler.GetRandomSpawn(t.Key), t.Key, user);
                    _session.GameMobs.Add(mob);
                }
            });


            return(true);
        }
    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 + "\"");
    }
Exemple #23
0
    public static bool ReadMobData()
    {
        if (!File.Exists(Config.LocalePath + "mob_data"))
        {
            return(false);
        }

        string raw = File.ReadAllText(Config.LocalePath + "mob_data");

        if (raw == "")
        {
            return(false);
        }

        try
        {
            int       len   = getFinalLocaleId(raw);
            MobData[] mobs  = new MobData[len];
            string[]  lines = raw.Split(Environment.NewLine.ToCharArray());
            for (int l = 0; l < lines.Length; l++)
            {
                if (lines[l] == "" || lines[l][0] == '#')
                {
                    continue;
                }

                string[] line_contents = lines[l].Split('\t');
                Int32.TryParse(line_contents[0].ToString(), out int id);
                string        name          = line_contents[1];
                MOB_WALK_TYPE walk_type     = (MOB_WALK_TYPE)Enum.Parse(typeof(MOB_WALK_TYPE), line_contents[2]);
                float         wander_radius = float.Parse(line_contents[3].ToString());
                Int32.TryParse(line_contents[4].ToString(), out int wanderWait);
                float.TryParse(line_contents[5].ToString(), out float maxHp);
                float.TryParse(line_contents[6].ToString(), out float hpRegen);
                float.TryParse(line_contents[7].ToString(), out float movSpeed);
                float.TryParse(line_contents[8].ToString(), out float attSpeed);
                float.TryParse(line_contents[9].ToString(), out float pAttack);
                float.TryParse(line_contents[10].ToString(), out float mAttack);
                float.TryParse(line_contents[11].ToString(), out float pDef);
                float.TryParse(line_contents[12].ToString(), out float mDef);
                float.TryParse(line_contents[13].ToString(), out float attRange);

                MobStats nStats = new MobStats(walk_type, wander_radius, wanderWait, maxHp, hpRegen, attSpeed, movSpeed, pAttack, mAttack, pDef, mDef, attRange);
                MobData  nData  = new MobData(id, name, nStats);
                mobs[id] = nData;
            }

            Config.Mobs = mobs.ToArray();
        }
        catch (Exception e) { Logger.Syserr(e.Message); return(false); }

        return(true);
    }
Exemple #24
0
    private void spawnGroup(int id, Vector2 pos, float respawn_time)
    {
        GroupData data = Config.MobGroups[id];

        if (data != null)
        {
            int gid = generateGroupId();
            for (int i = 0; i < data.mobIds.Length; i++)
            {
                MobData mdata = Config.Mobs[data.mobIds[i]];
                mobs.Add(new Mob(mdata, this, new Vector3(pos.X, heightMap[(int)pos.X, (int)pos.Y], pos.Y), respawn_time, gid, true));
            }
        }
    }
Exemple #25
0
    public MobEntity(int characterId)
    {
        SessionData sessionData = SessionData.GetInstance();

        m_mobId = characterId;
        m_mobData = sessionData.CurrentGameData.CurrentRoom.GetMobById(m_mobId);

        m_position = new Point3d(m_mobData.x, m_mobData.y, m_mobData.z);
        m_facing = MathConstants.GetUnitVectorForAngle(m_mobData.angle);
        m_dialogTimer = -1.0f;

        m_mobWidget = null;
        m_pathfindingComponent = null;
        m_steeringComponent = null;
    }
    public MobEntity(int characterId)
    {
        SessionData sessionData = SessionData.GetInstance();

        m_mobId   = characterId;
        m_mobData = sessionData.CurrentGameData.CurrentRoom.GetMobById(m_mobId);

        m_position    = new Point3d(m_mobData.x, m_mobData.y, m_mobData.z);
        m_facing      = MathConstants.GetUnitVectorForAngle(m_mobData.angle);
        m_dialogTimer = -1.0f;

        m_mobWidget            = null;
        m_pathfindingComponent = null;
        m_steeringComponent    = null;
    }
Exemple #27
0
        public CharactersManager()
        {
            DataTable mobsProtoTable = DatabaseManager.ReturnQuery("SELECT * FROM mobs_proto");

            for (int i = 0; i < mobsProtoTable.Rows.Count; i++)
            {
                DataRow row = mobsProtoTable.Rows[i];

                MobData data = new MobData()
                {
                    baseId    = (int)row["id"],
                    name      = (string)row["name"],
                    level     = (sbyte)row["lvl"],
                    health    = (int)row["health"],
                    expReward = (int)row["exp_reward"],
                    onClick   = (ClickType)(sbyte)row["on_click"],
                };

                mobsDataList.Add(data.baseId, data);
            }

            DataTable mobsTable = DatabaseManager.ReturnQuery("SELECT * FROM mobs");

            for (int i = 0; i < mobsTable.Rows.Count; i++)
            {
                DataRow row = mobsTable.Rows[i];

                int id = lastId++;
                Mob x  = CharactersManager.CreateMob(id);
                x.BaseId = (int)row["base_id"];
                MobData data = mobsDataList[x.BaseId];
                x.OnClick = data.onClick;

                StatsContainer stats = x.GetStatsContainer();
                stats.SetStat(StatType.NAME, (string)data.name);
                stats.SetStat(StatType.LEVEL, (short)data.level);
                stats.SetStat(StatType.HEALTH, (int)data.health);
                stats.SetStat(StatType.MAX_HEALTH, (int)data.health);
                stats.SetStat(StatType.POS_X, (short)row["pos_x"]);
                stats.SetStat(StatType.POS_Z, (short)row["pos_z"]);
                stats.SetStat(StatType.ROTATION, (short)row["rotation"]);
                x.SetSpawnPosition((short)row["pos_x"], (short)row["pos_z"]);

                AddCharacter(x);

                x.Init();
            }
        }
 public static MobData GreenCultist()
 {
     if (_greenCultist == null)
     {
         _greenCultist = new MobData
         {
             Life       = 150,
             Speed      = 180,
             Animations = Sprites.GreenCultist,
             Size       = 40,
             Spells     = new SpellData[1],
             LootRate   = 0.6,
             ScoreValue = 4
         };
         _greenCultist.Spells[0] = Spells.GreenCultistAttack();
     }
     return(_greenCultist);
 }
Exemple #30
0
    public override string ToChatString(GameWorldController gameWorldController)
    {
        string hackerName = "";

        if (HackerFaction == GameConstants.eFaction.ai)
        {
            MobData mobData = gameWorldController.Model.GetMobData(HackerId);
            MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name);

            hackerName = mobType.Name;
        }
        else if (HackerFaction == GameConstants.eFaction.player)
        {
            hackerName = gameWorldController.Model.GetCharacterData(HackerId).character_name;
        }

        return(base.ToChatString(gameWorldController) + " Energy Tank hacked by " + hackerName);
    }
Exemple #31
0
 public static double GetSpeedValueByStatus(MobData mob, List <MobStatusEffectModel> effects)
 {
     if (effects == null)
     {
         return(mob.Speed);
     }
     if (effects.Any(se => se.Type == MobStatusEffect.Stun))
     {
         return(0);
     }
     //Only use hightest Slowingeffect
     if (effects.Any(se => se.Type == MobStatusEffect.Slowed))
     {
         var slow = effects.Max(se => se.Value);
         return(Math.Round(mob.Speed - mob.Speed * (slow / 100f), 2));
     }
     return(mob.Speed);
 }
Exemple #32
0
    public static MobData FromObject(JsonData jsonData)
    {
        MobData result = new MobData();

        result.mob_id = (int)jsonData["mob_id"];
        result.mob_type_name = (string)jsonData["mob_type_name"];
        result.health = (int)jsonData["health"];
        result.energy = (int)jsonData["energy"];
        result.game_id = (int)jsonData["game_id"];
        result.room_x = (int)jsonData["room_x"];
        result.room_y = (int)jsonData["room_y"];
        result.room_z = (int)jsonData["room_z"];
        result.x = jsonData["x"].IsInt ? (float)((int)jsonData["x"]) : (float)((double)jsonData["x"]);
        result.y = jsonData["y"].IsInt ? (float)((int)jsonData["y"]) : (float)((double)jsonData["y"]);
        result.z = jsonData["z"].IsInt ? (float)((int)jsonData["z"]) : (float)((double)jsonData["z"]);
        result.angle = jsonData["angle"].IsInt ? (float)((int)jsonData["angle"]) : (float)((double)jsonData["angle"]);

        return result;
    }
Exemple #33
0
    // Gross
    public MobWidget(WidgetGroup parentGroup, MobWidgetStyle style, MobData mobData)
        : base(parentGroup,
            style.Width,
            style.Height,
            GameConstants.ConvertRoomPositionToPixelPosition(mobData.PositionInRoom).x,
            GameConstants.ConvertRoomPositionToPixelPosition(mobData.PositionInRoom).y)
    {
        MobType mobType = MobTypeManager.GetMobTypeByName(mobData.mob_type_name);

        m_style = style;

        m_title =
            new LabelWidget(
                this,
                style.LabelWidth, // width
                style.LabelHeight, // height
                (m_style.Width / 2.0f) - (m_style.LabelWidth / 2.0f), // local x
                -m_style.BoundsHeight - style.LabelHeight, // local y
                mobType.Label); // text
        m_title.Alignment = TextAnchor.UpperCenter;

        m_energy =
            new LabelWidget(
                this,
                style.LabelWidth, // width
                style.LabelHeight, // height
                (m_style.Width / 2.0f) - (m_style.LabelWidth / 2.0f), // local x
                0, // local y
                ""); // text
        m_energy.Alignment = TextAnchor.UpperCenter;
        this.Energy = mobData.energy;

        // Create the sprite game object
        {
            string archetype = mobType.Name;
            string gameObjectPath = "Gfx/Sprites/Enemies/" + archetype + "/" + archetype + "_sprite";

            m_spriteObject =
                GameObject.Instantiate(
                    Resources.Load<GameObject>(gameObjectPath)) as GameObject;
            m_spriteAnimator = m_spriteObject.GetComponent<Animator>();

            UpdateWorldPosition();
        }

        // Create the dialog label
        m_dialog =
            new LabelWidget(
                this,
                style.DialogWidth, // width
                style.DialogHeight, // height
                (m_style.Width / 2.0f) - (m_style.DialogWidth / 2.0f), // local x
                m_title.LocalY - style.DialogHeight, // local y
                ""); // text
        m_dialog.FontSize = 14;
        m_dialog.Color = Color.red;
        m_dialog.Alignment = TextAnchor.UpperCenter;
        m_dialog.Visible = false;

        // Set the initial animation controller parameters
        m_spriteAnimator.SetFloat(SPEED_FLOAT_PARAMETER, 0.0f);
        m_spriteAnimator.SetFloat(FACING_X_FLOAT_PARAMETER, 0.0f);
        m_spriteAnimator.SetFloat(FACING_Y_FLOAT_PARAMETER, -1.0f);
        m_spriteAnimator.SetBool(IS_ATTACKING_BOOL_PARAMETER, false);

        // Create the vision cone
        m_visionCone =
            new VisionConeWidget(
                this,
                mobType.Name + mobData.mob_id.ToString(),
                mobType.VisionConeDistance,
                mobType.VisionConeAngleDegrees,
                0.0f,
                0.0f,
                0.0f);
        m_visionCone.ConeFacing = MathConstants.GetAngleForDirection(MathConstants.eDirection.down);
    }
    protected override void ParseParameters(JsonData parameters)
    {
        base.ParseParameters(parameters);

        m_mobState = MobData.FromObject( parameters["mob_state"] );
    }
 public MobWidget AddMobWidget(MobData mobData)
 {
     // Constructor adds the widget to the entity widget group
     return new MobWidget(m_entityGroup, mobStyle, mobData);
 }
 public GameEvent_MobSpawned()
     : base()
 {
     EventType = GameEvent.eEventType.mob_spawned;
     m_mobState = new MobData();
 }
Exemple #37
0
 public void SetMobById(int mob_id, MobData mobState)
 {
     m_mobs.Add(mob_id,  mobState);
 }