public override void execute() { BasicAction basic_action = this.behavior.basic_action; if (this.finish_child()) { this.step.set_next(STEP.MOVE); } // ---------------------------------------------------------------- // // 다음 상태로 전환할지 체크합니다. switch (this.step.do_transition()) { // 걷는 중. case STEP.MOVE: { chrBehaviorLocal player = PartyControl.get().getLocalPlayer(); if (this.behavior.isInAttackRange(player.control)) { this.push(this.melee_attack); this.step.sleep(); } } break; } // ---------------------------------------------------------------- // // 상태가 전환됐을 때의 초기화. while (this.step.get_next() != STEP.NONE) { switch (this.step.do_initialize()) { // 걷는 중. case STEP.MOVE: { this.next_position = 0; Vector3 move_vector = this.positions[this.next_position] - this.control.getPosition(); basic_action.move_dir = Mathf.Atan2(move_vector.x, move_vector.z) * Mathf.Rad2Deg; } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch (this.step.do_execution(Time.deltaTime)) { // 걷는 중. case STEP.MOVE: { Vector3 tgt_vector0 = this.positions[0] - this.control.getPosition(); Vector3 tgt_vector1 = this.positions[1] - this.control.getPosition(); Vector3 move_vector = this.control.getMoveVector(); float dp0 = Vector3.Dot(tgt_vector0, move_vector); float dp1 = Vector3.Dot(tgt_vector1, move_vector); if (dp0 > 0.0f && dp1 > 0.0f) { if (tgt_vector0.sqrMagnitude < tgt_vector1.sqrMagnitude) { this.next_position = 0; } else { this.next_position = 1; } } else if (dp0 < 0.0f && dp1 < 0.0f) { if (tgt_vector0.sqrMagnitude > tgt_vector1.sqrMagnitude) { this.next_position = 0; } else { this.next_position = 1; } } Vector3 tgt_vector = this.positions[this.next_position] - this.control.getPosition(); basic_action.move_dir = Mathf.Atan2(tgt_vector.x, tgt_vector.z) * Mathf.Rad2Deg; basic_action.executeMove(); basic_action.setMoveMotionSpeed(1.0f); } break; } // ---------------------------------------------------------------- // this.execute_child(); }
public override void execute() { BasicAction basic_action = this.behavior.basic_action; if (this.finish_child()) { this.step.set_next(STEP.MOVE); } // ---------------------------------------------------------------- // // 다음 상태로 전환할지 체크합니다. switch (this.step.do_transition()) { // 걷는 중. case STEP.MOVE: { } break; // 멈춤. case STEP.REST: { if (this.step.get_time() > 1.0f) { this.step.set_next(STEP.MOVE); } chrBehaviorLocal player = PartyControl.get().getLocalPlayer(); if (this.behavior.isInAttackRange(player.control)) { this.push(this.melee_attack); this.step.sleep(); } } break; } // ---------------------------------------------------------------- // // 상태가 전환됐을 때의 초기화. while (this.step.get_next() != STEP.NONE) { switch (this.step.do_initialize()) { // 걷는 중. case STEP.MOVE: { } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch (this.step.do_execution(Time.deltaTime)) { // 걷는 중. case STEP.MOVE: { var coli = basic_action.control.collision_results.Find(x => x.object1.tag == "Wall" || x.object1.tag == "Player"); // 벽(또는 플레이어)에 부딪히면 반사해서 방향을 바꿉니다. do { if (coli == null) { break; } if (coli.option0 == null) { break; } ContactPoint cp = (ContactPoint)coli.option0; // 벽의 법선 방향을 90도 단위로 합니다. Vector3 normal = cp.normal; float normal_angle = Mathf.Atan2(normal.x, normal.z) * Mathf.Rad2Deg; normal_angle = MathUtility.unormDegree(normal_angle); normal_angle = Mathf.Round(normal_angle / 90.0f) * 90.0f; normal = Quaternion.AngleAxis(normal_angle, Vector3.up) * Vector3.forward; Vector3 v = basic_action.getMoveVector(); if (Vector3.Dot(v, normal) >= 0.0f) { break; } v -= 2.0f * Vector3.Dot(v, normal) * normal; basic_action.setMoveDirByVector(v); // 플레이어에게 부딪혔으면 대미지를 줍니다. do { if (coli.object1.tag != "Player") { break; } chrController chr = coli.object1.GetComponent <chrController>(); if (chr == null) { break; } if (!(chr.behavior is chrBehaviorLocal)) { break; } chr.causeDamage(this.control.vital.getAttackPower(), -1); } while(false); } while(false); basic_action.setMoveSpeed(4.0f); basic_action.setMoveMotionSpeed(0.0f); basic_action.executeMove(); // this.model.transform.Rotate(new Vector3(7.0f, 0.0f, 0.0f)); } break; // 멈춤. case STEP.REST: { basic_action.setMoveMotionSpeed(0.0f); } break; } // ---------------------------------------------------------------- // this.execute_child(); }
public override void execute() { chrBehaviorEnemy mine = this.behavior; BasicAction basic_action = mine.basic_action; if (this.finish_child()) { this.step.set_next(STEP.MOVE); } chrBehaviorPlayer target_player = this.behavior.selectTargetPlayer(float.MaxValue, float.MaxValue); this.melee_attack.target_player = target_player; // ---------------------------------------------------------------- // // 다음 상태로 이동하는지 체크합니다. switch (this.step.do_transition()) { // 걷는 중. case STEP.MOVE: { do { if (target_player == null) { break; } if (!this.behavior.isInAttackRange(target_player.control)) { break; } // this.push(this.melee_attack); this.step.sleep(); } while(false); } break; // 멈춰 있다. case STEP.REST: { if (this.step.get_time() > 1.0f) { this.step.set_next(STEP.MOVE); } do { if (target_player == null) { break; } if (!this.behavior.isInAttackRange(target_player.control)) { break; } // this.push(this.melee_attack); this.step.sleep(); } while(false); } break; } // ---------------------------------------------------------------- // // 상태가 전환됐을 때의 초기화. while (this.step.get_next() != STEP.NONE) { switch (this.step.do_initialize()) { // 걷는 중. case STEP.MOVE: { } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch (this.step.do_execution(Time.deltaTime)) { // 걷는 중. case STEP.MOVE: { do { if (target_player == null) { break; } basic_action.move_dir = MathUtility.calcDirection(mine.control.getPosition(), target_player.control.getPosition()); basic_action.setMoveMotionSpeed(1.0f); basic_action.setMoveSpeed(0.6f); basic_action.setMotionPlaySpeed(0.6f); basic_action.executeMove(); } while(false); } break; // 멈춰있다. case STEP.REST: { basic_action.setMoveMotionSpeed(0.0f); } break; } this.spring.execute(Time.deltaTime); if (this.spring.isMoving()) { this.scale = Mathf.InverseLerp(-1.0f, 1.0f, this.spring.position); this.scale = Mathf.Lerp(1.0f, 2.0f, this.scale); } this.control.transform.localScale = Vector3.one * this.scale; // ---------------------------------------------------------------- // this.execute_child(); if (this.child == this.melee_attack) { this.attack_motion_speed_control(); } }
public override void execute() { chrBehaviorEnemy mine = this.behavior; BasicAction basic_action = mine.basic_action; if (this.finish_child()) { this.step.set_next(STEP.MOVE); } chrBehaviorPlayer target_player = this.behavior.selectTargetPlayer(float.MaxValue, float.MaxValue); this.melee_attack.target_player = target_player; // ---------------------------------------------------------------- // // 다음 상태로 전환할지 체크합니다. switch (this.step.do_transition()) { // 걷는 중. case STEP.MOVE: { do { if (target_player == null) { break; } if (!this.behavior.isInAttackRange(target_player.control)) { break; } // this.push(this.melee_attack); this.step.sleep(); } while(false); } break; // 멈춤. case STEP.REST: { if (this.step.get_time() > 1.0f) { this.step.set_next(STEP.MOVE); } do { if (target_player == null) { break; } if (!this.behavior.isInAttackRange(target_player.control)) { break; } // this.push(this.melee_attack); this.step.sleep(); } while(false); } break; } // ---------------------------------------------------------------- // // 상태가 전한됐을 때의 초기화. while (this.step.get_next() != STEP.NONE) { switch (this.step.do_initialize()) { // 걷는 중. case STEP.MOVE: { } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch (this.step.do_execution(Time.deltaTime)) { // 걷는 중. case STEP.MOVE: { do { if (target_player == null) { break; } basic_action.move_dir = MathUtility.calcDirection(mine.control.getPosition(), target_player.control.getPosition()); basic_action.executeMove(); basic_action.setMoveMotionSpeed(1.0f); } while(false); } break; // 멈춤. case STEP.REST: { basic_action.setMoveMotionSpeed(0.0f); } break; } // ---------------------------------------------------------------- // this.execute_child(); }
public override void execute() { BasicAction basic_action = this.behavior.basic_action; if (this.finish_child()) { this.step.set_next(STEP.MOVE); } // ---------------------------------------------------------------- // // 다음 상태로 이동할지 체크합니다. switch (this.step.do_transition()) { // 걷는 중. case STEP.MOVE: { if (this.step.get_time() > 1.0f) { this.step.set_next(STEP.REST); } chrBehaviorLocal player = PartyControl.get().getLocalPlayer(); if (this.behavior.isInAttackRange(player.control)) { this.push(this.melee_attack); this.step.sleep(); } } break; // 멈춤. case STEP.REST: { if (this.step.get_time() > 1.0f) { this.step.set_next(STEP.MOVE); } chrBehaviorLocal player = PartyControl.get().getLocalPlayer(); if (this.behavior.isInAttackRange(player.control)) { this.push(this.melee_attack); this.step.sleep(); } } break; } // ---------------------------------------------------------------- // // 상태가 전환됐을 때의 초기화. while (this.step.get_next() != STEP.NONE) { switch (this.step.do_initialize()) { // 걷기 중. case STEP.MOVE: { basic_action.move_dir += Random.Range(-90.0f, 90.0f); if (basic_action.move_dir > 180.0f) { basic_action.move_dir -= 360.0f; } else if (basic_action.move_dir < -180.0f) { basic_action.move_dir += 360.0f; } } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch (this.step.do_execution(Time.deltaTime)) { // 걷기 중. case STEP.MOVE: { basic_action.executeMove(); basic_action.setMoveMotionSpeed(1.0f); } break; // 멈춤. case STEP.REST: { basic_action.setMoveMotionSpeed(0.0f); } break; } // ---------------------------------------------------------------- // this.execute_child(); }
public override void execute() { BasicAction basic_action = this.behavior.basic_action; if(this.target_player == null) { this.target_player = PartyControl.get().getLocalPlayer(); } // ---------------------------------------------------------------- // // 다음 상태로 이동할지 체크합니다. switch(this.step.do_transition()) { // 공격 중. case STEP.ATTACK: { if(this.behavior.is_attack_motion_finished) { this.step.set_next_delay(STEP.FINISH, 1.0f); } } break; } // ---------------------------------------------------------------- // // 상태가 바뀌었을 때의 초기화. while(this.step.get_next() != STEP.NONE) { switch(this.step.do_initialize()) { // 공격 중. case STEP.ATTACK: { basic_action.setMoveMotionSpeed(0.0f); basic_action.animator.SetTrigger("Attack"); } break; // 끝. case STEP.FINISH: { this.is_finished = true; } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch(this.step.do_execution(Time.deltaTime)) { // 공격 중. case STEP.ATTACK: { if(this.behavior.is_attack_motion_impact) { if(this.behavior.isInAttackRange(this.target_player.control)) { if(this.target_player.isLocal()) { this.target_player.control.causeDamage(this.behavior.control.vital.getAttackPower(), -1); } else { // 원격 플레이어에게는 대미지를 주지 않는다. } } } basic_action.move_dir = MathUtility.calcDirection(this.behavior.control.getPosition(), this.target_player.control.getPosition()); } break; } // ---------------------------------------------------------------- // }
public override void execute() { BasicAction basic_action = this.behavior.basic_action; chrBehaviorEnemy_Obake obake = this.behavior as chrBehaviorEnemy_Obake; // ---------------------------------------------------------------- // // 다음 상태로 이동할지 체크합니다. switch(this.step.do_transition()) { // 발사. case STEP.SHOOT: { if(this.behavior.is_attack_motion_finished) { this.step.set_next_delay(STEP.FINISH, 1.0f); } } break; } // ---------------------------------------------------------------- // // 상태가 바뀌었을 때의 초기화. while(this.step.get_next() != STEP.NONE) { switch(this.step.do_initialize()) { // 발사. case STEP.SHOOT: { basic_action.setMoveMotionSpeed(0.0f); basic_action.animator.SetTrigger("Attack"); } break; // 끝. case STEP.FINISH: { this.is_finished = true; } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch(this.step.do_execution(Time.deltaTime)) { // 발사. case STEP.SHOOT: { if(this.behavior.is_attack_motion_impact) { obake.shootBullet(); } } break; } // ---------------------------------------------------------------- // }