// 제네레이터를 찾는다. protected chrBehaviorEnemy_Lair find_lair(string lair_name) { chrBehaviorEnemy_Lair lair = null; do { RoomController room_control = PartyControl.get().getCurrentRoom(); Room room = this.rooms[room_control.getIndex().x, room_control.getIndex().z]; var lairs = room.enemies.FindAll(x => ((x.behavior as chrBehaviorEnemy_Lair) != null)); if (lairs.Count == 0) { break; } var lair_control = lairs.Find(x => (x.name == lair_name)); if (lair_control == null) { break; } lair = lair_control.behavior as chrBehaviorEnemy_Lair; } while(false); return(lair); }
// 적이 삭제되기 직전에 (chrBehaviorEnemy.deleteSelf)호출. public void onDeleteEnemy(RoomController room, chrController enemy) { Room level_room = this.rooms[room.getIndex().x, room.getIndex().z]; chrBehaviorEnemy_Lair as_lair = enemy.behavior as chrBehaviorEnemy_Lair; if (as_lair != null) { level_room.lairs.Remove(as_lair); } level_room.enemies.Remove(enemy); }
void Update() { RoomController room_control = PartyControl.get().getCurrentRoom(); do { if (room_control == null) { break; } Room level_room = this.rooms[room_control.getIndex().x, room_control.getIndex().z]; if (GameRoot.get().isHost()) { // 로컬은 직접 만든다. //if(Input.GetMouseButtonDown(1)) { if (this.spawn_timer > 5.0f) { chrBehaviorEnemy_Lair lair = null; for (int i = 0; i < level_room.lairs.Count; i++) { level_room.spawner = (level_room.spawner + 1) % level_room.lairs.Count; lair = level_room.lairs[level_room.spawner]; if (lair != null) { break; } } if (lair != null) { dbwin.console().print("LairName:" + lair.name); lair.spawnEnemy(); } this.spawn_timer = 0.0f; } this.spawn_timer += Time.deltaTime; } else { // 리모트는 호스트의 지시로 만든다. foreach (var lair in level_room.lairs) { if (lair == null) { continue; } // 조정이 끝난 쿼리를 찾는다. List <QueryBase> queries = QueryManager.get().findDoneQuery(lair.name); List <QueryBase> spawn_queries = queries.FindAll(x => (x as QuerySpawn) != null); foreach (var query in spawn_queries) { QuerySpawn query_spawn = query as QuerySpawn; // 용무를 마쳤으므로 삭제한다. query_spawn.set_expired(true); if (!query_spawn.isSuccess()) { continue; } dbwin.console().print("LairName:" + lair.name); dbwin.console().print("EnemyName:" + query_spawn.monster_id); //Debug.Log("LairName:" + lair.name); //Debug.Log("EnemyName:" + query_spawn.monster_id); lair.spawnEnemyFromPedigree(query_spawn.monster_id); } } } } while(false); }
//룸 안에 초기 배치할 적을 만든다. public void createRoomEnemies(RoomController room) { #if true MapCreator map_creater = MapCreator.get(); Vector3 room_position = map_creater.getRoomCenterPosition(room.getIndex()); string room_index = room.getIndex().x.ToString("D1") + room.getIndex().z.ToString("D1"); string item_type, item_name; Room level_room = this.rooms[room.getIndex().x, room.getIndex().z]; level_room.items.Clear(); List <Map.BlockIndex> lair_places = map_creater.getLairPlacesRoom(room.getIndex()); // FieldGenerator가 설정한 랜덤한 위치에 제네레이터를 배치. int n = 0; foreach (var lair_place in lair_places) { string enemy_name = "Enemy_Lair" + "." + room_index + "." + n.ToString("D3"); chrBehaviorEnemy behavior = this.createRoomEnemy <chrBehaviorEnemy>(room, enemy_name); if (behavior == null) { continue; } chrController chr = behavior.control; chrBehaviorEnemy_Lair lair = chr.behavior as chrBehaviorEnemy_Lair; // 쓰러뜨렸을 때 나타날 아이템. object item_option0 = null; if (n == 0) { item_type = "ice00"; // 당첨, 탈락 추첨. item_option0 = this.item_lot.ice_atari.draw(this.rand.getRandom()); } else { item_type = "cake00"; } item_name = item_type + "_" + room_index + "_" + level_room.enter_count + "_" + n.ToString("D2"); lair.setRewardItem(item_type, item_name, item_option0); level_room.items.Add(item_name); // 스폰할 적. chrBehaviorEnemy_Lair.SpawnEnemy spawn; spawn = lair.resisterSpawnEnemy(); spawn.enemy_name = "Enemy_Obake"; spawn.behave_kind = Enemy.BEHAVE_KIND.UROURO; spawn.behave_desc = null; spawn.frequency = 1.0f; spawn = lair.resisterSpawnEnemy(); spawn.enemy_name = "Enemy_Kumasan"; spawn.behave_kind = Enemy.BEHAVE_KIND.TOTUGEKI; spawn.behave_desc = null; spawn.frequency = 0.5f; spawn = lair.resisterSpawnEnemy(); spawn.enemy_name = "Enemy_Obake"; spawn.behave_kind = Enemy.BEHAVE_KIND.WARP_DE_FIRE; spawn.behave_desc = null; spawn.frequency = 0.5f; spawn = lair.resisterSpawnEnemy(); spawn.enemy_name = "Enemy_Kumasan"; spawn.behave_kind = Enemy.BEHAVE_KIND.JUMBO; spawn.behave_desc = null; spawn.frequency = 0.5f; spawn = lair.resisterSpawnEnemy(); spawn.enemy_name = "Enemy_Obake"; spawn.behave_kind = Enemy.BEHAVE_KIND.GOROGORO; spawn.behave_desc = null; spawn.frequency = 0.5f; Vector3 position = map_creater.getBlockCenterPosition(lair_place); lair.control.cmdSetPositionAnon(room_position + position); lair.control.cmdSetDirectionAnon(135.0f); n++; } // 도어 앞에 파수꾼처럼 배치. for (int i = 0; i < (int)Map.EWSN.NUM; i++) { DoorControl door = room.getDoor((Map.EWSN)i); if (door == null) { continue; } string enemy_name = "Enemy_Kumasan" + "." + room_index + "." + i.ToString("D3"); chrBehaviorEnemy enemy = this.createRoomEnemy <chrBehaviorEnemy>(room, enemy_name); Map.RoomIndex ri; Map.BlockIndex bi; map_creater.getBlockIndexFromPosition(out ri, out bi, door.getPosition()); Vector3 position = door.getPosition(); float angle = 0.0f; Map.EWSN eswn = door.door_dir; for (int j = 0; j < 4; j++) { if (map_creater.isPracticable(ri, bi, eswn)) { break; } eswn = Map.eswn.next_cw(eswn); } float offset = 7.0f; switch (eswn) { case Map.EWSN.NORTH: { position += Vector3.forward * offset; angle = 180.0f; } break; case Map.EWSN.SOUTH: { position += Vector3.back * offset; angle = 0.0f; } break; case Map.EWSN.EAST: { position += Vector3.right * offset; angle = 90.0f; } break; case Map.EWSN.WEST: { position += Vector3.left * offset; angle = -90.0f; } break; } enemy.control.cmdSetPositionAnon(position); enemy.control.cmdSetDirectionAnon(angle); var desc = new Character.OufukuAction.Desc(); Vector3 line = Quaternion.AngleAxis(angle, Vector3.up) * Vector3.right; desc.position0 = position + line * 2.0f; desc.position1 = position - line * 2.0f; enemy.setBehaveKind(Enemy.BEHAVE_KIND.OUFUKU, desc); } // 그 자리에서 총을 쏘는 몬스터 / 무기 체인지 아이템. int item_place = this.rand.getRandomInt(level_room.places.Count); int shot_item_sel = this.rand.getRandomInt(10) % 2; for (int i = 0; i < level_room.places.Count; i++) { var place = level_room.places[i]; Vector3 position = room_position + map_creater.getBlockCenterPosition(place); if (i == item_place) { // 무기 체인지 아이템. if (shot_item_sel == 0) { item_type = "shot_negi"; } else { item_type = "shot_yuzu"; } item_name = item_type + "_" + room_index + "_" + level_room.enter_count + "_" + n.ToString("D2"); level_room.items.Add(item_name); ItemManager.get().createItem(item_type, item_name, PartyControl.get().getLocalPlayer().getAcountID()); ItemManager.get().setPositionToItem(item_name, position); } else { // 그 자리에서 총을 쏘는 몬스터. string enemy_name = "Enemy_Obake" + "." + room_index + "." + i.ToString("D3"); chrBehaviorEnemy enemy = this.createRoomEnemy <chrBehaviorEnemy>(room, enemy_name); if (enemy == null) { continue; } enemy.setBehaveKind(Enemy.BEHAVE_KIND.SONOBA_DE_FIRE); enemy.control.cmdSetPositionAnon(position); } } #else #if false chrController chr0 = this.createRoomEnemy <chrBehaviorEnemy>(room, "Enemy_Lair").control; //chrController chr1 = this.createRoomEnemy<chrBehaviorEnemy>(room, "Enemy_Lair").control; chrBehaviorEnemy_Lair lair0 = chr0.behavior as chrBehaviorEnemy_Lair; //chrBehaviorEnemy_Lair lair1 = chr1.behavior as chrBehaviorEnemy_Lair; lair0.name += "00"; //lair0.setRewardItem("cake00", "cake01"); //lair1.setRewardItem("ice00" , "ice01"); chrBehaviorEnemy_Lair.SpawnEnemy spawn; spawn = lair0.resisterSpawnEnemy(); spawn.enemy_name = "Enemy_Kumasan"; spawn.behave_kind = Enemy.BEHAVE_KIND.JUMBO; spawn.behave_desc = null; spawn.frequency = 1.0f; //spawn = lair0.resisterSpawnEnemy(); //spawn.enemy_name = "Enemy_Kumasan"; //spawn.behave_kind = Enemy.BEHAVE_KIND.TOTUGEKI; //spawn.behave_desc = null; //spawn.frequency = 0.5f; //lair0.spawn_enemy.enemy_name = "Enemy_Obake"; //lair0.spawn_enemy.behave_kind = Enemy.BEHAVE_KIND.UROURO; //lair1.spawn_enemy = "Enemy_Obake"; Vector3 player_position = room.gameObject.transform.position; lair0.control.cmdSetPositionAnon(player_position + Vector3.forward * 2.0f); //lair1.control.cmdSetPositionAnon(player_position + Vector3.forward*2.0f + Vector3.right*4.0f); lair0.control.cmdSetDirectionAnon(135.0f); //lair1.control.cmdSetDirectionAnon(135.0f); // if (room.getIndex().x == 2 && room.getIndex().z == 1) { player_position = MapCreator.get().getPlayerStartPosition(); lair0.control.cmdSetPositionAnon(player_position + Vector3.forward * 4.0f); //lair1.control.cmdSetPositionAnon(player_position + Vector3.forward*2.0f + Vector3.right*4.0f); } #else for (int i = 0; i < 2; i++) { chrBehaviorEnemy enemy = this.createRoomEnemy <chrBehaviorEnemy>(room, i == 0 ? "Enemy_Obake" : "Enemy_Kumasan"); //chrController obake = this.createRoomEnemy<chrBehaviorEnemy>(room, "Enemy_Lair").controll; // Vector3 player_position = room.gameObject.transform.position; enemy.control.cmdSetPositionAnon(player_position + Vector3.forward * 3.0f); enemy.control.cmdSetDirectionAnon(180.0f - 45.0f); if (room.getIndex().x == 2 && room.getIndex().z == 1) { player_position = MapCreator.get().getPlayerStartPosition(); enemy.control.cmdSetPositionAnon(player_position + Vector3.forward * 2.0f + Vector3.right * 2.0f * (float)i); } if (i == 0) { //var desc = new Character.OufukuAction.Desc(); //Vector3 line = Quaternion.AngleAxis(180.0f, Vector3.up)*Vector3.back; //desc.position0 = player_position + line*2.0f; //desc.position1 = player_position - line*2.0f; enemy.setBehaveKind(Enemy.BEHAVE_KIND.GOROGORO); break; } else { enemy.setBehaveKind(Enemy.BEHAVE_KIND.TOTUGEKI); } } #endif #endif }
public override void execute() { BasicAction basic_action = this.behavior.basic_action; // ---------------------------------------------------------------- // // 다음 상태로 이행할지 체크한다. switch (this.step.do_transition()) { // 대기 중. case STEP.READY: { /*do { * * if(!LevelControl.get().canCreateCurrentRoomEnemy()) { * * break; * } * * if(!Input.GetMouseButtonDown(1)) { * //if(!this.step.is_acrossing_cycle(5.0f)) { * * break; * } * * this.step.set_next(STEP.SPAWN); * * } while(false);*/ } break; // 적 스폰. case STEP.SPAWN: { // 스폰 애니메이션이 끝나면 대기 상태로 돌아간다. do { // 애니메이션 전환 중이면 돌아가지 않는다. // (이걸 넣어두지 않으면 "idle" -> "generate"의. // 전환 중에 다음 if문이 true가 되어 버린다). if (basic_action.animator.IsInTransition(0)) { break; } if (basic_action.animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Generate")) { break; } this.step.set_next(STEP.READY); } while(false); } break; // 찌그러진다. case STEP.PECHANCO: { if (this.is_death_motion_finished) { this.step.set_next_delay(STEP.IDLE, 0.5f); } } break; } // ---------------------------------------------------------------- // // 상태 전환 시 초기화. while (this.step.get_next() != STEP.NONE) { switch (this.step.do_initialize()) { case STEP.IDLE: { // 부모 계층의 액션으로 복귀. if (this.parent != null) { this.parent.resume(); } } break; // 대기 중. case STEP.READY: { } break; // 적 스폰. case STEP.SPAWN: { this.is_trigger_pe = false; basic_action.animator.SetTrigger("Generate"); } break; // 찌그러진다. case STEP.PECHANCO: { basic_action.animator.SetTrigger("Death"); this.is_death_motion_finished = false; this.control.cmdEnableCollision(false); } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch (this.step.do_execution(Time.deltaTime)) { // 적 스폰. case STEP.SPAWN: { // 모션 타이밍에 맞춰 적을 토해낸다. if (this.is_trigger_pe) { chrBehaviorEnemy_Lair behave_lair = this.behavior as chrBehaviorEnemy_Lair; if (this.pedigree != "") { behave_lair.create_enemy_internal_pedigree(this.pedigree); this.pedigree = ""; } else { behave_lair.create_enemy_internal(); } this.is_trigger_pe = false; } } break; } // ---------------------------------------------------------------- // }
public override void execute() { BasicAction basic_action = this.behavior.basic_action; // ---------------------------------------------------------------- // // ?ㅼ쓬 ?곹깭濡??댄뻾?좎? 泥댄겕?쒕떎. switch (this.step.do_transition()) { // ?湲?以? case STEP.READY: { /*do { * * if(!LevelControl.get().canCreateCurrentRoomEnemy()) { * * break; * } * * if(!Input.GetMouseButtonDown(1)) { * //if(!this.step.is_acrossing_cycle(5.0f)) { * * break; * } * * this.step.set_next(STEP.SPAWN); * * } while(false);*/ } break; // ???ㅽ룿. case STEP.SPAWN: { // ?ㅽ룿 ?좊땲硫붿씠?섏씠 ?앸굹硫??湲??곹깭濡??뚯븘媛꾨떎. do { // ?좊땲硫붿씠???꾪솚 以묒씠硫??뚯븘媛吏 ?딅뒗?? // (?닿구 ?l뼱?먯? ?딆쑝硫?"idle" -> "generate"?? // ?꾪솚 以묒뿉 ?ㅼ쓬 if臾몄씠 true媛 ?섏뼱 踰꾨┛??. if (basic_action.animator.IsInTransition(0)) { break; } if (basic_action.animator.GetCurrentAnimatorStateInfo(0).IsName("Base Layer.Generate")) { break; } this.step.set_next(STEP.READY); } while(false); } break; // 李뚭렇?ъ쭊?? case STEP.PECHANCO: { if (this.is_death_motion_finished) { this.step.set_next_delay(STEP.IDLE, 0.5f); } } break; } // ---------------------------------------------------------------- // // ?곹깭 ?꾪솚 ??珥덇린?? while (this.step.get_next() != STEP.NONE) { switch (this.step.do_initialize()) { case STEP.IDLE: { // 遺紐?怨꾩링???≪뀡?쇰줈 蹂듦?. if (this.parent != null) { this.parent.resume(); } } break; // ?湲?以? case STEP.READY: { } break; // ???ㅽ룿. case STEP.SPAWN: { this.is_trigger_pe = false; basic_action.animator.SetTrigger("Generate"); } break; // 李뚭렇?ъ쭊?? case STEP.PECHANCO: { basic_action.animator.SetTrigger("Death"); this.is_death_motion_finished = false; this.control.cmdEnableCollision(false); } break; } } // ---------------------------------------------------------------- // // 媛??곹깭?먯꽌???ㅽ뻾 泥섎━. switch (this.step.do_execution(Time.deltaTime)) { // ???ㅽ룿. case STEP.SPAWN: { // 紐⑥뀡 ??대컢??留욎떠 ?곸쓣 ?좏빐?몃떎. if (this.is_trigger_pe) { chrBehaviorEnemy_Lair behave_lair = this.behavior as chrBehaviorEnemy_Lair; if (this.pedigree != "") { behave_lair.create_enemy_internal_pedigree(this.pedigree); this.pedigree = ""; } else { behave_lair.create_enemy_internal(); } this.is_trigger_pe = false; } } break; } // ---------------------------------------------------------------- // }