Example #1
0
        private void AddToQueue(EEnemyType type, EnemyUnit unit, float prio = 0f)
        {
            var toAdd = new PrioritizableObject <EnemyUnit>(unit, prio);

            GetPrioritiyQueueByEnemyType(type).Add(toAdd);
            mAllUnits.Add(toAdd);
        }
Example #2
0
        public Entity Create(EEnemyType type, Vector3 position, Vector3 forward)
        {
            var view   = _pool.Spawn(position, forward);
            var entity = CreateEntity(view);

            return(entity);
        }
Example #3
0
    protected void CheckEnemyType(EEnemyType type)
    {
        switch (type)
        {
        case EEnemyType.Mushroomy:
            InitMushroomy();
            break;

        case EEnemyType.Archer:
            InitArcher();
            break;

        case EEnemyType.Ghost:
            InitGhost();
            break;

        case EEnemyType.Medusa:
            InitMedusa();
            break;

        default:
            Debug.Log("적의 종류가 선택되지 않았습니다.");
            break;
        }
    }
Example #4
0
 public Enemy(EnemyBuilder enemyBuilder)
 {
     this.Name       = enemyBuilder.EnemyName;
     this.LifePoints = enemyBuilder.EnemyLifePoints;
     this.Position   = enemyBuilder.EnemyPosition;
     this.EnemyType  = enemyBuilder.EnemyType;
 }
Example #5
0
        // method that produces enemy military units when called up by the Ki
        internal EnemyUnit SpawnEnemy(EEnemyType type, Camera camera, Map.Map map, GameScreen gameScreen)
        {
            EnemyUnit enemyUnit;

            switch (type)
            {
            case EEnemyType.Attack:
                enemyUnit = new EnemyUnit(new Vector2(Center.X + 100, Center.Y + 30), camera, ref mDirector);
                break;

            case EEnemyType.Defend:
                enemyUnit = new EnemyHeavy(new Vector2(Center.X + 100, Center.Y + 30), camera, ref mDirector);
                break;

            case EEnemyType.Scout:
                enemyUnit = new EnemyFast(new Vector2(Center.X + 100, Center.Y + 30), camera, ref mDirector);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            gameScreen.AddObject(enemyUnit);
            return(enemyUnit);
        }
Example #6
0
    public void CreateEnemy(EEnemyType type, Vector3 pos)
    {
        var enemy = Instantiate(enemyPrefabs[(int)type], canvasParent);

        enemy.transform.localPosition = pos;
        enemy.GetComponentInChildren <EnemyMovement>().SetTarget(player);

        EnemyHPManager.GetInstance().enemyList.Add(enemy.GetComponentInChildren <EnemyHealth>());
    }
Example #7
0
        private void SpawnOneUnit(EEnemyType type, Spawner spawner)
        {
            var unit = spawner.SpawnEnemy(type, mDirector.GetStoryManager.Level.Camera,
                                          mDirector.GetStoryManager.Level.Map,
                                          mDirector.GetStoryManager.Level.GameScreen);

            //newly spawned units have no extra priority over others already existing.
            AddToQueue(type, unit);

            mIsCurrentlyMoving[unit] = false;
        }
        public static AbstractFactory GetFactory(EEnemyType enemy)
        {
            switch (enemy)
            {
            case EEnemyType.Normal:
                return(normalEnemyFactory);

            case EEnemyType.Big:
                return(bigEnemyFactory);
            }
            return(null);
        }
        public EnemyСharacteristicsVo GetСharacteristics(EEnemyType enemyType)
        {
            foreach (var enemyСharacteristicsVo in enemyСharacteristicsVos)
            {
                if (enemyType == enemyСharacteristicsVo.Type)
                {
                    return(enemyСharacteristicsVo);
                }
            }

            throw new Exception(
                      $"[{nameof(EnemyСharacteristicsDatabase)}] No characteristics for enemy {enemyType} in database");
        }
Example #10
0
    void Start()
    {
        attackCtrl     = GetComponentInChildren <EnemyAttack>();
        attackLongCtrl = GetComponentInChildren <EnemyAttack_Long>();
        healthCtrl     = GetComponentInChildren <EnemyHealth>();
        anim           = GetComponent <Animator>();
        enemyType      = GetComponent <EnemyCtrl>().EnemyType;

        if (enemyType != EEnemyType.TYPE1)
        {
            dist = 7.5f;
        }
    }
Example #11
0
        private void Retreat(EnemyUnit unit, EEnemyType type, GameTime gametime)
        {
            if (!mUnitToFlockingGroup.ContainsKey(unit))
            {
                mUnitToFlockingGroup[unit] = mDirector.GetMilitaryManager.GetNewFlock();
                mUnitToFlockingGroup[unit].AssignUnit(unit);
            }

            // make the scout that attacked retreat to a random structure of the ai
            mUnitToFlockingGroup[unit].FindPath(GetRandomPositionOnRectangle(mAi.GetBoundsOfStructure(mRandom.Next(mAi.GetStructureCount()))));

            mUnitsMovementSnapshot[(int)type] = (int)gametime.TotalGameTime.TotalMilliseconds;
        }
        public EnemyView GetEnemy(EEnemyType type)
        {
            foreach (var enemyVo in enemyVos)
            {
                if (enemyVo.Type == type)
                {
                    return(enemyVo.EnemyView);
                }
            }

            throw new Exception(
                      $"[{nameof(EnemyСharacteristicsDatabase)}] No prefab for enemytype {type} in database");
        }
Example #13
0
    IEnumerator Spawning()
    {
        while (true)
        {
            yield return(new WaitForSeconds(Random.Range(1.0f, 7.0f)));

            int randomCount = Random.Range(1, 3);

            for (int i = 0; i < randomCount; i++)
            {
                Vector3    randomPos  = Random.insideUnitCircle * Random.Range(1.0f, 2.0f);
                EEnemyType randomType = (EEnemyType)Random.Range(0, (int)EEnemyType._COUNT);
                CreateEnemy(randomType, transform.localPosition + randomPos);
            }
        }
    }
Example #14
0
        public Enemy(ILocationBehavior locationBehavoir, IRenderBehavior renderBehavior, float ratOfFire, float attackDistance,
            float sightiningDistance, float maxHealth, float speed, float health, EEnemyType typeOfEnemy)
            : base(locationBehavoir, renderBehavior)
        {
            this.buffList = new List<Buff>();
            this.ratOfFire = ratOfFire;
            this.AttackDistance = attackDistance;
            this.SightiningDistance = sightiningDistance;
            this.MaxHealth = maxHealth;
            TypOfEnemy = typeOfEnemy;

            lastAttack = 0;

            this.Speed = speed;
            this.Health = health;

            switch (typeOfEnemy)
            {
                case EEnemyType.E1:
                    moveRenderer = LoadedRenderer.Get("A_Krabbler_Move");
                    standRenderer = LoadedRenderer.Get("A_Krabbler_Stand");
                    break;
                case EEnemyType.E2:
                    moveRenderer = LoadedRenderer.Get("A_Schleimer_Move");
                    standRenderer = LoadedRenderer.Get("A_Schleimer_Stand");
                    break;
                case EEnemyType.E3:
                    moveRenderer = LoadedRenderer.Get("A_StachelKrabbe_Move");
                    standRenderer = LoadedRenderer.Get("A_StachelKrabbe_Stand");
                    break;
                case EEnemyType.E4:
                    moveRenderer = LoadedRenderer.Get("A_Schleimer_Move");
                    standRenderer = LoadedRenderer.Get("A_Schleimer_Stand");
                    break;
                case EEnemyType.E5:
                    moveRenderer = LoadedRenderer.Get("A_RoterDrache_Move");
                    standRenderer = LoadedRenderer.Get("A_RoterDrache_Stand");
                    break;
                case EEnemyType.E6:
                    moveRenderer = LoadedRenderer.Get("A_Hellboy_Move");
                    standRenderer = LoadedRenderer.Get("A_Hellboy_Stand");
                    break;
            }

            this.Activity = new NoActivity();
        }
Example #15
0
        private void UpdateLowestPriorityQueueElement(EEnemyType type)
        {
            if (GetPrioritiyQueueByEnemyType(type).Count <= 0)
            {
                return;
            }

            var minPrioUnit = GetPrioritiyQueueByEnemyType(type).DeleteMin();

            // we don't want to increase the priority if the unit is moving, this allows for us to not give units paths that
            // are already moving to one.
            if (mIsCurrentlyMoving[minPrioUnit.GetObject()])
            {
                GetPrioritiyQueueByEnemyType(type).Add(minPrioUnit);
                return;
            }

            minPrioUnit.SetPrioritization(minPrioUnit.GetPrioritization() + PriorityAddition);

            GetPrioritiyQueueByEnemyType(type).Add(minPrioUnit);
        }
Example #16
0
        public void Spawn(EEnemyType enemyType = EEnemyType.Green)
        {
            if (_enemyViews.Count >= _maxEnemyOnMap)
            {
                return;
            }
            var enemyСharacteristics = _enemyСharacteristics.GetСharacteristics(enemyType);
            var enemySpeed           = enemyСharacteristics.Speed;
            var enemyHp     = enemyСharacteristics.Health;
            var enemyDamage = enemyСharacteristics.Damage;
            var enemyArmour = enemyСharacteristics.Armour;
            var prefab      = _enemyPrefabDatabase.GetEnemy(enemyType);
            var spawnPoint  = spawnPoints[Random.Range(0, spawnPoints.Length)].position;
            var enemyView   = Instantiate(prefab, spawnPoint, Quaternion.identity);

            enemyView.Initialize(enemyHp, enemySpeed, enemyArmour, enemyDamage, _playerController.PlayerTransform);
            _enemyViews.Add(enemyView);
            enemyView.ListenDeath(() =>
            {
                _enemyViews.Remove(enemyView);
                Spawn();
            });
        }
 public SignalEnemySpawn(EEnemyType type, Vector3 position, Vector3 forward)
 {
     Type     = type;
     Forward  = forward;
     Position = position;
 }
Example #18
0
 // ***************************************************************************
 // Läd und erzeugt das eigentliche Spiel
 public SpawnPoint(MapLocation location, EEnemyType enemyType, float modifier)
 {
     Location = location;
     EnemyType = enemyType;
     this.modifier = modifier;
 }
Example #19
0
 public Enemy(ILocationBehavior locationBehavoir, float ratOfFire, float attackDistance,
     float sightiningDistance, float maxHealth, float speed, float health, EEnemyType typeOfEnemy)
     : this(locationBehavoir, new NoRenderer(), ratOfFire, attackDistance, sightiningDistance, maxHealth, speed, health, typeOfEnemy)
 {
 }
Example #20
0
        private IEnumerator CreateEnemy(EEnemyType type)
        {
            yield return(null);

            _enemyFactory.Create(type, Vector3.zero, Vector3.zero);
        }
Example #21
0
 void InitMedusa()
 {
     enemyType = EEnemyType.Medusa;
 }
Example #22
0
 void InitGhost()
 {
     enemyType = EEnemyType.Ghost;
 }
Example #23
0
        private IPriorityQueue <PrioritizableObject <EnemyUnit> > GetPrioritiyQueueByEnemyType(EEnemyType type)
        {
            switch (type)
            {
            case EEnemyType.Attack:
                return(mAttackingUnits);

            case EEnemyType.Defend:
                return(mDefendingUnits);

            case EEnemyType.Scout:
                return(mScoutingUnits);

            default:
                throw new Exception("Unexpected enemy type");
            }
        }
Example #24
0
 void InitMushroomy()
 {
     enemyType = EEnemyType.Mushroomy;
 }
Example #25
0
 void InitArcher()
 {
     enemyType = EEnemyType.Archer;
 }
Example #26
0
 public EnemyBuilder Type(EEnemyType enemyType)
 {
     this.EnemyType = enemyType;
     return(this);
 }