Пример #1
0
    public RoundEnemyEntry ToRoundEnemyEntry(int round)
    {
        if (round < spawnInRound)
        {
            return(null);
        }
        RoundEnemyEntry r = new RoundEnemyEntry();

        r.enemyPrefab = enemyPrefab;
        EnemyId id = enemyPrefab.GetComponent <EnemyId>();

        if (id == null)
        {
            Debug.LogError("Prefab '" + enemyPrefab.name + "' has no EnemyId.");
            return(null);
        }
        r.id = id.id;
        r.maxEnemiesOnMap     = startMaxEnemy + (round * increaseMaxMinEnemiesPerRound);
        r.minEnemiesOnMap     = startMinEnemy + (round * increaseMaxMinEnemiesPerRound);
        r.enemiesForThisRound = startEnemiesForThisRound + (round * increaseEnemyPerRound);
        r.spawnWaitTime       = spawnWaitTime;
        r.probabilityToSpawn  = probabilityToSpawn;

        return(r);
    }
Пример #2
0
    private void Update()
    {
        if (queue.Count == 0)
        {
            //Debug.Log(currentRound.roundEnemyEntries.Length) ;
            foreach (var e in currentRound.roundEnemyEntries)
            {
                //count enemies on the map
                int enemiesOnMap = 0;
                for (int i = 0; i < parentOfEnemies.childCount; i++)
                {
                    EnemyId id = parentOfEnemies.GetChild(i).GetComponent <EnemyId>();
                    if (id == null)
                    {
                        Debug.LogError("'" + parentOfEnemies.GetChild(i).name + "' has no EnemyId.");
                        continue;
                    }

                    if (id.id == e.id)
                    {
                        //Debug.Log("add enemy");
                        enemiesOnMap++;
                    }
                }

                if (enemiesOnMap <= e.minEnemiesOnMap)
                {
                    int diff = e.maxEnemiesOnMap - enemiesOnMap;
                    if ((enemiesOnMap + killedEnemies) + diff >= currentRound.enemiesForThisRound)
                    {
                        diff = e.enemiesForThisRound - (enemiesOnMap + killedEnemies);
                    }
                    for (int i = 0; i < diff; i++)
                    {
                        if (UnityEngine.Random.value <= e.probabilityToSpawn)
                        {
                            queue.Add(e);
                        }
                    }
                }
            }
        }


        roundText.text   = "Round " + (currentRoundIndex + 1);
        enemiesText.text = (killedEnemies) + " / " + currentRound.enemiesForThisRound + " Gegnern";
        if (killedEnemies >= currentRound.enemiesForThisRound)
        {
            NextRound();
        }
    }
Пример #3
0
    protected virtual void Awake()
    {
        // The id will identify the enemy in the scene.
        Id = new EnemyId(transform.position);

        // Awake gets called immediately when instantiating a Unity object in the scene.
        // We set the persistence here so that anything that instantiates this can change it in the same frame.
        IsPersistent = true;

        _animator       = new EnemyAnimator(GetComponent <Animator>());
        _attackZone     = GetComponentInChildren <AttackZone>();
        _rigidBody      = GetComponent <Rigidbody2D>();
        _physicalHitBox = GetComponent <Collider2D>();
    }
Пример #4
0
        }                                                                                                             //未設定(0)の時は使用しない

        public Enemy(Dungeon _dungeon, EnemyId id) : base(_dungeon)
        {
            _params = new EnemyParams();
            EnemyId = id;
            Master  = DataBase.EnemyMasters[id];

            //マスタからパラメータ取得
            Params.Name = Master.Name;
            HP          = Master.HP;
            MaxHP       = Master.HP;
            Speed       = Master.Speed;
            Params.Str  = Master.Str;
            Params.Vit  = Master.Vit;
            Params.Dex  = 0;
            Params.Agi  = 0;

            destination = new Form(-1, -1);
        }
Пример #5
0
 public bool Equals(EnemyId other)
 {
     return(Id.Equals(other.Id));
 }
Пример #6
0
    public GameObject CreateEnemy(EnemyId EnemyId)
    {
        var lookup = EnemyLookup.Where(l => l.Enemy.Id == EnemyId).Single();

        return(CreateEnemy(lookup.Prefab));
    }
Пример #7
0
 public NetworkEnemy(Server server, string gameId, EnemyId enemyId)
 {
     GameId = gameId;
     this.server = server;
     EnemyId = enemyId;
 }