#include "MyShip.h"

#include "jp/ggaf/core/actor/ex/GgafActorDepository.h"
#include "jp/ggaf/dxcore/actor/supporter/GgafDxChecker.h"
#include "jp/ggaf/dxcore/actor/supporter/GgafDxKuroko.h"
#include "jp/ggaf/dxcore/actor/supporter/GgafDxAxesMover.h"
#include "jp/ggaf/dxcore/actor/supporter/GgafDxScaler.h"
#include "jp/ggaf/dxcore/actor/supporter/GgafDxSeTransmitterForActor.h"
#include "jp/ggaf/dxcore/model/GgafDxModel.h"
#include "jp/ggaf/dxcore/util/GgafDxCollisionArea.h"
#include "jp/ggaf/dxcore/util/GgafDxCollisionPart.h"
#include "jp/ggaf/lib/actor/laserchip/LaserChipDepository.h"
#include "jp/ggaf/lib/util/CollisionChecker.h"
#include "jp/gecchi/VioletVreath/actor/effect/EffectTurbo001.h"
#include "jp/gecchi/VioletVreath/actor/my/MagicMeter.h"
#include "jp/gecchi/VioletVreath/actor/my/MagicMeter/DamageDispBar.h"
#include "jp/gecchi/VioletVreath/actor/my/MyLockonController.h"
#include "jp/gecchi/VioletVreath/actor/my/MyMagicEnergyCore.h"
#include "jp/gecchi/VioletVreath/actor/my/MyShot001.h"
#include "jp/gecchi/VioletVreath/actor/my/MySnipeShot001.h"
#include "jp/gecchi/VioletVreath/actor/my/MyStraightLaserChip001.h"
#include "jp/gecchi/VioletVreath/actor/my/MyTorpedoController.h"
#include "jp/gecchi/VioletVreath/God.h"
#include "jp/gecchi/VioletVreath/Properties.h"
#include "jp/gecchi/VioletVreath/util/MyStgUtil.h"
#include "jp/gecchi/VioletVreath/actor/my/Bunshin/MyBunshinBase.h"
#include "jp/ggaf/dxcore/util/GgafDx26DirectionUtil.h"

#include "jp/ggaf/lib/util/ColliAAPrism.h"

using namespace GgafCore;
using namespace GgafDxCore;
using namespace GgafLib;
using namespace VioletVreath;


coord MyShip::lim_y_top_     =  0;
coord MyShip::lim_y_bottom_  =  0;
coord MyShip::lim_x_infront_ =  0;
coord MyShip::lim_x_behaind_ =  0;
coord MyShip::lim_z_left_    =  0;
coord MyShip::lim_z_right_   =  0;


uint32_t MyShip::shot2_matrix_[4][MYSHIP_SHOT_MATRIX] = {
    {
            8,           //  0001000
            0,           //  0000000
            0,           //  0000000
            0,           //  0000000
            0,           //  0000000
            0,           //  0000000
            8            //  0001000
    },
    {
            0,           //  0000000
            2,           //  0000010
            0,           //  0000000
            0,           //  0000000
            0,           //  0000000
           32,           //  0100000
            0            //  0000000
    },
    {
            0,           //  0000000
            0,           //  0000000
            0,           //  0000000
           65,           //  1000001
            0,           //  0000000
            0,           //  0000000
            0            //  0000000
    },
    {
            0,           //  0000000
           32,           //  0100000
            0,           //  0000000
            0,           //  0000000
            0,           //  0000000
            2,           //  0000010
            0            //  0000000

    }
};

uint32_t MyShip::shot3_matrix_[2][MYSHIP_SHOT_MATRIX] = {
    {
            8,           //  0001000
            0,           //  0000000
            0,           //  0000000
           65,           //  1000001
            0,           //  0000000
            0,           //  0000000
            8            //  0001000
    },
    {
            0,           //  0000000
           34,           //  0100010
            0,           //  0000000
            0,           //  0000000
            0,           //  0000000
           34,           //  0100010
            0            //  0000000
    }
};

/** 僜僼僩楢幩悢偱丄侾僾僢僔儏偱寕偮偙偲偑弌棃傞楢幩悢 */
#define SOFT_RAPIDSHOT_NUM       (3)
/** 僜僼僩楢幩悢偱偺僔儑僢僩偲僔儑僢僩偺娫妘 */
#define SOFT_RAPIDSHOT_INTERVAL  (4)

MyShip::MyShip(const char* prm_name) :
        DefaultD3DXMeshActor(prm_name, "VicViper", STATUS(MyShip)) {
//DefaultMeshActor(prm_name, "jiki", STATUS(MyShip)) {
//CubeMapMeshActor(prm_name, "wakka", STATUS(MyShip)) {
//DefaultD3DXAniMeshActor(prm_name, "AnimatedSkelton", STATUS(MyShip)) {
    _class_name = "MyShip";
    pAxsMver_ = NEW GgafDxAxesMover(this);

    //effectBlendOne(); //壛嶼崌惉Technique巜掕

    //夋柺偺戝偒偝偵敽偭偰丄堏摦斖埻傪寛掕
    //偙偺偁偨傝偼FovX偵埶懚偡傞偺偱旝挷惍丅
    static const coord game_buffer_width  = PX_C(PROPERTY::GAME_BUFFER_WIDTH);
    static const coord game_buffer_height = PX_C(PROPERTY::GAME_BUFFER_HEIGHT);
    MyShip::lim_y_top_     =  (game_buffer_height/2) + game_buffer_height*4;  //忋偼丄崅偝4夋柺暘尒偊側偄椞堟傑偱堏摦壜擻
    MyShip::lim_y_bottom_  = -(game_buffer_height/2) - game_buffer_height*4;  //壓偼丄崅偝4夋柺暘尒偊側偄椞堟傑偱堏摦壜擻
    MyShip::lim_x_infront_ =  (game_buffer_width/2)  + game_buffer_width*2;   //慜偼丄暆偺2夋柺暘尒偊側偄椞堟傑偱堏摦壜擻
    MyShip::lim_x_behaind_ = -(game_buffer_width/2)  - game_buffer_width*1;   //屻傠偼丄暆偺侾夋柺暘尒偊側偄椞堟傑偱堏摦壜擻
    MyShip::lim_z_left_    =  (game_buffer_height/2) + game_buffer_height*4;   //庤慜偼丄崅偝4夋柺暘尒偊側偄椞堟傑偱堏摦壜擻
    MyShip::lim_z_right_   = -(game_buffer_height/2) - game_buffer_height*4;   //墱偼丄崅偝4夋柺暘尒偊側偄椞堟傑偱堏摦壜擻
    _TRACE_("MyShip 斖埻 X("<<MyShip::lim_x_behaind_<<" 乣 "<<MyShip::lim_x_infront_<<")  Y("<<MyShip::lim_y_bottom_<<" 乣 "<<MyShip::lim_y_top_<<")  Z("<<MyShip::lim_z_right_<<" 乣 "<<MyShip::lim_z_left_<<")");


    //CommonScene偑new偺応崌愝掕
    angRxVelo_BeginMZ_ = 1000;   //墱枖偼庤慜傊捠忢Z捠忢堏摦奐巒帪偺X幉夞揮妏懍搙偺弶懍搙
    angRxAcce_MZ_ = 300;         //墱枖偼庤慜傊捠忢Z堏摦拞偺X幉夞揮妏懍搙偺弶妏壛懍搙
    angRxTopVelo_MZ_ = 5000;     //墱枖偼庤慜傊捠忢Z堏摦拞偺X幉夞揮妏懍搙偺忋尷妏懍搙
    angRxStop_MZ_ = 90000;       //墱枖偼庤慜傊捠忢Z堏摦拞偺X幉夞揮妏偺栚昗掆巭妏搙
    angRxVelo_BeginMZT_ = 20000; //墱枖偼庤慜傊Turbo堏摦奐巒帪偺X幉夞揮妏懍搙偺弶懍搙

    mv_speed_ = 0;
    veloBeginMT_ = 0;
    setMoveSpeed(2000);


//    //debug ---->
//    pDepo_TestGuShot_ = NEW GgafActorDepository("Depo_TestGuShot");
//    for (int i = 0; i < 25; i++) { //僥僗僩僌乕抏僗僩僢僋
//        pDepo_TestGuShot_->addSubLast(NEW TestGuShot("TestGuShot"));
//    }
//    addSubGroup(pDepo_TestGuShot_);
//    pDepo_TestChokiShot_ = NEW GgafActorDepository("Depo_TestChokiShot");
//    for (int i = 0; i < 25; i++) { //僥僗僩僠儑僉抏僗僩僢僋
//        pDepo_TestChokiShot_->addSubLast(NEW TestChokiShot("TestChokiShot"));
//    }
//    addSubGroup(pDepo_TestChokiShot_);
//    pDepo_TestPaShot_ = NEW GgafActorDepository("Depo_TestPaShot");
//    for (int i = 0; i < 25; i++) { //僥僗僩僷乕抏僗僩僢僋
//        pDepo_TestPaShot_->addSubLast(NEW TestPaShot("TestPaShot"));
//    }
//    addSubGroup(pDepo_TestPaShot_);
//    pDepo_TestNomalShot_ = NEW GgafActorDepository("Depo_TestNomalShot");
//    for (int i = 0; i < 25; i++) { //僥僗僩僲乕儅儖抏僗僩僢僋
//        pDepo_TestNomalShot_->addSubLast(NEW TestNomalShot("TestNomalShot"));
//    }
//    addSubGroup(pDepo_TestNomalShot_);
//    //<---- debug


    pDepo_MyShots001_ = NEW GgafActorDepository("RotShot001");
    MyShot001* pShot;
    for (int i = 0; i < 50; i++) { //帺抏僗僩僢僋
        pShot = NEW MyShot001("MY_MyShot001");
        pShot->inactivate();
        pDepo_MyShots001_->put(pShot);
    }
    addSubGroup(pDepo_MyShots001_);

    pDepo_MySnipeShots001_ = NEW GgafActorDepository("RotShot001");
    MySnipeShot001* pSnipeShot;
    for (int i = 0; i < 5; i++) { //帺抏僗僩僢僋
        pSnipeShot = NEW MySnipeShot001("MY_MySnipeShot001");
        pSnipeShot->inactivate();
        pDepo_MySnipeShots001_->put(pSnipeShot);
    }
    addSubGroup(pDepo_MySnipeShots001_);

    pLaserChipDepo_ = NEW LaserChipDepository("MyRotLaser");
    MyStraightLaserChip001* pChip;
    for (int i = 0; i < 80; i++) { //儗乕僓乕僗僩僢僋
        std::string name = "MyStraightLaserChip001("+XTOS(i)+")";
        pChip = NEW MyStraightLaserChip001(name.c_str());
        pChip->setPositionSource(this); //埵抲偩偗摨婜
        pLaserChipDepo_->put(pChip);
    }
    pLaserChipDepo_->config(80, 25, nullptr);
    addSubGroup(pLaserChipDepo_);

    //儘僢僋僆儞僐儞僩儘乕儔乕
    pLockonCtrler_ = NEW MyLockonController("MySHipLockonController");
    addSubGroup(pLockonCtrler_);

    //僼僅僩儞僐儞僩儘乕儔乕
    pTorpedoCtrler_ = NEW MyTorpedoController("TorpedoController", this, pLockonCtrler_);
    addSubGroup(pTorpedoCtrler_);

    pEffectTurbo001_ = NEW EffectTurbo001("EffectTurbo001");
    addSubGroup(pEffectTurbo001_);
//    pEffectTurbo002_ = NEW EffectTurbo002("EffectTurbo002");
//    addSubGroup(pEffectTurbo002_);

    pMyMagicEnergyCore_ = NEW MyMagicEnergyCore("MyMagicEnergyCore");
    addSubGroup(pMyMagicEnergyCore_);

    //26曽岦偵堏摦偟偨応崌偺帺婡偺孹偒掕媊
    pSenakai_ = &(senakai_[13]);
    pSenakai_[DIR26(-1,-1,-1)] = -D_ANG(120);
    pSenakai_[DIR26(-1,-1, 0)] =  0;
    pSenakai_[DIR26(-1,-1, 1)] =  D_ANG(120);
    pSenakai_[DIR26(-1, 0,-1)] = -D90ANG;
    pSenakai_[DIR26(-1, 0, 0)] =  0;
    pSenakai_[DIR26(-1, 0, 1)] =  D90ANG;
    pSenakai_[DIR26(-1, 1,-1)] = -D_ANG(30);
    pSenakai_[DIR26(-1, 1, 0)] =  0;
    pSenakai_[DIR26(-1, 1, 1)] =  D_ANG(30);
    pSenakai_[DIR26( 0,-1,-1)] = -D135ANG;
    pSenakai_[DIR26( 0,-1, 0)] =  0;
    pSenakai_[DIR26( 0,-1, 1)] =  D135ANG;
    pSenakai_[DIR26( 0, 0,-1)] = -D90ANG;
    pSenakai_[DIR26( 0, 0, 0)] =  0;
    pSenakai_[DIR26( 0, 0, 1)] =  D90ANG;
    pSenakai_[DIR26( 0, 1,-1)] = -D45ANG;
    pSenakai_[DIR26( 0, 1, 0)] =  0;
    pSenakai_[DIR26( 0, 1, 1)] =  D45ANG;
    pSenakai_[DIR26( 1,-1,-1)] = -D_ANG(120);
    pSenakai_[DIR26( 1,-1, 0)] =  0;
    pSenakai_[DIR26( 1,-1, 1)] =  D_ANG(120);
    pSenakai_[DIR26( 1, 0,-1)] = -D90ANG;
    pSenakai_[DIR26( 1, 0, 0)] =  0;
    pSenakai_[DIR26( 1, 0, 1)] =  D90ANG;
    pSenakai_[DIR26( 1, 1,-1)] = -D_ANG(30);
    pSenakai_[DIR26( 1, 1, 0)] =  0;
    pSenakai_[DIR26( 1, 1, 1)] =  D_ANG(30);

    GgafDxSeTransmitterForActor* pSe = getSeTransmitter();
    pSe->set(SE_DAMAGED     , "WAVE_MY_DAMAGED_001");
    pSe->set(SE_EXPLOSION   , "WAVE_MY_SE_EXPLOSION_001");
    pSe->set(SE_TURBO       , "WAVE_MY_TURBO_001");
    pSe->set(SE_CANT_TURBO  , "WAVE_MY_CANT_TURBO_001");
    pSe->set(SE_FIRE_LASER  , "WAVE_MY_FIRE_LASER_001");
    pSe->set(SE_FIRE_SHOT   , "WAVE_MY_FIRE_SHOT_001");
    pSe->set(SE_FIRE_TORPEDO, "WAVE_MY_FIRE_TORPEDO_001");

    veloTurboTop_ = 30000;
    veloTurboBottom_ = 10000;

    is_being_soft_rapidshot_ = false;
    soft_rapidshot_shot_count_ = 0;
    soft_rapidshot_push_cnt_ = 0;
    soft_rapidshot_shot_count_in_one_push_ = 0;
    soft_rapidshot_frames_in_one_push = 0;
    is_snipe_shot_ = false;

    is_just_shot_ = false;
    is_shooting_laser_ = false;
    can_shoot_laser_ = false;
    frame_shot_pressed_ = 0;

    can_control_ = true;
    is_diving_ = false;

    blown_veloX_ = 0;
    blown_veloY_ = 0;
    blown_veloZ_ = 0;
    way_ = DIR26( 0, 0, 0);
    prev_way_ = DIR26( 0, 0, 0);
    is_just_change_way_ = true;

    //MP弶婜抣
    mp_ = MY_SHIP_START_MP;
    //mp_傪曄偊傞偲丄撪晹嶲徠偡傞 MpBar 偺昞帵偑楢摦偟偰曄傢傞

    //Vreath偼幚抣傪 getStatus() 偺STAT_Stamina抣傪嶲徠偡傞傛偆偵愝掕丅
//    vreath_.link( &(getStatus()->_paValue[STAT_Stamina]._int_val) );
    //STAT_Stamina偑尭傟偽丄vreath_ 偑曄壔偟丄偦傟傪撪晹嶲徠偡傞 VreathBar 偺昞帵偑楢摦偟偰曄傢傞

    //杺朄儊乕僞乕愝抲
    pMagicMeter_ = NEW MagicMeter("MagicMeter", &mp_, &(getStatus()->_paValue[STAT_Stamina]._int_val) );
    pMagicMeter_->setPosition(PX_C(100), PX_C(PROPERTY::GAME_BUFFER_HEIGHT) - (pMagicMeter_->height_) - PX_C(16+16+16));
    addSubGroup(pMagicMeter_);

    r_blown_velo_decay_ = 0.8;

    invincible_frames_ = 0;

    trace_delay_count_ = 0;
    is_trace_waiting_ = false;

    shot_level_ = 1;

    prev_x_ = _x;
    prev_y_ = _y;
    prev_z_ = _z;
}

void MyShip::onCreateModel() {
    GgafDxModel* pModel = getModel();
    pModel->setSpecular(5.0, 1.0);
}

void MyShip::initialize() {
    _TRACE_(FUNC_NAME<<"");

    //庬暿偵怳傝暘偗
//    bringDirector()->addSubGroup(KIND_MY_SHOT_NOMAL, pDepo_MyShots001_->extract());
//    bringDirector()->addSubGroup(KIND_MY_SHOT_NOMAL, pDepo_MyWaves001_->extract());
    //bringDirector()->addSubGroup(KIND_MY_SHOT_NOMAL, pLaserChipDepo_->extract());

    setHitAble(true);
    CollisionChecker* pChecker = getCollisionChecker();
    pChecker->createCollisionArea(1);
//    pChecker->setColliSphere(0, -100000, -50000, 20000, 100000);
// pChecker->setColliAABox(0, -100000, -50000, 20000, 10000, 40000, 80000);
//    pChecker->setColliSphere(1, 0,-100000,0, 30000, true, true, true);
//    pChecker->setColliSphere(2, 0,100000,0, 30000, true, true, true);
//    pChecker->setColliSphere(3, 0,0,-100000, 30000, true, true, true);
//    pChecker->setColliSphere(4, 0,0,100000, 30000, true, true, true);

//    pChecker->setColliAABox_Cube(0, 40000);
/////////////TEST
      pChecker->setColliAABox_Cube(0, PX_C(120));

    GgafDxKuroko* const pKuroko = getKuroko();
    pKuroko->setMvVelo(0);

    //setMaterialColor(1.0, 0.5, 0.5);
    setAlpha(1.0);

    pAxsMver_->forceVxyzMvVeloRange(-veloTurboTop_, veloTurboTop_);
    pAxsMver_->setZeroVxyzMvAcce();

    getKuroko()->setRollFaceAngVelo(300);
}


void MyShip::onReset() {
    _TRACE_(FUNC_NAME<<" "<<NODE_INFO<<"");
    is_being_soft_rapidshot_ = false;
    soft_rapidshot_shot_count_ = 0;
    soft_rapidshot_push_cnt_ = 0;
    soft_rapidshot_shot_count_in_one_push_ = 0;
    soft_rapidshot_frames_in_one_push = 0;
    is_snipe_shot_ = false;
    is_being_soft_rapidshot_ = false;
    is_just_shot_ = false;
    is_shooting_laser_ = false;
    can_shoot_laser_ = false;
    frame_shot_pressed_ = 0;
    _x = _y = _z = 0;
    way_ = DIR26( 0, 0, 0);
    prev_way_ = DIR26( 0, 0, 0);
//    way_switch_.reset();

    mp_ = MY_SHIP_START_MP;
    getStatus()->reset();

    setInvincibleFrames(60 * 10); //搊応帪偺柍揋帪娫
}

void MyShip::onActive() {
    _TRACE_(FUNC_NAME<<"");
    //儗乕僓乕傗儘僢僋儞僞乕僎僢僩傗嫑棆偑僒僽偵偄傞偨傔
    //屄暿偵屇傃弌偡
    pLockonCtrler_->onActive();
    pTorpedoCtrler_->onActive();
}
void MyShip::onInactive() {
    _TRACE_(FUNC_NAME<<"");
    //儗乕僓乕傗儘僢僋儞僞乕僎僢僩傗嫑棆偑僒僽偵偄傞偨傔
    //屄暿偵屇傃弌偡
    pLockonCtrler_->onInactive();
    pTorpedoCtrler_->onInactive();
//    pLaserChipDepo_->reset();
}
void MyShip::processBehavior() {
    VirtualButton* pVbPlay = VB_PLAY;
    int pos_camera = P_VAM->getPosCam();
    GgafDxKuroko* const pKuroko = getKuroko();

    //憖嶌嫅斲
    if (!can_control_) {
        return;
    }

    int prev_way = way_;

    way_ = getMoveWay();

    if (prev_way != way_) {
        is_just_change_way_ = true;
    } else {
        is_just_change_way_ = false;
    }

    if (getStatus()->get(STAT_Stamina) < 0) {
        //懅愗傟
    } else {
        if (pVbPlay->isPressed(VB_OPTION)) {
            int tmp = mv_speed_;
            mv_speed_ /= 8; //僆僾僔儑儞憖嶌拞堏摦偼抶偄
            moveNomal(way_);
            mv_speed_ = tmp;
        } else {
            moveNomal(way_);
        }

        if (pVbPlay->isPushedDown(VB_TURBO)) {
            if (pAxsMver_->_velo_vx_mv == 0 && pAxsMver_->_velo_vy_mv == 0 && pAxsMver_->_velo_vz_mv == 0) {
                //僞乕儃堏摦姰慡偵廔椆偟側偄偲師偺僞乕儃偼幚峴晄壜
                moveTurbo(way_);
                UTIL::activateProperEffect01Of(this); //僞乕儃奐巒偺僄僼僃僋僩
//                (this->*funcTurbo_[way_])(); //曽岦抣偵墳偠偨僞乕儃奐巒張棟儊僜僢僪傪屇傃弌偡
                getSeTransmitter()->play3D(SE_TURBO);
            } else {
                //僞乕儃堏摦拞
                getSeTransmitter()->play3D(SE_CANT_TURBO);
            }
        } else {
            //Not僞乕儃奐巒帪
            if (pVbPlay->isPressed(VB_TURBO)) {
                //僞乕儃儃僞儞傪墴偟懕偗傞偙偲偱丄懍搙尭悐偑備傞傗偐偵側傝丄
                //堏摦嫍棧傪怢偽偡
                pAxsMver_->_velo_vx_mv *= 0.96;
                pAxsMver_->_velo_vy_mv *= 0.96;
                pAxsMver_->_velo_vz_mv *= 0.96;
            } else {
                //僞乕儃傪棧偟偨応崌丄懍搙尭悐丅
                pAxsMver_->_velo_vx_mv *= 0.9;
                pAxsMver_->_velo_vy_mv *= 0.9;
                pAxsMver_->_velo_vz_mv *= 0.9;
            }
            if (ABS(pAxsMver_->_velo_vx_mv) <= 2) {
                pAxsMver_->_velo_vx_mv = 0;
            }
            if (ABS(pAxsMver_->_velo_vy_mv) <= 2) {
                pAxsMver_->_velo_vy_mv = 0;
            }
            if (ABS(pAxsMver_->_velo_vz_mv) <= 2) {
                pAxsMver_->_velo_vz_mv = 0;
            }
        }

        if (pVbPlay->isDoublePushedDown(VB_OPTION,8,8) ) {
            pAxsMver_->setZeroVxyzMvVelo(); //僞乕儃堏摦拞偱傕掆巭偡傞丅乮僞乕儃僉儍儞僙儖揑偵側傞両乯
        }
    }


    //僗僺儞偑惃偄傛偔夞偭偰偄傞側傜偽懍搙傪庛傔傞
    angvelo MZ = angRxTopVelo_MZ_-3000; //3000偼捠忢慁夞帪偵懍搙傪庛傔偰angRxTopVelo_MZ_傪挻偊側偄傛偆偵偡傞偨傔丄傗傗庤慜偱尭懍偡傞偲尵偆堄枴乮TODO:梫挷惍乯丅
    if (pKuroko->_angvelo_face[AXIS_X] >= MZ) {
        pKuroko->_angvelo_face[AXIS_X] *= 0.93;
        //_getKuroko()->setFaceAngAcce(AXIS_X, -1*angRxAcce_MZ_*2);
    } else if (pKuroko->_angvelo_face[AXIS_X] <= -MZ) {
        pKuroko->_angvelo_face[AXIS_X] *= 0.93;
        //_getKuroko()->setFaceAngAcce(AXIS_X, angRxAcce_MZ_*2);
    }

    //慁夞偟側偄堏摦曽岦偺応崌丄婡懱傪悈暯偵偡傞乮扐偟惃偄傛偔夞偭偰偄側偄応崌偵尷傞丅setStopTargetFaceAng偺戞4堷悢傛傝妏懍搙偑備傞偄応崌庴偗擖傟乯
    if (pSenakai_[way_] == 0) {
        angle dist = pKuroko->getFaceAngDistance(AXIS_X, 0, TURN_CLOSE_TO);
        if (0 <= dist && dist < D180ANG) {
            getKuroko()->setFaceAngAcce(AXIS_X, angRxAcce_MZ_);
        } else if (-1*D180ANG < dist && dist < 0) {
            getKuroko()->setFaceAngAcce(AXIS_X, -1*angRxAcce_MZ_);
        }
        pKuroko->setMvAcce(0);
        pKuroko->setStopTargetFaceAng(AXIS_X, 0, TURN_BOTH, angRxTopVelo_MZ_);
    }



    ////////////////////////////////////////////////////

    //嵗昗偵斀塮
    pKuroko->behave();
    pAxsMver_->behave();
    getSeTransmitter()->behave();

    if (invincible_frames_ > 0) {
        setHitAble(false);
        invincible_frames_ --;
        if (getActiveFrame() % 2 == 0) {
            setAlpha(0.6);
        } else {
            setAlpha(0);
        }
        if (invincible_frames_ == 0) {
            setHitAble(true);
            setAlpha(1.0);
        }
    } else {

    }
    //悂偭旘傃
    if (ABS(blown_veloX_) < PX_C(1)) {
        blown_veloX_ = 0;
    } else {
        _x += blown_veloX_;
        blown_veloX_ *= r_blown_velo_decay_;
    }
    if (ABS(blown_veloY_) < PX_C(1)) {
        blown_veloY_ = 0;
    } else {
        _y += blown_veloY_;
        blown_veloY_ *= r_blown_velo_decay_;
    }
    if (ABS(blown_veloZ_) < PX_C(1)) {
        blown_veloZ_ = 0;
    } else {
        _z += blown_veloZ_;
        blown_veloZ_ *= r_blown_velo_decay_;
    }


    if (is_diving_) {
        //撍擖儌乕僔儑儞帪偼丄堏摦斖埻惂屼柍偟
    } else {
        //捠忢堏摦斖埻惂屼
        if (_y > MyShip::lim_y_top_) {
            _y = MyShip::lim_y_top_;
        } else if (_y < MyShip::lim_y_bottom_ ) {
            _y = MyShip::lim_y_bottom_;
        }

        if (_x > MyShip::lim_x_infront_) {
            _x = MyShip::lim_x_infront_;
        } else if (_x < MyShip::lim_x_behaind_) {
            _x = MyShip::lim_x_behaind_;
        }

        if (_z > MyShip::lim_z_left_) {
            _z = MyShip::lim_z_left_;
        } else if (_z < MyShip::lim_z_right_) {
            _z = MyShip::lim_z_right_;
        }
    }




    //枅僼儗乕儉偺屇媧偺徚旓
    getStatus()->minus(STAT_Stamina, MY_SHIP_VREATH_COST);



    //僔儑僢僩娭楢張棟
    is_shooting_laser_ = false;
    if (pVbPlay->isPressed(VB_SHOT1)) {
        frame_shot_pressed_ ++;
        if (can_shoot_laser_) {
            if (frame_shot_pressed_ > 30) { //30僼儗乕儉墴偟偭傁側偟偱儗乕僓乕傊
                is_shooting_laser_ = true;
            }
        }
    } else {
        frame_shot_pressed_ = 0;
        pLockonCtrler_->releaseAllLockon(); //儘僢僋僆儞夝彍
    }

    //儗乕僓乕敪幩
    if (is_shooting_laser_) {
        if (pVbPlay->isPressed(VB_SHOT1)) {
            LaserChip* pLaserChip = pLaserChipDepo_->dispatch();
            if (pLaserChip) {
                if (pLaserChip->getInfrontChip() == nullptr) {
                    getSeTransmitter()->play3D(SE_FIRE_LASER);
                }
            }
        } else {

        }
    }

    //僜僼僩楢幩
    //侾僾僢僔儏栚偺弶抏偺傒侾敪偺傒敪幩偺僗僫僀僾僔儑僢僩丅
    //俀僾僢僔儏栚埲崀僜僼僩楢幩丄侾僾僢僔儏偱4F枅偵嵟戝3敪
    if (pVbPlay->isPushedDown(VB_SHOT1) && !pVbPlay->isPressed(VB_POWERUP)) {
        if (is_being_soft_rapidshot_) {
            if (soft_rapidshot_frames_in_one_push >= SOFT_RAPIDSHOT_INTERVAL) {
                //僾僢僔儏屻偺僜僼僩楢幩偵傛傞俀敪栚偺 SOFT_RAPIDSHOT_INTERVAL 僼儗乕儉傛傝師偺僾僢僔儏偑抶偄応崌
                //楢幩偲楢幩偺偮側偓栚偑柍偄傛偆偵墘弌偡傞傔偵丄
                //soft_rapidshot_frames_in_one_push 傪 SOFT_RAPIDSHOT_INTERVAL 攞偺抣擾抧嵟彫抣偵偡傞
                soft_rapidshot_frames_in_one_push = soft_rapidshot_frames_in_one_push % SOFT_RAPIDSHOT_INTERVAL;
                if (soft_rapidshot_frames_in_one_push > 0) {
                    //soft_rapidshot_frames_in_one_push 偑塣椙偔0側傜偽丄SOFT_RAPIDSHOT_NUM 敪偺抏偑僜僼僩楢幩偵傛傝敪幩偝傟傞偙偲偵側傞偑丄
                    //soft_rapidshot_frames_in_one_push > 0 側傜偽丄SOFT_RAPIDSHOT_NUM-1 敪偵側傝侾敪尭偭偰偟傑偆丅
                    //偙傟傪旔偗傞堊丄SOFT_RAPIDSHOT_NUM 敪偺抏傪寕偮偙偲傪曐徹偡傞偨傔偵丄soft_rapidshot_frames_in_one_push傪曗惓
                    soft_rapidshot_frames_in_one_push -= SOFT_RAPIDSHOT_INTERVAL;
                }
                soft_rapidshot_shot_count_in_one_push_ = 0;
                soft_rapidshot_push_cnt_++;
            } else {
                //僾僢僔儏屻丄僜僼僩楢幩偵傛傞俀敪栚偺 SOFT_RAPIDSHOT_INTERVAL 僼儗乕儉傛傝師偺僾僢僔儏偑懍偄応崌
                //偙傟傪庴偗擖傟偰嫮惂揑偵敪幩偱偒傞(SOFT_RAPIDSHOT_INTERVAL傛傝懍偄庤摦楢幩偼丄楢幩桪愭)
                soft_rapidshot_frames_in_one_push = 0;
                soft_rapidshot_shot_count_in_one_push_ = 0;
                soft_rapidshot_push_cnt_++;
            }
        } else {
            //僜僼僩楢幩奐巒両
            is_being_soft_rapidshot_ = true;
            soft_rapidshot_frames_in_one_push = 0;
            soft_rapidshot_shot_count_in_one_push_ = 0;
            soft_rapidshot_push_cnt_ = 1;
        }
    }

    if (is_being_soft_rapidshot_) {
        //僜僼僩楢幩拞丄幚嵺偵僔儑僢僩傪曻偮僞僀儈儞僌偺敾掕
        if (soft_rapidshot_frames_in_one_push % SOFT_RAPIDSHOT_INTERVAL == 0) {
            //僔儑僢僩傪曻偮僞僀儈儞僌偱偼偁傞偑丄壥偨偟偰僔儑僢僩偟偰傕傛偄偐丠
            soft_rapidshot_shot_count_++;
            soft_rapidshot_shot_count_in_one_push_++;
            //僜僼僩楢幩堐帩帪娫奜敾掕
            if(soft_rapidshot_frames_in_one_push > SOFT_RAPIDSHOT_INTERVAL*(SOFT_RAPIDSHOT_NUM-1)) {
                //僜僼僩楢幩夝彍
                is_being_soft_rapidshot_ = false;
                soft_rapidshot_shot_count_ = 0;
                soft_rapidshot_shot_count_in_one_push_ = 0;
                soft_rapidshot_push_cnt_ = 0;
                is_just_shot_ = false; //僔儑僢僩柍偟傛
            } else {
                //僜僼僩楢幩堐帩帪娫撪側偺偱
                is_just_shot_ = true;  //僔儑僢僩偟傑偟傚偆
                soft_rapidshot_frames_in_one_push++;
            }
        } else {
            //僜僼僩楢幩拞偩偑丄僞僀儈儞僌偑埆偄
            is_just_shot_ = false;
            soft_rapidshot_frames_in_one_push++;
        }
    } else {
         //僜僼僩楢幩拞偱偡傜側偄
        is_just_shot_ = false;
    }

    //僗僫僀僾僔儑僢僩偺敾掕
    is_snipe_shot_ = false;
    if (is_just_shot_) {
        if (soft_rapidshot_push_cnt_ == 1) { //嵟弶偺僾僢僔儏偱偁傞丅
            if (soft_rapidshot_shot_count_in_one_push_ == 1) {  //嵟弶偺僾僢僔儏偺侾敪栚偱偁傞
                is_snipe_shot_ = true; //僗僫僀僾僔儑僢僩両
            }
            if (2 <= soft_rapidshot_shot_count_in_one_push_ && soft_rapidshot_shot_count_in_one_push_ <= SOFT_RAPIDSHOT_NUM) {
                is_just_shot_ = false; //僗僫僀僾僔儑僢僩帪偺僾僢僔儏偼丄弶抏埲奜傪柍棟傗傝僔儑僢僩柍偟嫺惓丅
            } else {
                is_just_shot_ = true;
            }
        }
    } else {
    }

    if (is_just_shot_) {
        if (is_snipe_shot_) {
            //僗僫僀僾僔儑僢僩帪
            MySnipeShot001* const pSnipeShot = (MySnipeShot001*)pDepo_MySnipeShots001_->dispatch();
            if (pSnipeShot) {
                getSeTransmitter()->play3D(SE_FIRE_SHOT);
                pSnipeShot->setPositionAt(this);
                pSnipeShot->getKuroko()->setRzRyMvAng(_rz, _ry);
                pSnipeShot->getKuroko()->setMvVelo(PX_C(100));
                pSnipeShot->getKuroko()->setMvAcce(100);
            }
        } else {
            //僗僫僀僾僔儑僢僩埲奜帪
            if (shot_level_ >= 1) {
                MyShot001* const pShot = (MyShot001*)pDepo_MyShots001_->dispatch();
                if (pShot) {
                    getSeTransmitter()->play3D(SE_FIRE_SHOT);
                    pShot->setPositionAt(this);
                    pShot->getKuroko()->setRzRyMvAng(_rz, _ry);
                    pShot->getKuroko()->setMvVelo(PX_C(70));
                    pShot->getKuroko()->setMvAcce(100);
                }
            }

            if (shot_level_ == 2) {
                uint32_t i = soft_rapidshot_shot_count_ % 4;
                UTIL::shotWay003(this,
                                 pDepo_MyShots001_ , MyShip::shot2_matrix_[i],
                                 nullptr, nullptr,
                                 nullptr, nullptr,
                                 PX_C(1),
                                 MYSHIP_SHOT_MATRIX, MYSHIP_SHOT_MATRIX,
                                 D_ANG(5), D_ANG(5),
                                 PX_C(70), 100,
                                 1, 0, 1.0);
            } else if (shot_level_ >= 3) {
                uint32_t i = soft_rapidshot_shot_count_ % 2;
                UTIL::shotWay003(this,
                                 pDepo_MyShots001_ , MyShip::shot3_matrix_[i],
                                 nullptr, nullptr,
                                 nullptr, nullptr,
                                 PX_C(1),
                                 MYSHIP_SHOT_MATRIX, MYSHIP_SHOT_MATRIX,
                                 D_ANG(5), D_ANG(5),
                                 PX_C(70), 100,
                                 1, 0, 1.0);
            }
        }
    }


    //岝巕嫑棆敪幩
    if (pVbPlay->isPushedDown(VB_SHOT2)) {
        if (this->pTorpedoCtrler_->fire()) {
            getSeTransmitter()->play3D(MyShip::SE_FIRE_TORPEDO);
        }
    }

    //TODO:帺敋 TEST
    if (GgafDxInput::isPushedDownKey(DIK_0)) {
        //帺婡敋敪奐嵜
        setHitAble(false);
        getSeTransmitter()->play3D(SE_EXPLOSION);
        throwEventUpperTree(EVENT_MY_SHIP_WAS_DESTROYED_BEGIN);
    }


    if (prev_x_ == _x && prev_y_ == _y && prev_z_ == _z) {
        is_move_ = false;
    } else {
        is_move_ = true;
    }
    mv_offset_x_ = _x - prev_x_;
    mv_offset_y_ = _y - prev_y_;
    mv_offset_z_ = _z - prev_z_;
    prev_x_ = _x;
    prev_y_ = _y;
    prev_z_ = _z;
}

void MyShip::processJudgement() {
}

void MyShip::onHit(const GgafActor* prm_pOtherActor) {
    GgafDxGeometricActor* pOther = (GgafDxGeometricActor*)prm_pOtherActor;
    //偙偙偵僸僢僩僄僼僃僋僩
    int vreath = getStatus()->get(STAT_Stamina);
    if (UTIL::calcMyStamina(this, pOther) <= 0) {
        //帺婡敋敪奐嵜
        setHitAble(false);
        getSeTransmitter()->play3D(SE_EXPLOSION);
        throwEventUpperTree(EVENT_MY_SHIP_WAS_DESTROYED_BEGIN);
    }
    int damage = vreath - getStatus()->get(STAT_Stamina);
    if (damage > 0) {
        pMagicMeter_->pDamageDispBar_->addDamage(damage > vreath ? vreath : damage);
    }

    //暻偺応崌摿暿側張棟
    if (pOther->getKind() & KIND_CHIKEI) {
        //悂偭旘傃曽岦傪峫偊傞丅
        //尰嵼偺堏摦偺媡曽岦乮悂偭旘傃埿椡偼俀攞偵乯
        float vx1,vy1,vz1;
        coord dX1 = -mv_offset_x_;
        coord dY1 = -mv_offset_y_;
        coord dZ1 = -mv_offset_z_;
        if (dX1 == 0 && dY1 == 0 && dZ1 == 0) {
            vx1 = vy1 = vz1 = 0;
        } else {
            UTIL::getNormalizedVector(dX1, dY1, dZ1,
                                     vx1, vy1, vz1 );
        }
        float vx2, vy2, vz2;
        coord dX2,dY2,dZ2;
        if ( pOther->instanceOf(Obj_WallPartsActor)) {
            if ((pOther->_pChecker->_pCollisionArea->_papColliPart[0]->_shape_kind) & COLLI_AAPRISM) {
                //僾儕僘儉暻
                ColliAAPrism* pPrism = (ColliAAPrism*)(pOther->_pChecker->_pCollisionArea->_papColliPart[0]);
                int pos_prism = pPrism->_pos_info;
                if (pos_prism & POS_PRISM_XY) {
                    if (pos_prism & POS_PRISM_pp) {
                        //            仾 y+
                        // (_x1,_y2)      (_x2,_y2)
                        //        劇劅劅劅劉
                        //        劆乢偙偪劆
                        // x- 仼  劆  乢傜劆  仺 x+
                        //        劆    乢劆
                        //        劋劅劅劅劊
                        // (_x1,_y1)      (_x2,_y1)
                        //            伀 y-
                        dX2 = (_x - (pOther->_x + pPrism->_hdx));
                        dY2 = (_y - (pOther->_y + pPrism->_hdy));
                        dZ2 = (_z - (pOther->_z               ));
                    } else if (pos_prism & POS_PRISM_np) {
                        //            仾 y+
                        // (_x1,_y2)      (_x2,_y2)
                        //        劇劅劅劅劉
                        //        劆偙偪乛劆
                        // x- 仼  劆傜乛  劆  仺 x+
                        //        劆乛    劆
                        //        劋劅劅劅劊
                        // (_x1,_y1)      (_x2,_y1)
                        //            伀 y-
                        dX2 = (_x - (pOther->_x - pPrism->_hdx));
                        dY2 = (_y - (pOther->_y + pPrism->_hdy));
                        dZ2 = (_z - (pOther->_z               ));
                    } else if (pos_prism & POS_PRISM_pn) {
                        //            仾 y+
                        // (_x1,_y2)      (_x2,_y2)
                        //        劇劅劅劅劉
                        //        劆    乛劆
                        // x- 仼  劆  乛偙劆  仺 x+
                        //        劆乛偪傜劆
                        //        劋劅劅劅劊
                        // (_x1,_y1)      (_x2,_y1)
                        //            伀 y-
                        dX2 = (_x - (pOther->_x + pPrism->_hdx));
                        dY2 = (_y - (pOther->_y - pPrism->_hdy));
                        dZ2 = (_z - (pOther->_z               ));
                    } else { // 偺偙傝偼 POS_PRISM_nn
                        //            仾 y+
                        // (_x1,_y2)      (_x2,_y2)
                        //        劇劅劅劅劉
                        //        劆乢    劆
                        // x- 仼  劆偙乢  劆  仺 x+
                        //        劆偪傜乢劆
                        //        劋劅劅劅劊
                        // (_x1,_y1)      (_x2,_y1)
                        //            伀 y-
                        dX2 = (_x - (pOther->_x - pPrism->_hdx));
                        dY2 = (_y - (pOther->_y - pPrism->_hdy));
                        dZ2 = (_z - (pOther->_z               ));
                    }

                } else if (pos_prism & POS_PRISM_YZ) {

                    if (pos_prism & POS_PRISM_pp) {
                        //            仾 z+
                        // (_y1,_z2)      (_y2,_z2)
                        //        劇劅劅劅劉
                        //        劆乢偙偪劆
                        // y- 仼  劆  乢傜劆  仺 y+
                        //        劆    乢劆
                        //        劋劅劅劅劊
                        // (_y1,_z1)      (_y2,_z1)
                        //            伀 z-
                        dX2 = (_x - (pOther->_x               ));
                        dY2 = (_y - (pOther->_y + pPrism->_hdy));
                        dZ2 = (_z - (pOther->_z + pPrism->_hdz));
                    } else if (pos_prism & POS_PRISM_np) {
                        //            仾 z+
                        // (_y1,_z2)      (_y2,_z2)
                        //        劇劅劅劅劉
                        //        劆偙偪乛劆
                        // y- 仼  劆傜乛  劆  仺 y+
                        //        劆乛    劆
                        //        劋劅劅劅劊
                        // (_y1,_z1)      (_y2,_z1)
                        //            伀 z-
                        dX2 = (_x - (pOther->_x               ));
                        dY2 = (_y - (pOther->_y - pPrism->_hdy));
                        dZ2 = (_z - (pOther->_z + pPrism->_hdz));
                    } else if (pos_prism & POS_PRISM_pn) {
                        //            仾 z+
                        // (_y1,_z2)      (_y2,_z2)
                        //        劇劅劅劅劉
                        //        劆    乛劆
                        // y- 仼  劆  乛偙劆  仺 y+
                        //        劆乛偪傜劆
                        //        劋劅劅劅劊
                        // (_y1,_z1)      (_y2,_z1)
                        //            伀 z-
                        dX2 = (_x - (pOther->_x               ));
                        dY2 = (_y - (pOther->_y + pPrism->_hdy));
                        dZ2 = (_z - (pOther->_z - pPrism->_hdz));
                    } else { // 偺偙傝偼 POS_PRISM_nn
                        //            仾 z+
                        // (_y1,_z2)      (_y2,_z2)
                        //        劇劅劅劅劉
                        //        劆乢    劆
                        // y- 仼  劆偙乢  劆  仺 y+
                        //        劆偪傜乢劆
                        //        劋劅劅劅劊
                        // (_y1,_z1)      (_y2,_z1)
                        //            伀 z-
                        dX2 = (_x - (pOther->_x               ));
                        dY2 = (_y - (pOther->_y - pPrism->_hdy));
                        dZ2 = (_z - (pOther->_z - pPrism->_hdz));
                    }

                } else if (pos_prism & POS_PRISM_ZX) {
                    if (pos_prism & POS_PRISM_pp) {
                        //            仾 x+
                        // (_z1,_x2)      (_z2,_x2)
                        //        劇劅劅劅劉
                        //        劆乢偙偪劆
                        // z- 仼  劆  乢傜劆  仺 z+
                        //        劆    乢劆
                        //        劋劅劅劅劊
                        // (_z1,_x1)      (_z2,_x1)
                        //            伀 x-
                        dX2 = (_x - (pOther->_x + pPrism->_hdx));
                        dY2 = (_y - (pOther->_y               ));
                        dZ2 = (_z - (pOther->_z + pPrism->_hdz));
                    } else if (pos_prism & POS_PRISM_np) {
                        //            仾 x+
                        // (_z1,_x2)      (_z2,_x2)
                        //        劇劅劅劅劉
                        //        劆偙偪乛劆
                        // z- 仼  劆傜乛  劆  仺 z+
                        //        劆乛    劆
                        //        劋劅劅劅劊
                        // (_z1,_x1)      (_z2,_x1)
                        //            伀 x-
                        dX2 = (_x - (pOther->_x + pPrism->_hdx));
                        dY2 = (_y - (pOther->_y               ));
                        dZ2 = (_z - (pOther->_z - pPrism->_hdz));
                    } else if (pos_prism & POS_PRISM_pn) {
                        //            仾 x+
                        // (_z1,_x2)      (_z2,_x2)
                        //        劇劅劅劅劉
                        //        劆    乛劆
                        // z- 仼  劆  乛偙劆  仺 z+
                        //        劆乛偪傜劆
                        //        劋劅劅劅劊
                        // (_z1,_x1)      (_z2,_x1)
                        //            伀 x-
                        dX2 = (_x - (pOther->_x - pPrism->_hdx));
                        dY2 = (_y - (pOther->_y               ));
                        dZ2 = (_z - (pOther->_z + pPrism->_hdz));
                    } else { // 偺偙傝偼 POS_PRISM_nn
                        //            仾 x+
                        // (_z1,_x2)      (_z2,_x2)
                        //        劇劅劅劅劉
                        //        劆乢    劆
                        // z- 仼  劆偙乢  劆  仺 z+
                        //        劆偪傜乢劆
                        //        劋劅劅劅劊
                        // (_z1,_x1)      (_z2,_x1)
                        //            伀 x-
                        dX2 = (_x - (pOther->_x - pPrism->_hdx));
                        dY2 = (_y - (pOther->_y                ));
                        dZ2 = (_z - (pOther->_z - pPrism->_hdz));
                    }
                } else {

                }
            } else {
                //僾儕僘儉埲奜偺暻
                dX2 = (_x - pOther->_x);
                dY2 = (_y - pOther->_y);
                dZ2 = (_z - pOther->_z);
            }
        } else {
            GgafDxCollisionArea* pCollisionArea = pOther->_pChecker->_pCollisionArea;
            if (pCollisionArea->_hit_colli_part_index >= 0) {
                GgafDxCollisionPart* pPart = pCollisionArea->_papColliPart[pCollisionArea->_hit_colli_part_index];
                dX2 = (_x - (pOther->_x + pPart->_cx));
                dY2 = (_y - (pOther->_y + pPart->_cy));
                dZ2 = (_z - (pOther->_z + pPart->_cz));
            } else {
                dX2 = (_x - pOther->_x);
                dY2 = (_y - pOther->_y);
                dZ2 = (_z - pOther->_z);
            }
        }

        if (dX2 == 0 && dY2 == 0 && dZ2 == 0) {
            vx2 = vy2 = vz2 = 0;
        } else {
            UTIL::getNormalizedVector(dX2, dY2, dZ2,
                                     vx2, vy2, vz2 );
        }

        float vx3, vy3, vz3;
        UTIL::getNormalizedVector(
                    vx1+vx2, vy1+vy2, vz1+vz2,
                    vx3, vy3, vz3);
        setBlownVelo(vx3*PX_C(40), vy3*PX_C(40), vz3*PX_C(40), 0.8);
        setInvincibleFrames(120);
    }
    if (pOther->getKind() & KIND_ITEM)  {
    } else {
        UTIL::activateExplosionEffectOf(this);
        getSeTransmitter()->play3D(SE_DAMAGED);
    }
}


void MyShip::setMoveSpeed(velo prm_speed_velo) {
    //lv_MoveSpeed_ = lv;
    //mv_speed_ = PX_C(lv);
    mv_speed_ = prm_speed_velo;
    veloBeginMT_ = mv_speed_ * 20;
}

void MyShip::onCatchEvent(hashval prm_no, void* prm_pSource) {
}

void MyShip::setBlownVelo(velo prm_blown_veloX, velo prm_blown_veloY, velo prm_blown_veloZ, double prm_r_blown_velo_attenuate) {
    blown_veloX_ += prm_blown_veloX;
    blown_veloY_ += prm_blown_veloY;
    blown_veloZ_ += prm_blown_veloZ;
    r_blown_velo_decay_ = prm_r_blown_velo_attenuate;
}

void MyShip::setInvincibleFrames(int prm_frames) {
    setHitAble(false);
    invincible_frames_ = prm_frames;
}
int MyShip::getMoveWay() {
    VirtualButton* pVbPlay = VB_PLAY;
    int pos_camera = P_VAM->getPosCam();
    int way = 0;
    int sgn_x = 0;
    int sgn_y = 0;
    int sgn_z = 0;


    if (pVbPlay->isPressed(VB_RIGHT)) {
        sgn_x = 1;
    }
    if (pVbPlay->isPressed(VB_LEFT)) {
        sgn_x = -1;
    }

    switch (pos_camera) {
        case VAM_POS_ZRIGHT: {
            if (pVbPlay->isPressed(VB_UP)) {
                sgn_y = 1;
            }
            if (pVbPlay->isPressed(VB_DOWN)) {
                sgn_y = -1;
            }
            break;
        }
        case VAM_POS_ZRIGHT_UP: {
            if (pVbPlay->isPressed(VB_UP)) {
                sgn_y = 1;
                sgn_z = 1;
            }
            if (pVbPlay->isPressed(VB_DOWN)) {
                sgn_y = -1;
                sgn_z = -1;
            }
            break;
        }
        case VAM_POS_UP: {
            if (pVbPlay->isPressed(VB_UP)) {
                sgn_z = 1;
            }
            if (pVbPlay->isPressed(VB_DOWN)) {
                sgn_z = -1;
            }
            break;
        }
        case VAM_POS_ZLEFT_UP: {
            if (pVbPlay->isPressed(VB_UP)) {
                sgn_y = -1;
                sgn_z = 1;
            }
            if (pVbPlay->isPressed(VB_DOWN)) {
                sgn_y = 1;
                sgn_z = -1;
            }
            break;
        }
        case VAM_POS_ZLEFT: {
            if (pVbPlay->isPressed(VB_UP)) {
                sgn_y = -1;
            }
            if (pVbPlay->isPressed(VB_DOWN)) {
                sgn_y = 1;
            }
            break;
        }
        case VAM_POS_ZLEFT_DOWN: {
            if (pVbPlay->isPressed(VB_UP)) {
                sgn_y = -1;
                sgn_z = -1;
            }
            if (pVbPlay->isPressed(VB_DOWN)) {
                sgn_y = 1;
                sgn_z = 1;
            }
            break;
        }
        case VAM_POS_DOWN: {
            if (pVbPlay->isPressed(VB_UP)) {
                sgn_z = -1;
            }
            if (pVbPlay->isPressed(VB_DOWN)) {
                sgn_z = 1;
            }
            break;
        }
        case VAM_POS_ZRIGHT_DOWN: {
            if (pVbPlay->isPressed(VB_UP)) {
                sgn_y = 1;
                sgn_z = -1;
            }
            if (pVbPlay->isPressed(VB_DOWN)) {
                sgn_y = -1;
                sgn_z = 1;
            }
            break;
        }
    }
    return DIR26(sgn_x, sgn_y, sgn_z);
}

void MyShip::moveNomal(dir26 prm_way) {
    float vx,vy,vz;
    GgafDx26DirectionUtil::cnvDirNo2Vec(prm_way, vx, vy, vz);
    _x += mv_speed_ * vx;
    _y += mv_speed_ * vy;
    _z += mv_speed_ * vz;
    if (is_just_change_way_) {
        angle rz, ry;
        GgafDx26DirectionUtil::cnvDirNo2RzRy(prm_way, rz, ry);
        getKuroko()->setRzRyMvAng(rz, ry);
        //慁夢

        int sgn_turn = SGN(pSenakai_[prm_way]);
        if (sgn_turn != 0) {
            getKuroko()->setFaceAngAcce(AXIS_X, sgn_turn*angRxAcce_MZ_);
            getKuroko()->setStopTargetFaceAng(AXIS_X, pSenakai_[prm_way],
                                              //sgn_turn > 0 ? TURN_COUNTERCLOCKWISE : TURN_CLOCKWISE,
                                              TURN_CLOSE_TO,
                                              angRxTopVelo_MZ_);
        }
    }
}

void MyShip::moveTurbo(dir26 prm_way) {
    float vx,vy,vz;
    GgafDx26DirectionUtil::cnvDirNo2Vec(prm_way, vx, vy, vz);
    pAxsMver_->addVxMvVelo(veloBeginMT_ * vx);
    pAxsMver_->addVyMvVelo(veloBeginMT_ * vy);
    pAxsMver_->addVzMvVelo(veloBeginMT_ * vz);

    angle rz, ry;
    GgafDx26DirectionUtil::cnvDirNo2RzRy(prm_way, rz, ry);
    getKuroko()->setRzRyMvAng(rz, ry);

    //慁夢
    angle senkai = pSenakai_[prm_way];
    if (senkai != 0) {
        double senkai_spin_speed_rate = (1.0 * D90ANG / senkai); //慁夞帪丄90搙-90搙偵孹偔応崌 1.0丄1.0 偲側傞丅
        getKuroko()->setRollFaceAngVelo(angRxVelo_BeginMZT_ * senkai_spin_speed_rate);
    }
}

MyShip::~MyShip() {
    GGAF_DELETE(pAxsMver_);
}


