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); }
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(); } }
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>(); }
} //未設定(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); }
public bool Equals(EnemyId other) { return(Id.Equals(other.Id)); }
public GameObject CreateEnemy(EnemyId EnemyId) { var lookup = EnemyLookup.Where(l => l.Enemy.Id == EnemyId).Single(); return(CreateEnemy(lookup.Prefab)); }
public NetworkEnemy(Server server, string gameId, EnemyId enemyId) { GameId = gameId; this.server = server; EnemyId = enemyId; }