Пример #1
0
 private void DisableAttacking(MobInfo _mobInfo)
 {
     if (mobBattleInfo.MobInfo == _mobInfo)
     {
         this.enabled = false;
     }
 }
Пример #2
0
 private void DisableHealth(MobInfo _mobInfo)
 {
     if (mobBattleInfo.MobInfo == _mobInfo)
     {
         this.enabled = false;
     }
 }
Пример #3
0
        void Start()
        {
            MobInfo mob = BattleManager.Instance.Mob;

            if (mob == null)
            {
                mobBattleInfo.Initialize(
                    "TestMob",
                    new ScienceNum {
                    baseValue = 10
                },
                    new ScienceNum {
                    baseValue = 2
                },
                    1f,
                    null
                    );
                return;
            }
            spriteRenderer.sprite = mob.MobSO.sprite;
            mobBattleInfo.Initialize(
                mob.MobSO.name,
                mob.MobSO.health * mob.DifficultyScale,
                mob.MobSO.attackDamage * mob.DifficultyScale,
                mob.MobSO.attackFrequency,
                mob
                );
        }
Пример #4
0
        void Update()
        {
            timer += Time.deltaTime;
            if (timer > spawnerInfo.SpawnTimer)
            {
                timer -= spawnerInfo.SpawnTimer;

                if (spawnerInfo.SpawnCount >= spawnerInfo.SpawnLimit)
                {
                    return;
                }

                GameObject go = ObjectPooler.Instance.GetPooledObject(mobPrefab);
                go.transform.SetParent(spawnerInfo.SpawnPoints[UnityEngine.Random.Range(0, spawnerInfo.SpawnPoints.Length)]);
                go.transform.localPosition = Vector3.zero;

                //Use object pooler to instantiate mobPrefab
                MobInfo mobInfo = go.GetComponent <MobInfo>();

                //Sum up the total weight of mobs
                float totalWeight = 0f;
                foreach (WeightedMob wm in waveInfo.CurrentWave.mobs)
                {
                    totalWeight += wm.weight;
                }

                //Pick a random number up to the maximum weight
                float randMob = UnityEngine.Random.Range(0f, totalWeight);

                //Iterate through the mobs until that weight is reached.
                MobSO mob = null;
                foreach (WeightedMob wm in waveInfo.CurrentWave.mobs)
                {
                    randMob -= wm.weight;
                    if (randMob <= 0f)
                    {
                        mob = wm.mob;
                        break;
                    }
                }

                mobInfo.Initialize(mob, scalerInfo.DifficultyScale);
                MobMovement mobMovement = mobInfo.GetComponent <MobMovement>();
                mobMovement.Initialize();
                //Update the spawnerInfo with this specific mob
                spawnerInfo.MobSpawned(mobInfo);
                //Generic event stating a mob has spawned
                EventManager.Instance.MobSpawned(mobInfo);
            }
        }
Пример #5
0
 private void RemoveMob(MobInfo mobInfo)
 {
     spawnerInfo.RemoveMob(mobInfo);
 }