protected virtual void exec_step_vanish() { if (this.damage_effect.isVacant()) { if (room != null) { } (this.behavior as chrBehaviorEnemy).onDelete(); EnemyRoot.getInstance().deleteEnemy(this); } }
protected void decideNextStep() { if (m_isHost) { // 가까이에 있는(퀵 공격 할 수 있는) 플레이어를 찾는다. chrBehaviorPlayer target = this.find_close_player(); if (target != null) { this.next_step = STEP.ACTION; EnemyRoot.getInstance().RequestBossQuickAttack(target.getAcountID(), 1.0f); } else { // FIXME: 통신에 대응시킬 것. float randomValue = Random.value * 4; if (randomValue < 1.0f) { Debug.Log("DirectAttack"); this.next_step = STEP.ACTION; EnemyRoot.getInstance().RequestBossDirectAttack(focus.getAcountID(), 1.0f); } else if (randomValue < 2.0f) { Debug.Log("RangeAttack"); this.next_step = STEP.ACTION; EnemyRoot.getInstance().RequestBossRangeAttack(1.0f, 5.0f); } else { this.next_step = STEP.MOVE; } } } else { this.next_step = STEP.MOVE; } // ---------------------------------------------------------------- // // 캐릭터 좌표를 보낸다. sendCharacterCoordinates(); }
// ================================================================ // // このコントローラ(敵種)に固有のメソッド /** * spawn_class_nameプロパティで指定された敵を生成する * @return 生成に成功した場合は true 、生成を見送った場合は false を戻す */ public bool createEnemy() { if (!activated) { return(false); } // 放出する方向が空いているかどうかを調べる Vector3[] spawnDirections = new Vector3[] { Vector3.back, Vector3.left, Vector3.forward, Vector3.right }; Vector3 spawnFrom; spawnFrom = this.transform.position; spawnFrom.y = SPAWN_COLLIDE_CHECK_POS_Y; foreach (Vector3 dir in spawnDirections) { if (!Physics.SphereCast(new Ray(spawnFrom, dir), SPAWN_COLLIDE_CHECK_RADIUS, SPAWN_DISTANCE, 1 << LayerMask.NameToLayer("Enemy"))) { playGenerate(); // 敵を生成する //FIXME: The following 3 parameters should be a property. chrControllerEnemyBase enemy = EnemyRoot.getInstance().createEnemy("Enemy_Obake", "chrControllerEnemyGhost", "chrBehaviorEnemyGhost") as chrControllerEnemyBase; if (room != null) { room.RegisterEnemy(enemy); } enemy.transform.position = spawnFrom + dir * SPAWN_DISTANCE; enemy.transform.rotation = Quaternion.LookRotation(dir); return(true); } } return(false); }
// 룸 안의 적을 전부 삭제. public void deleteRoomEnemies(RoomController room) { Room level_room = this.rooms[room.getIndex().x, room.getIndex().z]; var enemies = this.rooms[room.getIndex().x, room.getIndex().z].enemies; foreach (var enemy in enemies) { if (enemy == null) { continue; } EnemyRoot.getInstance().deleteEnemy(enemy); } level_room.enemies.Clear(); level_room.lairs.Clear(); level_room.enemy_index = 0; level_room.spawner = 0; this.spawn_timer = 0.0f; }
public override void execute() { base.execute(); // 스페이스바나 J키로 점프 공격 if (Input.GetKey(KeyCode.Space) || Input.GetKey(KeyCode.J)) { EnemyRoot.getInstance().RequestBossRangeAttack(1.0f, 5.0f); } // C키로 공격 if (Input.GetKey(KeyCode.C)) { // 돌격 EnemyRoot.getInstance().RequestBossDirectAttack(focus.getAcountID(), 3.0f); } // Q키로 퀵 공격 if (Input.GetKey(KeyCode.Q)) { // 퀵 공격 EnemyRoot.getInstance().RequestBossQuickAttack(focus.getAcountID(), 1.0f); } }
// 자신을 삭제한다. public void deleteSelf() { this.onDelete(); EnemyRoot.getInstance().deleteEnemy(this.control); }
// 디버그 창을 만든다(여러 가지). protected void create_debug_window() { var window = dbwin.root().createWindow("game"); window.createCheckBox("어카운트1", GlobalParam.get().db_is_connected[0]) .setOnChanged((bool is_checked) => { GlobalParam.get().db_is_connected[0] = is_checked; }); window.createCheckBox("어카운트 2", GlobalParam.get().db_is_connected[1]) .setOnChanged((bool is_checked) => { GlobalParam.get().db_is_connected[1] = is_checked; }); window.createCheckBox("어카운트3", GlobalParam.get().db_is_connected[2]) .setOnChanged((bool is_checked) => { GlobalParam.get().db_is_connected[2] = is_checked; }); window.createCheckBox("어카운트 4", GlobalParam.get().db_is_connected[3]) .setOnChanged((bool is_checked) => { GlobalParam.get().db_is_connected[3] = is_checked; }); window.createCheckBox("BGM", this.debug_flag.play_bgm) .setOnChanged((bool is_checked) => { this.debug_flag.play_bgm = is_checked; if (this.debug_flag.play_bgm) { SoundManager.get().playBGM(Sound.ID.TKJ_BGM01); } else { SoundManager.get().stopBGM(); } }); /*window.createButton("물렸다") * .setOnPress(() => * { * dbwin.console().print("hoge"); * //this.next_step = STEP.TO_TITLE; * });*/ #if false window.createButton("적 만들기") .setOnPress(() => { dbwin.console().print("fuga"); /*GameObject go = GameObject.FindGameObjectWithTag("EnemyLair"); * * if(go != null) { * * chrBehaviorEnemyLair0 lair = go.GetComponent<chrBehaviorEnemyLair0>(); * * lair.createEnemy(); * }*/ }); window.createButton("적을 잔뜩 만들다") .setOnPress(() => { EnemyRoot.getInstance().createManyEnemies(); }); window.createButton("메가 크래시") .setOnPress(() => { EnemyRoot.getInstance().debugCauseDamageToAllEnemy(); }); #endif window.createButton("메가메가 크래시") .setOnPress(() => { EnemyRoot.getInstance().debugCauseVanishToAllEnemy(); }); window.createButton("제네레이터를 찾는다") .setOnPress(() => { var enemies = EnemyRoot.get().getEnemies(); var lairs = enemies.FindAll(x => (x.behavior as chrBehaviorEnemy_Lair) != null); foreach (var lair in lairs) { Debug.Log(lair.name); } }); #if false window.createButton("모두에게 대미지") .setOnPress(() => { var players = PartyControl.getInstance().getPlayers(); foreach (var player in players) { player.controll.vital.causeDamage(10.0f); } }); window.createButton("때린다") .setOnPress(() => { var player = PartyControl.getInstance().getLocalPlayer(); player.controll.cmdSetMotion("m003_attack", 1); var enemies = EnemyRoot.getInstance().getEnemies(); foreach (var enemy in enemies) { enemy.cmdSetMotion("m003_attack", 1); } }); window.createButton("마법") .setOnPress(() => { var player = PartyControl.getInstance().getLocalPlayer(); player.controll.cmdSetMotion("m004_use", 1); }); window.createButton("아팟") .setOnPress(() => { var player = PartyControl.getInstance().getLocalPlayer(); player.controll.causeDamage(0.0f); var enemies = EnemyRoot.getInstance().getEnemies(); foreach (var enemy in enemies) { enemy.cmdSetMotion("m005_damage", 1); } }); #endif window.createButton("일시정지 설정") .setOnPress(() => { this.setEnemyPause(true); }); window.createButton("일시정지 해제") .setOnPress(() => { this.setEnemyPause(false); }); this.sequence.createDebugWindow(window); }
public override void execute() { // ---------------------------------------------------------------- // // ステップ内の経過時間を進める. this.step_timer += Time.deltaTime; // ---------------------------------------------------------------- // if (this.trigger_damage) { this.control.damage_effect.startDamage(); this.life -= 1.0f; if (this.life <= 0.0f) { this.next_step = STEP.VANISH; } } // ---------------------------------------------------------------- // // 次の状態に移るかどうかを、チェックする. if (this.next_step == STEP.NONE) { switch (this.step) { case STEP.MOVE: { if (this.step_timer > 1.0f) { this.next_step = STEP.REST; } } break; case STEP.REST: { if (this.step_timer >= REST_TIME) { this.next_step = STEP.MOVE; } } break; case STEP.VANISH: { if (this.control.damage_effect.isVacant()) { EnemyRoot.getInstance().deleteEnemy(this.control); } } break; } } // ---------------------------------------------------------------- // // 状態が遷移したときの初期化. while (this.next_step != STEP.NONE) { this.step = this.next_step; this.next_step = STEP.NONE; switch (this.step) { case STEP.MOVE: { float turn; // FIXME controll からマトリクス(transform)を取得する関数かなんか作らないといけなさそう Vector3 focal_local_pos = this.control.transform.InverseTransformPoint(focus.transform.position); focal_local_pos.y = 0.0f; // 高さはみない //float turn = Random.Range(-90.0f, 90.0f); if (Vector3.Dot(Vector3.right, focal_local_pos) > 0) { turn = Vector3.Angle(focal_local_pos, Vector3.forward); } else { turn = -Vector3.Angle(focal_local_pos, Vector3.forward); } turn = Mathf.Clamp(turn, -90, 90); // move_dir に回転の角度を入れる this.move_dir = this.control.getDirection() + turn; } break; case STEP.VANISH: { this.control.cmdBeginVanish(); } break; } this.step_timer = 0.0f; } // ---------------------------------------------------------------- // // 各状態での実行処理. switch (this.step) { case STEP.MOVE: { this.exec_step_move(); } break; case STEP.VANISH: { } break; } // ---------------------------------------------------------------- // this.trigger_damage = false; }
public override void execute() { // ---------------------------------------------------------------- // // ステップ内の経過時間を進める. this.step_timer_prev = this.step_timer; this.step_timer += Time.deltaTime; // ---------------------------------------------------------------- // if (this.damage_trigger) { this.control.damage_effect.startDamage(); this.life -= 1.0f; if (this.life <= 0.0f) { this.next_step = STEP.VANISH; } } // ---------------------------------------------------------------- // // 次の状態に移るかどうかを、チェックする. if (this.next_step == STEP.NONE) { switch (this.step) { case STEP.MOVE: { } break; case STEP.REST: { if (this.step_timer > 1.0f) { this.next_step = STEP.MOVE; } } break; case STEP.VANISH: { if (this.control.damage_effect.isDone()) { EnemyRoot.getInstance().deleteEnemy(this.control); } } break; } } // ---------------------------------------------------------------- // // 状態が遷移したときの初期化. while (this.next_step != STEP.NONE) { this.step = this.next_step; this.next_step = STEP.NONE; switch (this.step) { case STEP.MOVE: { float turn = Random.Range(-90.0f, 90.0f); this.move_dir = this.control.getDirection() + turn; } break; case STEP.VANISH: { this.control.damage_effect.startVanish(); } break; } this.step_timer_prev = 0.0f; this.step_timer = 0.0f; } // ---------------------------------------------------------------- // // 各状態での実行処理. switch (this.step) { case STEP.MOVE: { if (this.step_timer > 0.0f) { if (Mathf.FloorToInt(this.step_timer_prev / 5.0f) != Mathf.FloorToInt(this.step_timer / 5.0f)) { this.createEnemy(); } } } break; } // ---------------------------------------------------------------- // this.damage_trigger = false; }
public void createEnemy() { chrController enemy = EnemyRoot.getInstance().createEnemy(); enemy.transform.position = this.transform.position; }
public override void execute() { // ---------------------------------------------------------------- // // ステップ内の経過時間を進める. this.step_timer += Time.deltaTime; // ---------------------------------------------------------------- // if (this.control.trigger_damage) { this.control.damage_effect.startDamage(); if (this.control.vital.hit_point <= 0.0f) { this.next_step = STEP.VANISH; } } // ---------------------------------------------------------------- // // 次の状態に移るかどうかを、チェックする. if (this.next_step == STEP.NONE) { switch (this.step) { case STEP.MOVE: { if (this.step_timer > 1.0f) { this.next_step = STEP.REST; } } break; case STEP.REST: { if (this.step_timer > 1.0f) { this.next_step = STEP.MOVE; } } break; case STEP.VANISH: { if (this.control.damage_effect.isDone()) { EnemyRoot.getInstance().deleteEnemy(this.control); } } break; } } // ---------------------------------------------------------------- // // 状態が遷移したときの初期化. while (this.next_step != STEP.NONE) { this.step = this.next_step; this.next_step = STEP.NONE; switch (this.step) { case STEP.MOVE: { float turn = Random.Range(-90.0f, 90.0f); this.move_dir = this.control.getDirection() + turn; this.control.cmdSetMotion("m001_walk", 0); } break; case STEP.REST: { float turn = Random.Range(-90.0f, 90.0f); this.move_dir = this.control.getDirection() + turn; this.control.cmdSetMotion("m002_idle", 0); } break; case STEP.VANISH: { this.control.cmdBeginVanish(); } break; } this.step_timer = 0.0f; } // ---------------------------------------------------------------- // // 各状態での実行処理. switch (this.step) { case STEP.MOVE: { this.exec_step_move(); } break; case STEP.VANISH: { } break; } // ---------------------------------------------------------------- // }
public override void execute() { // ---------------------------------------------------------------- // // ステップ内の経過時間を進める. this.step_timer += Time.deltaTime; // ---------------------------------------------------------------- // if (this.trigger_damage) { this.control.damage_effect.startDamage(); this.life -= 1.0f; if (this.life <= 0.0f) { this.next_step = STEP.VANISH; } } // ---------------------------------------------------------------- // // 次の状態に移るかどうかを、チェックする. if (this.next_step == STEP.NONE) { switch (this.step) { case STEP.MOVE: { if (this.step_timer > 1.0f) { this.next_step = STEP.REST; } } break; case STEP.REST: { if (this.step_timer > 3.0f) { this.next_step = STEP.MOVE; } } break; case STEP.VANISH: { if (this.control.damage_effect.isDone()) { EnemyRoot.getInstance().deleteEnemy(this.control); } } break; } } // ---------------------------------------------------------------- // // 状態が遷移したときの初期化. while (this.next_step != STEP.NONE) { this.step = this.next_step; this.next_step = STEP.NONE; switch (this.step) { case STEP.MOVE: { } break; case STEP.VANISH: { // アニメーションとめる. Animation[] animations = this.gameObject.GetComponentsInChildren <Animation>(); foreach (var animation in animations) { animation.Stop(); } this.control.damage_effect.startVanish(); } break; } this.step_timer = 0.0f; } // ---------------------------------------------------------------- // // 各状態での実行処理. switch (this.step) { case STEP.MOVE: { chrController player = CharacterRoot.getInstance().getPlayer(); if (player != null) { var dir = Quaternion.LookRotation(player.transform.position - this.transform.position); this.move_dir = dir.eulerAngles.y; } else { float turn = Random.Range(-90.0f, 90.0f); this.move_dir = this.control.getDirection() + turn; } this.exec_step_move(); } break; case STEP.VANISH: { } break; } // ---------------------------------------------------------------- // this.trigger_damage = false; }