Ejemplo n.º 1
0
        public static Func <ISpell> CreateSpell(Vector3 poolPosition, SpellObject spellObject, UsableServices services)
        {
            Func <ISpell> result = null;

            switch (spellObject.SpellType)
            {
            case SpellType.None:
                break;

            case SpellType.Meteor:
                result = () => new SpellMeteor(poolPosition, spellObject, services);
                break;

            case SpellType.Golem:
                result = () => new SpellGolem(poolPosition, spellObject, services);
                break;

            case SpellType.Shake:
                result = () => new SpellShake(poolPosition, spellObject, services);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(result);
        }
Ejemplo n.º 2
0
        protected Spell(Vector3 poolPosition, SpellObject spellObject, UsableServices services)
        {
            Id             = spellObject.Id;
            _speed         = spellObject.Speed;
            _hitRadius     = spellObject.HitRadius;
            SpellColorType = spellObject.SpellColorType;
            _destroyDelay  = spellObject.DestroyAfterTime;
            _poolPos       = poolPosition;
            _services      = services;
            _isSpawnEnemy  = spellObject.MustSpawnOnEnemyPosition;
            _statuses      = new Status[spellObject.StatusObjects.Length];

            if (!_isSpawnEnemy)
            {
                Transform = spellObject.SpawnSpellPosition;
            }

            _projectile = Object.Instantiate(spellObject.Spell);
            _projectile.SetActive(false);
            _projectile.name = $"{Id}";

            int index = 0;

            foreach (StatusObject state in spellObject.StatusObjects)
            {
                _statuses[index] = Invoker.CreateStatus(state);
                index++;
            }
        }