示例#1
0
 void Start()
 {
     mobStats = GetComponent<MobStats>();
     mobCollision = GetComponent<MobCollisionController>();
     //Setting Local Variables
     x = transform.localScale.x;
 }
示例#2
0
        public ModifyMobStatContext(MobStats stats)
        {
            _stats = stats;

            _setHistory   = new MobStats();
            _resetHistory = new MobStats();
        }
示例#3
0
    void UpdateTarget()
    {
        if (target != null && TargetInRange(target, transform, range))
        {
            return;
        }
        GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
        float        dist;
        float        minDist     = Mathf.Infinity;
        Transform    foundTarget = null;

        foreach (GameObject enemy in enemies)
        {
            dist = Vector3.Distance(transform.position, enemy.transform.position);
            if (dist < minDist)
            {
                minDist     = dist;
                foundTarget = enemy.transform;
            }
        }
        if (minDist <= range && foundTarget != null)
        {
            target = foundTarget;
            enemy  = target.GetComponent <MobStats>();
        }
        else
        {
            target = null;
        }
    }
示例#4
0
 void Start()
 {
     startingPoint = transform.position;
     playerObject  = GameObject.FindGameObjectWithTag("Player");
     agent         = GetComponent <NavMeshAgent>();
     mobStats      = GetComponent <MobStats>();
     bossAnimator  = GetComponent <BossAnimator>();
 }
示例#5
0
    void damage(Transform enemy)
    {
        MobStats mob = enemy.GetComponent <MobStats>();

        if (mob != null)
        {
            mob.TakeDamage(bulletDamage * damageAmplifier);
        }
    }
示例#6
0
 private void attackIfCan(List <Mob> mobs, MobStats stats, Vector3 attackPosition)
 {
     foreach (Mob enemy in mobs)
     {
         float dist = Vector3.Distance(enemy.transform.position, attackPosition);
         if (dist < stats.attackRadius)
         {
             enemy.receiveDamage(stats.damage);
         }
     }
 }
示例#7
0
    public override void doActions(float deltaTime, GameObject self, MobStats selfStats, MobSceneData sceneData)
    {
        Mob mob = self.GetComponent <Mob>();

        if (mob.target == null)
        {
            Supervisor.chooseTarget(mob, selfStats, sceneData);
        }

        targetApproachAndAttack(deltaTime, mob, selfStats, sceneData);
    }
示例#8
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);
    }
    void Awake()
    {
        nav = GetComponent<NavMeshAgent>();
        mobStats = GetComponent<MobStats>();
        anim = GetComponent<Animator>();
        mobAudio = GetComponent<AudioSource>();
        hitParticles = GetComponentInChildren<ParticleSystem>();
        capsuleCollider = GetComponent<CapsuleCollider>();

        aggroTarget = GetNerestTarget();

        attackTimer = TargetRefreshTimer = 0f;
        team = Team.Mobs;
    }
    bool isSinking; // Automata

    void Awake()
    {
        nav             = GetComponent <NavMeshAgent>();
        mobStats        = GetComponent <MobStats>();
        anim            = GetComponent <Animator>();
        mobAudio        = GetComponent <AudioSource>();
        hitParticles    = GetComponentInChildren <ParticleSystem>();
        capsuleCollider = GetComponent <CapsuleCollider>();

        aggroTarget = GetNerestTarget();

        attackTimer = TargetRefreshTimer = 0f;
        team        = Team.Mobs;
    }
示例#11
0
 private void attackIfCan(List <Player> mobs, MobStats stats, Vector3 attackPosition)
 {
     foreach (Player enemy in mobs)
     {
         if (enemy == null)
         {
             continue;
         }
         float dist = Vector3.Distance(enemy.transform.position, attackPosition);
         if (dist < stats.attackRadius)
         {
             enemy.receiveDamage(stats.damage);
         }
     }
 }
示例#12
0
    public void attackSignal(GameObject from, MobStats stats)
    {
        if (from == null)
        {
            return;
        }

        Vector3 pos = from.transform.position;

        if (stats.team == 0)
        {
            if (!from.GetComponent <Player>().isRespawned)
            {
                playerAttacked = true;
            }

            if (playerTeam == 0 || playerTeam == 2)
            {
                attackIfCan(currentSceneState.redTeam, stats, pos);
            }
            if (playerTeam == 0 || playerTeam == 1)
            {
                attackIfCan(currentSceneState.blueTeam, stats, pos);
            }
        }
        else if (stats.team == 1)
        {
            if (playerTeam != 1)
            {
                attackIfCan(currentSceneState.players, stats, pos);
            }
            attackIfCan(currentSceneState.blueTeam, stats, pos);
        }
        else if (stats.team == 2)
        {
            if (playerTeam != 2)
            {
                attackIfCan(currentSceneState.players, stats, pos);
            }
            attackIfCan(currentSceneState.redTeam, stats, pos);
        }
    }
示例#13
0
 public static void chooseTarget(Mob self, MobStats selfStats, MobSceneData sceneData)
 {
     if (selfStats.team != Supervisor.self.playerTeam && chance(0.25f))
     {
         // select some player
         self.target = randomFrom(Supervisor.currentSceneState.players);
     }
     else
     {
         // select enemy
         if (selfStats.team == 1)
         {
             self.target = randomFrom(Supervisor.currentSceneState.blueTeam);
         }
         else
         {
             self.target = randomFrom(Supervisor.currentSceneState.redTeam);
         }
     }
 }
示例#14
0
    public void targetApproachAndAttack(float deltaTime, Mob self, MobStats selfStats, MobSceneData sceneData)
    {
        if (self.target == null)
        {
            return;
        }

        Vector3 targetPos = self.target.transform.position;
        float   dist      = Vector3.Distance(targetPos, self.transform.position);

        if (dist > 0.9f * selfStats.attackRadius)
        {
            Vector3 dir = targetPos - self.transform.position;
            dir = Vector3.Normalize(dir);
            self.transform.position += dir * selfStats.moveSpeed * deltaTime;
        }
        else
        {
            if (self.canAttack(selfStats))
            {
                self.attack(self.gameObject, selfStats);
            }
        }
    }
示例#15
0
 void Start()
 {
     nextWaypoint = Waypoint.waypointList[waypointIndex];
     buildManager = BuildManager.instance;
     mobStats     = GetComponent <MobStats>();
 }
 // Use this for initialization
 void Start()
 {
     player   = GameObject.Find("Player");
     mobStats = GetComponent <MobStats>();
     animator = GetComponent <Animator>();
 }
示例#17
0
 public MobData(int _id, string _name, MobStats _stats)
 {
     this.id    = _id;
     this.name  = _name;
     this.stats = _stats;
 }
示例#18
0
 public void attack(GameObject self, MobStats selfStats)
 {
     lastTimeAttack = Supervisor.playtime;
     Supervisor.self.attackSignal(self, selfStats);
     playAttackAnimation(self);
 }
示例#19
0
 private void Awake()
 {
     animator = GetComponent <Animator>();
     player   = GameObject.Find("Player");
     mobStats = GetComponent <MobStats>();
 }
示例#20
0
 public abstract void doActions(float deltaTime, GameObject self, MobStats selfStats, MobSceneData sceneData);
示例#21
0
 void Start()
 {
     mobStats = GetComponent<MobStats>();
 }
示例#22
0
        public void TargetKilled(Player player, Player target, Room room)
        {
            player.Target = String.Empty;
            player.Status = CharacterStatus.Status.Standing;
            target.Status = CharacterStatus.Status.Ghost;
            target.Target = string.Empty;

            DeathCry(room, target);

            _gain.GainExperiencePoints(player, target);

            _quest.IsQuestMob(player, target.Name);

            if (target.ConnectionId != "mob")
            {
                Helpers.PostToDiscord($"{target.Name} got killed by {player.Name}!", "event", _cache.GetConfig());

                if (player.ConnectionId != "mob")
                {
                    target.PlayerDeaths += 1;
                    player.PlayerKills  += 1;
                }
                else
                {
                    target.MobDeaths += 1;
                }
            }

            _writer.WriteLine("<p class='dead'>You are dead. R.I.P.</p>", target.ConnectionId);


            var targetName = target.Name.ToLower(CultureInfo.CurrentCulture);
            var corpse     = new Item.Item()
            {
                Name        = $"The corpse of {targetName}",
                Description = new Description()
                {
                    Room = $"The corpse of {targetName} is laying here.",
                    Exam = target.Description,
                    Look = target.Description,
                },
                Slot      = Equipment.EqSlot.Held,
                Level     = 1,
                Stuck     = true,
                Container = new Container()
                {
                    Items   = new ItemList(),
                    CanLock = false,
                    IsOpen  = true,
                    CanOpen = false,
                },
                ItemType   = Item.Item.ItemTypes.Container,
                Decay      = target.ConnectionId.Equals("mob", StringComparison.OrdinalIgnoreCase) ? 10 : 20,
                DecayTimer = 300 // 5 minutes,
            };

            foreach (var item in target.Inventory)
            {
                item.Equipped = false;
                corpse.Container.Items.Add(item);
            }

            if (target.ConnectionId.Equals("mob", StringComparison.CurrentCultureIgnoreCase))
            {
                player.MobKills += 1;

                var randomItem = _randomItem.WeaponDrop(player);

                if (randomItem != null)
                {
                    corpse.Container.Items.Add(randomItem);
                }
            }

            // clear list
            target.Inventory = new ItemList();
            // clear equipped
            target.Equipped = new Equipment();

            var mount = target.Pets.FirstOrDefault(x => x.Name.Equals(target.Mounted.Name));

            if (mount != null)
            {
                target.Pets.Remove(mount);
                target.Mounted.Name = string.Empty;
            }

            // add corpse to room
            room.Items.Add(corpse);
            _clientUi.UpdateInventory(target);
            _clientUi.UpdateEquipment(target);
            _clientUi.UpdateScore(target);
            _clientUi.UpdateScore(player);

            room.Clean = false;

            _cache.RemoveCharFromCombat(target.Id.ToString());
            _cache.RemoveCharFromCombat(player.Id.ToString());

            if (target.ConnectionId.Equals("mob", StringComparison.CurrentCultureIgnoreCase))
            {
                room.Mobs.Remove(target);
                var getTodayMobStats = _pdb.GetList <MobStats>(PlayerDataBase.Collections.MobStats).FirstOrDefault(x => x.Date.Date.Equals(DateTime.Today));

                if (getTodayMobStats != null)
                {
                    getTodayMobStats.MobKills += 1;
                }
                else
                {
                    getTodayMobStats = new MobStats()
                    {
                        MobKills     = 1,
                        PlayerDeaths = 0,
                        Date         = DateTime.Now,
                    };
                }
                _pdb.Save <MobStats>(getTodayMobStats, PlayerDataBase.Collections.MobStats);
            }
            else
            {
                room.Players.Remove(target);
                var getTodayMobStats = _pdb.GetList <MobStats>(PlayerDataBase.Collections.MobStats).FirstOrDefault(x => x.Date.Date.Equals(DateTime.Today));

                if (getTodayMobStats != null)
                {
                    getTodayMobStats.PlayerDeaths += 1;
                }
                else
                {
                    getTodayMobStats = new MobStats()
                    {
                        MobKills     = 0,
                        PlayerDeaths = 1,
                        Date         = DateTime.Now,
                    };
                }
                _pdb.Save <MobStats>(getTodayMobStats, PlayerDataBase.Collections.MobStats);
            }
            // take player to Temple / recall area

            if (target.ConnectionId != "mob")
            {
                target.Status = CharacterStatus.Status.Resting;
                var newRoom = _cache.GetRoom(target.RecallId);

                target.Buffer = new Queue <string>();

                target.RoomId = Helpers.ReturnRoomId(newRoom);

                newRoom.Players.Add(target);
                target.Buffer.Enqueue("look");
            }
        }
示例#23
0
 public bool canAttack(MobStats selfStats)
 {
     return(Supervisor.playtime - lastTimeAttack > selfStats.attackPause);
 }