void Enemy::update() { switch (state_) { case game::Enemy::State::Walk: walk(); break; case game::Enemy::State::Attack: attack(); break; case game::Enemy::State::Rush: Rush(); break; case game::Enemy::State::Back: back(); break; default: break; } distanceCheck(); //lifeが半分以下になると凶暴な肘攻撃 if (life_ < lifeMax_ / 2 && state_ == State::Walk) { anim_.setAnimation(2, 0.3f); kuma_.setSrcY(2); kuma_.setVelocity(ci_ext::Vec3f(-4 * speed_, 0.f, 0.f)); state_ = State::Rush; } anim_.update(); kuma_.update(); }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, CONSTmxArray *prhs[]) { static psych_bool firstTime=1,deferAvailable; long priorityLevel=-1; double a; Stuff stuff; psych_bool isString,oldMatlabBackgrounding; plhs; InitMEX(); isString=nrhs>0 && (mxIsChar(prhs[0]) || mxIsCell(prhs[0])); if(nlhs>1 || nrhs<1 || nrhs>2 || (isString && nlhs>0))PrintfExit("Usage:\n\n%s",useRush); switch(nrhs){ case 2: a=mxGetScalar(prhs[1]); if(a!=0 && a!=0.5 && a!=1 && a!=2 && a!=3 && a!=4 && a!=5 && a!=6 && a!=7) PrintfExit("Illegal priorityLevel %.1f. Must be 0, 0.5, 1, 2, 3, 4, 5, 6, or 7. Usage:\n%s",a,useRush); priorityLevel=a; if(a==0.5)priorityLevel=-1; case 1: if(!isString){ // special case: get an array of timings double s,s0; long j; stuff.getTimes=mxGetScalar(prhs[0]); if(stuff.getTimes<1) PrintfExit("The first argument must be either a string (or strings) or a number."); plhs[0]=mxCreateDoubleMatrix(1,stuff.getTimes,mxREAL); if(plhs[0]==NULL)PrintfExit("Couldn't allocate %ld element array.",stuff.getTimes); stuff.mxTimes=plhs[0]; stuff.iterations=10000; s=Seconds(); s=Seconds(); s0=Seconds()-s; s=Seconds(); for(j=0;j<stuff.iterations;j++) ; s=Seconds()-s-s0; stuff.iterations=(0.001-s0)*stuff.iterations/s; // That many iterations plus a call to Seconds() should take 1 ms. }else stuff.getTimes=0; break; } if(1){ // concatenate array or cell array of strings int error=0; mxArray *out,*in; in=(mxArray *)prhs[0]; error=mexCallMATLAB(1,&out,1,&in,"CatStr"); // Psychtoolbox:PsychOneliners:CatStr.m stuff.mxString=out; }else{ stuff.mxString=prhs[0]; } stuff.trapErrors=1; stuff.error=0; #if TARGET_OS_MAC if(CanControlMatlabBackgrounding()){ oldMatlabBackgrounding=MatlabBackgrounding(0); }else{ if(firstTime){ // Backgrounding is dangerous. Matlab would give time to another process while priority is raised. // Checking the enabled flag (on the disk) is slow, so we only do it once if backgrounding's off. But // if it's on, we give an error, and check again next time. if(IsMatlabBackgroundingEnabled()){ PrintfExit("Rush: please turn off Matlab's \"Backgrounding\" Preference, in the File menu.\n"); }else firstTime=0; } } #endif mexEvalString("lasterr('');"); Rush(priorityLevel,&fun,&stuff); if(CanControlMatlabBackgrounding())MatlabBackgrounding(oldMatlabBackgrounding); if(stuff.error)mexErrMsgTxt("mexCallMATLAB error during Rush"); // never happens { // if there's a message in LASTERR, print it as an error, with a preface int nlhs=1,nrhs=0,error=0; mxArray *plhs[1]={NULL},*prhs[1]={NULL}; char string[512]="Error during Rush: ",*errorMsg; errorMsg=string+strlen(string); error=mexCallMATLAB(nlhs,plhs,nrhs,prhs,"lasterr"); error=mxGetString(plhs[0],errorMsg,sizeof(string)-strlen(string)); if(strlen(errorMsg)>0)mexErrMsgTxt(string); } }