Ejemplo n.º 1
0
 public void GetHit(AttkData hit)
 {
     float scV = 1;
     stats.motion.vel.x=Mathf.Cos(hit.dir)*scV;
     stats.motion.vel.y=Mathf.Sin(hit.dir)*scV;
     atkTmr.ResetTimer();
     float stunT = hit.mag/2;
     if(stunT>1)
         stunT=1;
     stunTmr.SetTimer(stunT);
     Idle();
 }
Ejemplo n.º 2
0
 public plProjectile()
 {
     dbgBox = null;
     hitdata = new AttkData ();
     active=false;
     vNum = V_NUM;
     pScale = 1.0f;
     v = new SPoint[V_NUM];
     ang = new float[V_NUM];
     v[0]=new SPoint(0,  1);
     v[1]=new SPoint(-0.71f, .71f);
     v[2]=new SPoint(-1, 0);
     v[3]=new SPoint(-0.71f,-0.71f);
     v[4]=new SPoint(0, -1);
     v[5]=new SPoint(0.71f,-0.71f);
     v[6]=new SPoint(1, 0);
     v[7]=new SPoint(0.71f,0.71f);
     ttl = new STimer ();
     for(int j = 0; j < vNum-1; j++)
         ang[j] = Mathf.Atan2(v[j+1].y - v[j].y, v[j+1].x - v[j].x); //store angles for detection
     ang[V_NUM-1] = Mathf.Atan2(v[0].y - v[vNum-1].y, v[0].x - v[vNum-1].x);
 }
Ejemplo n.º 3
0
    protected virtual void Attack(Fighter plr,int tr, AttkTrack aBox, AttkData data)
    {
        //pHit is a bool array of flags that tell whether a sub-poly held collision
        //aBox is a modified track taken from current frame
        //plr is the player hit
        //check pnum else we cut Serenuity's sword
        if((plr.stats.id.num<100)&&(attackBox.trackList[fHelper.atkType].hit[tr][plr.stats.id.num])){//if this attack was recorded already
            data.noHit=true; //flag so this does not trigger impact
            return;//don't hit again
        }
        attackBox.trackList[fHelper.atkType].hit[tr][plr.stats.id.num]=true;

        bool isInBox=false;
        bool vNextInBox=false;
        AttkVtx iVt;
        bool[] cornerFlag = new bool[4];
        SPoint[] hb = plr.GetHitBox();// double[4]
        for(int i=0;i<4;i++){
            cornerFlag[i]=true;
            hb[i].x = hb[i].x-GetPos().x;//translate to origin
            hb[i].y = hb[i].y-GetPos().y;
        }
        bool emptyFlag = true;
        bool fullFlag =true;//assume true, disprove by counterexample
        SPoint vPos = new SPoint ();
        SPoint opp = new SPoint();
        int vNext,vLast,jl, il;
        float nX, nY, lY=0, lX=0, vX, vY, ppX, ppY, ph2, pw2, diDist,vDir, vDmg, vMag, vWgt = 0;
        //add poitional value (for wgt=0) into data
        opp.x=plr.GetPos().x-GetPos().x;//used to store the centerpoint
        if(fHelper.IsFacingRight())      //for input into data
            opp.x-=(aBox.centre.pos.x);
        else
            opp.x+=(aBox.centre.pos.x);
        opp.y=plr.GetPos().y-GetPos().y+aBox.centre.pos.y;
        data.SetAVals(opp);
        il = aBox.iLength;
        //set data.abds as an sPoint holding the vertices for aBox.vtx
        //this is done purely for debug rendering
        //which will later handle 'data'
        data.aBds = new SPoint[il][];
        for(int j=0;j<il;j++){
            data.aBds[j] = new SPoint[aBox.GetJlength(j)];
            for(int i=0;i<aBox.GetJlength(j);i++)
                data.aBds[j][i] = new SPoint(aBox.aVtx[j][i].pos.x-GetPos().x, aBox.aVtx[j][i].pos.y-GetPos().y);
        }

        emptyFlag=true;
        fullFlag=true;
        ph2 = plr.stats.size.y/2;
        pw2 = plr.stats.size.x/2;
        ppX = plr.GetPos().x;
        ppY = plr.GetPos().y+ph2;
        for(int i=0;i<4;i++)//assume true then prove false
            cornerFlag[i]=true;
        for(int p=0; p<aBox.iLength;p++){
            jl = aBox.GetJlength(p);
            for(int v = 0; v < jl;v++){//loop through the second index
                vPos = aBox.aVtx[p][v].pos;//use this vertex to check whether it falls
                if((Mathf.Abs(vPos.x-ppX)<pw2)&&(Mathf.Abs(vPos.y-ppY)<ph2))// within hitbox
                    emptyFlag = false;//can't be empty
                else
                    fullFlag = false;//can't be full
            }
            if(fullFlag){
                for(int v = 0; v < jl;v++){
                    int before = v-1;
                    if(before<0)
                        before=jl-1;
                    diDist = Mathf.Sqrt(Mathf.Pow(aBox.aVtx[p][before].pos.x-aBox.aVtx[p][v].pos.x, 2) + Mathf.Pow(aBox.aVtx[p][before].pos.y-aBox.aVtx[p][v].pos.y, 2));
                    vMag = aBox.aVtx[p][v].mag;
                    vDir = aBox.aVtx[p][v].dir;
                    vDmg = aBox.aVtx[p][v].dmg;
                    vWgt = aBox.aVtx[p][v].wgt;
                    data.addVal(aBox.aVtx[p][v].pos, vMag, vDir, diDist, vDmg, vWgt);
                    for(int i=0;i<4;i++)
                        cornerFlag[i]=false;//none possible to be included
                }
            }
            else if(emptyFlag){
                for(int j = 0;j<jl;j++){
                    diDist=1;
                    vMag = aBox.aVtx[p][j].mag;
                    vDir = aBox.aVtx[p][j].dir;
                    vDmg = aBox.aVtx[p][j].dmg;
                    vWgt = aBox.aVtx[p][j].wgt;
                    vPos = aBox.aVtx[p][j].pos;
                    vPos.x-=GetPos().x;
                    vPos.y-=GetPos().y;
                    data.addVal(vPos, vMag, vDir, diDist, vDmg, vWgt);
                }
            }
            else
            for(int v = 0; v < jl;v++){
                vNext = (v+1)%jl;//circular array
                vPos = aBox.aVtx[p][vNext].pos;
                vNextInBox = ((Mathf.Abs(vPos.x-ppX)<pw2)&&(Mathf.Abs(vPos.y-ppY)<ph2));
                vLast=v-1;
                if(vLast<0)
                    vLast=jl-1;
                vMag = aBox.aVtx[p][v].mag;
                vDir = aBox.aVtx[p][v].dir;
                vDmg = aBox.aVtx[p][v].dmg;
                vWgt = aBox.aVtx[p][v].wgt;
                vPos = aBox.aVtx[p][v].pos;
                vX = aBox.aVtx[p][v].pos.x-GetPos().x;//all values translated to origin
                vY = aBox.aVtx[p][v].pos.y-GetPos().y;
                if(v==0){
                    lX=vX;//mustdefine these ahead of time
                    lY=vY;//so the first dir is properly averaged
                }     //in case the loop below is not entered
                if((Mathf.Abs(vPos.x-ppX)<pw2)&&(Mathf.Abs(vPos.y-ppY)<ph2)){//within the victim's hitbox
                    diDist = Mathf.Sqrt( (lX-vX)*(lX-vX) + (lY-vY)*(lY-vY));
                    data.addVal(new SPoint(vX, vY), vMag, vDir, diDist, vDmg, vWgt);
                    lX=vX;
                    lY=vY;
                    if(!vNextInBox){
                        iVt = InterpVert(aBox.aVtx[p][v], aBox.aVtx[p][vNext], plr);
                        iVt.pos.x-=GetPos().x;//all values translated to origin
                        iVt.pos.y-=GetPos().y;
                        diDist = Mathf.Sqrt(Mathf.Pow(iVt.pos.x-vX, 2)+Mathf.Pow(iVt.pos.y-vY, 2));
                        data.addVal(iVt.pos, iVt.mag, iVt.dir, diDist, iVt.dmg, iVt.wgt);
                        lX=iVt.pos.x;
                        lY=iVt.pos.y;
                    }
                }
                else {
                    if(vNextInBox){
                        iVt = InterpVert(aBox.aVtx[p][vNext], aBox.aVtx[p][v], plr);
                        iVt.pos.x-=GetPos().x;//all values translated to origin
                        iVt.pos.y-=GetPos().y;
                        diDist = Mathf.Sqrt(Mathf.Pow(iVt.pos.x-lX, 2)+Mathf.Pow(iVt.pos.y-lY, 2));
                        data.addVal(iVt.pos, iVt.mag, iVt.dir, diDist, iVt.dmg, iVt.wgt);
                        lX=iVt.pos.x;
                        lY=iVt.pos.y;
                    }
                }
                for(int i = 0; i<4;i++){//check player corner axis
                    vX = aBox.aVtx[p][v].pos.x-GetPos().x-hb[i].x;//all values translated to origin
                    vY = aBox.aVtx[p][v].pos.y-GetPos().y-hb[i].y;
                    nX = aBox.aVtx[p][vNext].pos.x-GetPos().x-hb[i].x;
                    nY = aBox.aVtx[p][vNext].pos.y-GetPos().y-hb[i].y;
                    if((fHelper.IsFacingRight())&&(nX*vY-vX*nY<0))//second part is a shortcut formula
                        cornerFlag[i]=false;
                    else if((!fHelper.IsFacingRight())&&(nX*vY-vX*nY>0))
                        cornerFlag[i]=false;
                }
            }
            //last step; add corners that retained their flag
            if(emptyFlag){//for now ; TODO: add case later
                for(int i=0;i<4;i++)
                if(cornerFlag[i]){
                    iVt = InterpCorner(aBox.aVtx[p], aBox.GetJlength(p), plr.GetPos());
                    iVt.pos.x-=GetPos().x;//all values translated to origin
                    iVt.pos.y-=GetPos().y;
                    diDist = Mathf.Sqrt(Mathf.Pow(iVt.pos.x-lX, 2)+Mathf.Pow(iVt.pos.y-lY, 2));
                    data.addVal(iVt.pos, iVt.mag, iVt.dir, diDist, iVt.dmg,iVt.wgt);
                    lX=iVt.pos.x;
                    lY=iVt.pos.y;
                }
            }
        }

        data.rollIntoAvg();
        if (attackBox.trackList [fHelper.atkType].isVacuum) {
            data.isVacuum=true;
        }

        data.SetConOrigin(aBox.centre.pos);
        data.PlayerHitBoxInput(hb);
    }
Ejemplo n.º 4
0
    public virtual void AttackDetect(Fighter plr)
    {
        bool multiHitFlag = false;
        string hitText;
        //std::stringstream log;
        bool hitflag = true;
        int atkLen;
        int spI=0;
        int spJ=0;
        int hbLen=4;
        SPoint[] plBox;
        SPoint[][] spBox;
        float[] plAng ={0, Mathf.PI/2, Mathf.PI, -Mathf.PI/2};
        int il = 0;
        if (fHelper.atkType  == GRAB)
             il = 1;
        else
            il = attackBox.trackList[fHelper.atkType].iLength;//num of tracks
        AttkTrack aBox = new AttkTrack();

        int polyHit=-1;
        plBox = plr.GetHitBox();//loads victim hitbox into plBox
        //each side is made from the vertices [i] and [+1]
        int numPoly = 0; //number of polygons in a track;
        int pInd = 0;//polygon index
        SPoint[] pHdr = new SPoint[8];

        //projectile checks
        for(int p=0;p<PROJ_LMT;p++){
            if(projectile[p].active){
                for(int i=0;i<8;i++)
                    pHdr[i]=new SPoint(projectile[p].v[i].x+projectile[p].pos.x,projectile[p].v[i].y+projectile[p].pos.y);
                atkLen =  projectile[p].GetVNum();
                for(int j = 0; j < atkLen; j++)
                    if(!CheckAxis(pHdr[0], projectile[p].ang[j], plBox, pHdr, hbLen, projectile[p].GetVNum()) ) //no axis intersection
                        hitflag = false;

                if(hitflag)//test on the axis of the player hit box to confirm
                    for(int j = 0; j < 4; j++)
                        if(!CheckAxis(plBox[j], plAng[j], plBox, pHdr, hbLen, projectile[p].GetVNum())) //no axis intersection
                            hitflag = false;
                if(hitflag){
                    projectile[p].active=false;
                    plr.GetHit(projectile[p].hitdata);
                }

            }
        }
        if(!atkTmr.IsReady()){//only continue if an attack is out
            if(fHelper.atkType==GRAB){
                aBox= new AttkTrack();
                aBox.noHit=false;
                float gCheck = grabTime/fHelper.actionTmr.GetLen();
                float fCheck = fHelper.frame/fHelper.actionTmr.GetLen();
                if(Mathf.Abs(fCheck-gCheck)<Time.deltaTime){

                    aBox.SetGrabBox(GetPos (), stats.grabRange);

                    float[] atAng = new float[4];
                    atAng[0]=0;
                    atAng[1]=Mathf.PI/2;
                    atAng[2]=Mathf.PI;
                    atAng[3]=-Mathf.PI/2;
                    //for(pInd=0;pInd<numPoly;pInd++)//iterate per poly
                    atkLen =  4;
                    hitflag=true;
                    attackBox.grabRange= stats.grabRange;
                    SPoint[] spArr = attackBox.FetchGrabRenderFrame(fHelper.frame, GetPos (), fHelper.IsFacingRight());

                    for(int j = 0; j < atkLen; j++)
                        if(!CheckAxis(spArr[j], atAng[j], plBox, spArr, hbLen, atkLen) ) //no axis intersection
                            hitflag = false;

                    if(hitflag)//test on the axis of the player hit box to confirm
                        for(int j = 0; j < 4; j++)
                            if(!CheckAxis(plBox[j], plAng[j], plBox, spArr, hbLen, atkLen)) //no axis intersection
                                hitflag = false;

                    if(hitflag){//hit
                        if(plr.grabbedPlr!=null){
                            plr.grabbedPlr. state=IDLE;
                            plr.grabbedPlr.Idle();
                            plr.grabbedPlr.fHelper.Animate ("Idle", true, 0);
                            plr.fHelper.Animate ("Idle", true, 0);
                            plr.grabbedPlr.stats.flags.mBusy=false;
                            plr.grabbedPlr.stats.flags.aBusy=false;
                            plr.grabbedPlr=null;
                            Idle();
                            fHelper.Animate ("Idle", true, 0);

                        }
                        else if(plr.stats.dodge.IsReady()){
                        grabbedPlr=plr;
                            plr.Grabbed ();}
                    }
                }

            }else{
            //attack checks

            for(int t=0;t<il;t++){//iterate through all sub tr

                //if(plr.CharName().CompareTo("PsySword")==0)
                //	int ds=2;//checkpt
                if((fHelper.seqInd!=0)&&((fHelper.seqInd-1)!=t)){
                    hitflag=false;//do nothing, for now
                }else {
                    aBox= new AttkTrack();
                    aBox.noHit=false;
                        if(attackBox.trackList[fHelper.atkType].trackType==AttkBox.FLASH){
                            if(fHelper.frame>lastFlash){

                                for(AttkVtx av = attackBox.trackList[fHelper.atkType].aVtx[0][0]; av!=null;av=av.next){
                                    if((av.frame==lastFlash)&&(av.next!=null)){
                                        lastFlash=av.next.frame;
                                        attackBox.flashAtkRdy=true;
                                        attackBox.ResetHits (fHelper.atkType);
                                        while(av.next!=null)
                                            av=av.next;
                                        //av=null;//force exit
                                    }
                                }
                            }
                        }
                    attackBox.FetchFrame(fHelper.atkType, atkTmr.GetLen(), fHelper.frame, t, new SPoint(GetPos().x, GetPos().y), fHelper.IsFacingRight(), aBox);//fetches frame into aBox

                        //aBox has its polygons separated into different tracks for efficiency
                    //make a new SPoint array, spBox, to use checkAxis.

                    hitflag=true;
                    if(aBox.noHit==false){

                        //if(plr.CharName().CompareTo("PsySword")==0)
                        //	int d2s=2;//checkpt
                        spBox=new SPoint[aBox.iLength][];
                        for(int i=0;i<aBox.iLength;i++)
                            spBox[i]=new SPoint[aBox.jLength[i]];
                        aBox.FetchSPArr(spBox);
                            if(ClashCheck(plr, spBox, aBox.atkAng)){

                                return;
                            }

                        numPoly=aBox.iLength;
                            bool hitCheck = false;
                        for(pInd=0;pInd<numPoly;pInd++){//iterate per poly
                                hitflag=true;
                            atkLen =  aBox.GetJlength(pInd);
                            for(int j = 0; j < atkLen; j++)
                                if(!CheckAxis(aBox.aVtx[pInd][j].pos, aBox.atkAng[pInd][j], plBox, spBox[pInd], hbLen, aBox.GetJlength(pInd)) ) //no axis intersection
                                    hitflag = false;

                            if(hitflag)//test on the axis of the player hit box to confirm
                                for(int j = 0; j < 4; j++)
                                    if(!CheckAxis(plBox[j], plAng[j], plBox, spBox[pInd], hbLen, aBox.GetJlength(pInd))) //no axis intersection
                                        hitflag = false;
                            if(hitflag)
                                    hitCheck=true;

                        }
                            hitflag=hitCheck;
                        //log.str(std::string());
                        /*	for(int i=0;i<aBox.iLength;i++){//tidy up
                            if(!aBox.noHit)
                                delete [] spBox[i];
                        }
                        if(aBox.iLength==0){
                            int ee = 2;
                            //log.str(std::string());
                        }
                        else if(!aBox.noHit){//make sure it was hit
                            if(aBox.iLength>1)
                                delete [] spBox;
                            else
                                delete spBox;
                            spBox=NULL;
                        }*/
                    }else
                        hitflag=false;//abandon
                    if(hitflag){
                        AttkData retOb  = new AttkData(aBox.GetJlength(t));//initilize for holding vals
                        Attack(plr, t, aBox, retOb);
                        if(!retOb.noHit){
                                if(debugModeOn){
                                if(multiHitFlag)
                                    hitText = CharName() + " multi-hit\r\n" + plr.CharName() + "!";
                                else
                                    hitText =  CharName() + " hit \r\n" + plr.CharName() + "!";
                                ConsoleLog(hitText);
                                }
                            plr.GetHit(retOb);
                            if((cons!=null)&&(!multiHitFlag)&&(retOb!=null))
                                cons.PostHit(retOb.GetSPArr(), retOb.curInd, retOb.aBds[0], retOb.attLen, retOb.pBds, retOb.GetConOrigin(), retOb.GetConInter());
                            multiHitFlag=true;
                            t=il;//force exit; one track hit
                        }
                    }

                    }

                }
            }
        }
        //seems the ideal place to determine pushback
        //if the difference in z is less than their average width
        if((Mathf.Abs(plr.GetPos().x-GetPos().x) < (plr.stats.size.x+stats.size.x)/2  )
           &&(Mathf.Abs(plr.GetPos().y-GetPos().y) < (plr.stats.size.y+stats.size.y)/2)
           &&(!fHelper.airborne)&&(!plr.fHelper.airborne))
        if(plr.GetPos().x-GetPos().x>0){
            stats.motion.move.x-=0.1f;
            plr.stats.motion.move.x+=0.1f;}
        else{
            stats.motion.move.x+=0.1f;
            plr.stats.motion.move.x-=0.1f;}

        //prob at a second case here for seren sword
        //	if(plr.CharName().CompareTo("Serenity")==0){
        //		AttackDetect(plr.GetFamiliar());
        //	}
        if (fHelper.atkType == DATK) {
            if ((rightLip != 0) && (stats.motion.pos.x < rightLip)) {
                stats.motion.vel.x = 0;
                stats.walk.gndSpeed = 0;

            } else if ((leftLip != 0) && (stats.motion.pos.x > leftLip)) {
                stats.motion.vel.x = 0;
                stats.walk.gndSpeed = 0;
            }
        }
    }
Ejemplo n.º 5
0
    public virtual void ThrowMotion(int tType, float dmg, float dir, float mag)
    {
        //basic throw
        if(grabbedPlr==null)
            return;//no throw
        float diff = 0;
        if (!fHelper.IsFacingRight()) {
            diff = ((Mathf.PI / 2) - dir) * 2.0f;
            dir += diff;
        }
        AttkData thr = new AttkData();
        thr.dmg=dmg;
        thr.dir=dir;
        thr.mag=mag;
        thr.isThrow = true;
        //felper.Animate("Throw", false, 0);

        grabbedPlr.GetHit(thr);
        grabbedPlr.stats.tumble.tmr.SetTimer (1.0f);
        grabbedPlr.transform.localEulerAngles = NORM_ORIENT;
        grabbedPlr.stats.flags.mBusy = false;
        grabbedPlr.stats.flags.aBusy = false;
        grabbedPlr. state =  FALL;
        SPoint rPos = new SPoint(GetPos ().x, GetPos().y);
        //if (Mathf.Sin (thr.dir) < 0)
        //	rPos.x -= stats.size.x;
        //else if (Mathf.Sin (thr.dir) > 0)
        //	rPos.x += stats.size.x;
        rPos.y += 4.0f;
        grabbedPlr.RePosition(rPos);
        grabbedPlr.stats.motion.lastPos = new SPoint(grabbedPlr.stats.motion.lastPos.x, grabbedPlr.stats.motion.lastPos.y+1.0f);
        grabbedPlr.fHelper.UnTranslate ();
        if(grabbedPlr.fHelper.IsFacingRight())
            grabbedPlr.fHelper.Orient(0);
        else
            grabbedPlr.fHelper.Orient(180);
        grabbedPlr = null;
        stats.flags.aBusy = false;
    }
Ejemplo n.º 6
0
    public void TakeHit(AttkData hit)
    {
        float dmgScale = 1.0f;
        if (stats.defence != 0)
            dmgScale = stats.damage / stats.defence;

        float tumTime = 0.1f +(0.5f+hit.dmg/250.0f)*dmgScale;
        dmgScale++;
        if (hit.dmg * dmgScale > stats.tumble.thresh) {
            stats.tumble.tmr.SetTimer (tumTime);

            stats.flags.aBusy=true;
        }

        float uVel, vVel, xVel, yVel;
        uVel = magScale*hit.mag*Mathf.Cos(hit.dir);//this determines the height to move up to
        vVel = magScale*hit.mag*Mathf.Sin(hit.dir);//this determines rough distance

        if(uVel>0)
            xVel= Mathf.Sqrt(uVel*stats.grav);
        else
            xVel= -Mathf.Sqrt(-uVel*stats.grav);
        if(vVel>0)
            yVel = Mathf.Sqrt(vVel*2*stats.grav);
        else
            yVel = -Mathf.Sqrt(-vVel*2*stats.grav);
        yVel*=dmgScale;
        xVel*=dmgScale;

        //TurnCheck(xVel);
        if(Mathf.Abs(xVel) < 1.2f)
            stats.walk.gndSpeed=xVel*(1+stats.fric);
        else{
            yVel=Mathf.Abs(xVel)/3.0f;
            stats.motion.vel.y=yVel;
            stats.motion.vel.x=xVel;
            Fall();
        }
        if ((!fHelper.airborne)) {//Grounded down momentum changed to up
            if(yVel<0){
                yVel = -0.8f*yVel;
                fHelper.airborne=true;
            }
        }
        if ((fHelper.airborne) || (yVel > Mathf.Abs (xVel) + 0.1f)) {//check to see if the hit was
                fHelper.airborne = true; //hard enough to launch the player into
                rightLip = 0;
                leftLip = 0;
                stats.motion.vel.y = yVel; //airborne state
                stats.motion.vel.x = xVel;
                if (Mathf.Abs (xVel) > 2)
                        fHelper.Animate ("SentFlying", false, 0);
                else
                        fHelper.Animate ("Tumble", false, 0);
        }

        if (debugModeOn) {
            string log = "";
            log += CharName () + " hit!v(" + xVel + "," + yVel + ")m" + hit.mag + "d" + dmgScale;
            ConsoleLog (log);
        }

        dmgFlag = true;
    }
Ejemplo n.º 7
0
    public void Start()
    {
        //stats=new Stats();
        FindConsole ();
        hovTmr = new STimer(1.0f);
        hovDir = new SPoint(0, 0);
        hovFin = new SPoint(0, 0);
        hovRec = 1;
        dashTmr = new STimer(DASH_TIME);
        rollInvOn = new STimer ();
        rollInvOff = new STimer ();
        debugFadeTmr = new STimer (0.5f);
        atkTmr = new STimer ();
        NORM_ORIENT = new Vector3 (0, 90.0f, 0);
        if (debugModeOn)
            CreateColBox ();
        GameObject go;
        int pCt = 0;
        for (int i=1; i<5; i++) {
            go = GameObject.FindGameObjectWithTag ("Player" + i);
            if (go != null)
                pCt++;
            }
        hitHolder = null;
        stunTimer = new STimer ();
        fighterList = new Fighter[pCt-1];
        int plC=0;
        int otC = 0;
        go=new GameObject();
        for(int i=1;i<pCt+1;i++){
            go =  GameObject.FindGameObjectWithTag("Player"+i);
            if(go!=null){

                if(i!=plNum){
                    fighterList[otC]=go.GetComponent<Fighter>();
                    otC++;
                }
            plC++;
            }
        }
    }
Ejemplo n.º 8
0
    public void RunTimers(float timeLapsed)
    {
        dashTmr.RunTimer(timeLapsed);
        if (hovTmr.RunTimer(timeLapsed)) {
            hovDir.x = 0;
            hovDir.y = 0;
            hovFin.y = 0;
            hovFin.x = 0;
        }
        else if (!hovTmr.IsReady())
        {
            fHelper.airborne = true;
            float rat = hovTmr.tmr / hovTmr.GetLen();
            stats.motion.accl.y = stats.grav;
            stats.motion.vel.x = (1.0f-rat)*hovDir.x  + rat*hovFin.x;
            stats.motion.vel.y = (1.0f-rat) * hovDir.y + rat * hovFin.y;
            hovRec = 1;
        }
        if (stats.jump.tmr.RunTimer(timeLapsed)){
            if(!fHelper.airborne){
                Jump();
            }
        }
        if(stunTimer.RunTimer(timeLapsed)){
            if(hitHolder!=null)
                TakeHit (hitHolder);
            hitHolder=null;
        }
        if(!debugFadeTmr.IsReady()){
            if(debugFadeTmr.RunTimer (timeLapsed))
                Destroy (attkHitbox);
        }
        if(rollInvOn.RunTimer(timeLapsed)){
            rollInvOff.SetTimer();
            stats.flags.invuln=true;

        }if (rollInvOff.RunTimer (timeLapsed)) {
            stats.flags.invuln=false;
        }
        //attack timer
        atkTmr.RunTimer (timeLapsed);

        //edge timers
        if(stats.edgegrab.delayTmr.RunTimer(timeLapsed))
            fHelper.grabBox.isActive = true;

        if(InState( EDGEGRAB)){
            stats.motion.vel.y = 0;
            if((stats.edgegrab.edgeTmr.RunTimer(timeLapsed))||(gCont.lStick.y<-LOWTHRESH)){
                stats.flags.aBusy=false;
                stats.flags.mBusy=false;
                fHelper.UnTranslate();
                Fall();
                fHelper.grabBox.isActive = false;
                stats.motion.pos.y -= stats.edgegrab.hgt;
                stats.motion.vel.y = -4*stats.grav;
                stats.edgegrab.delayTmr.SetTimer();
                stats.edgegrab.edgeTmr.ResetTimer();
            }
        }else{
            if(stats.edgegrab.flag){//end of an edgegrab
                fHelper.grabBox.isActive = false;
                stats.edgegrab.flag = false;
                //fHelper.UnTranslate();
                //Translate(SPoint(0, stats.size.y));
                stats.edgegrab.delayTmr.SetTimer();
                stats.motion.pos.y-=stats.edgegrab.hgt;
                stats.motion.vel.y = -4*stats.grav;
            }
        }

            //timer to track pivoting between left/right
        if(stats.pivot.pTmr.tmr>0){
            if(stats.pivot.pTmr.RunTimer(timeLapsed))
                PivotEnd();
            else if (stats.pivot.slowPivot)
                fHelper.Pivot((0.25f*timeLapsed/stats.pivot.pTmr.GetLen())*180.0f);
            else
                fHelper.Pivot((timeLapsed/stats.pivot.pTmr.GetLen())*180.0f);
            }
        else if(stats.pivot.pTmr.tmr<0){
            if(stats.pivot.pTmr.RunTimer(timeLapsed))
                    PivotEnd();
            else if (stats.pivot.slowPivot)
                fHelper.Pivot(-0.25f*(timeLapsed/stats.pivot.pTmr.GetLen())*180.0f);
            else
                fHelper.Pivot(-(timeLapsed/stats.pivot.pTmr.GetLen())*180.0f);
            }
            if(stats.walk.shuffle.RunTimer(timeLapsed))
            stats.flags.running=true;

        if(Mathf.Abs(stats.walk.gndSpeed)<stats.walk.maxSpeed/2)
                stats.flags.running =false;
            //time between jump command and action (windup frames)

            //landing stuff added here
            if (stats.land.RunTimer (timeLapsed)) {
                        stats.flags.aBusy = false;
            stats.flags.mBusy=false;
                }
            //actiontimer
            //Timer(timeLapsed);

            //tumble timer
            if (!stats.tumble.tmr.IsReady()) {
                if (stats.tumble.tmr.RunTimer (timeLapsed))//stop anim + set state idle
                if(!fHelper.airborne)
                    GetUp ();
            } else
            stats.tumble.tmr.ResetTimer ();

            //dodge timer
            if(InState( DODGE)){
                stats.flags.invuln=true;
                if(stats.dodge.RunTimer(timeLapsed)){
                    stats.flags.invuln=false;
                    stats.flags.aBusy=false;
                    stats.flags.mBusy=false;
                     state=IDLE;
                    //Idle();

            }
        }

        //fHelper.RunTimers(timeLapsed);
    }
Ejemplo n.º 9
0
 public void OnGuard(AttkData hit)
 {
     stats.guard.arc-=hit.dmg/stats.defence;//formula for now
 }
Ejemplo n.º 10
0
    public void GetHit(AttkData hit)
    {
        //called when the player has taken a hit
        atkTmr.ResetTimer ();
        fHelper.nextAnim="";
        if (InState (EDGEGRAB)) {
                        state = FALL;
                        stats.edgegrab.delayTmr.SetTimer ();
                }
        //	int ifr = fHelper.IntFacingRight ();
        if (stats.flags.invuln)
                        return;//dodged
        else if (hit.isThrow) {
                        Grabbed ();
                } else if (InState (GUARD)) {
                        for (double r = -Mathf.PI; r<Mathf.PI*2; r+=Mathf.PI*2)//check all transforms
                                if ((hit.adir + r < stats.guard.dir + stats.guard.arc) && (hit.adir + r > stats.guard.dir - stats.guard.arc)) {
                                        OnGuard (hit);
                                        return;//attack blocked
                                }
                            stunTimer.SetTimer (hit.dmg*stunMult / stats.defence);

                } else {
            stunTimer.SetTimer (hit.dmg*stunMult / stats.defence);
        }
        hitHolder = hit;

        stats.damage+=hit.dmg;
        PlayEffect (EF_HIT);
        PlayGeneralSound ("hit");
        fHelper.Animate("Hit", false, 0);
        if (hit.isThrow)
                        TakeHit (hit);
        if (hit.isVacuum) {
            stats.motion.move.x = hit.cenPt.x;//-stats.motion.pos.x;
            stats.motion.move.y = hit.cenPt.y;//-stats.motion.pos.y;
        }

        //TakeHit (hit);
    }
Ejemplo n.º 11
0
    protected override void Attack(Fighter plr,int tr, AttkTrack aBox, AttkData data)
    {
        if(fHelper.atkType == SPA){

            data.isThrow = true;
            data.throwType=1;

            SpecGrab(plr);
        }else if(fHelper.atkType == UB){

            data.isThrow = true;
            data.throwType=1;
            fHelper.Animate("UB2", false, 0);
            SpecGrab(plr);
        }
        base.Attack (plr, tr, aBox, data);
    }
Ejemplo n.º 12
0
    public void GetHit(AttkData hit)
    {
        //called when the player has taken a hit
        if (!parryTmr.IsReady()) {
            effects[3].Play();
            parryTmr.ResetTimer();

            return;
        }
        atkTmr.ResetTimer ();
        fHelper.nextAnim="";

        if (stats.flags.invuln)
                        return;//dodged

        hitHolder = hit;

        stats.damage+=hit.dmg;
        //PlayEffect (EF_HIT);
        PlayGeneralSound ("hit");
        fHelper.Animate("Hit", false, 0);
        if (hit.isThrow)
                        TakeHit (hit);
        if (hit.isVacuum) {
            stats.motion.move.x = hit.cenPt.x;//-stats.motion.pos.x;
            stats.motion.move.y = hit.cenPt.y;//-stats.motion.pos.y;
        }
        PlayEffect(1);
        RePosition(new SPoint(startPos.x, startPos.y));
        //TakeHit (hit);
    }
Ejemplo n.º 13
0
    public virtual void AttackDetect(Ninja plr)
    {
        bool multiHitFlag = false;
        string hitText;
        //std::stringstream log;
        bool hitflag = true;
        int atkLen;
        int spI=0;
        int spJ=0;
        int hbLen=4;
        SPoint[] plBox;
        SPoint[][] spBox;
        float[] plAng ={0, Mathf.PI/2, Mathf.PI, -Mathf.PI/2};
        int il = 0;

            il = attackBox.trackList[fHelper.atkType].iLength;//num of tracks
        AttkTrack aBox = new AttkTrack();

        int polyHit=-1;
        plBox = plr.GetHitBox();//loads victim hitbox into plBox
        //each side is made from the vertices [i] and [+1]
        int numPoly = 0; //number of polygons in a track;
        int pInd = 0;//polygon index
        SPoint[] pHdr = new SPoint[8];

        il = 1;
        if(!atkTmr.IsReady()){//only continue if an attack is out

            //attack checks

            for(int t=0;t<il;t++){//iterate through all sub tr

                //if(plr.CharName().CompareTo("PsySword")==0)
                //	int ds=2;//checkpt
                if((fHelper.seqInd!=0)&&((fHelper.seqInd-1)!=t)){
                    hitflag=false;//do nothing, for now
                }else {
                    aBox= new AttkTrack();
                    aBox.noHit=false;
                        if(attackBox.trackList[fHelper.atkType].trackType==AttkBox.FLASH){
                            if(fHelper.frame>lastFlash){

                                for(AttkVtx av = attackBox.trackList[fHelper.atkType].aVtx[0][0]; av!=null;av=av.next){
                                    if((av.frame==lastFlash)&&(av.next!=null)){
                                        lastFlash=av.next.frame;
                                        attackBox.flashAtkRdy=true;
                                        attackBox.ResetHits (fHelper.atkType);
                                        while(av.next!=null)
                                            av=av.next;
                                        //av=null;//force exit
                                    }
                                }
                            }
                        }
                    attackBox.FetchFrame(fHelper.atkType, atkTmr.GetLen(), fHelper.frame, t, new SPoint(GetPos().x, GetPos().y), fHelper.IsFacingRight(), aBox);//fetches frame into aBox

                        //aBox has its polygons separated into different tracks for efficiency
                    //make a new SPoint array, spBox, to use checkAxis.

                    hitflag=true;
                    if(aBox.noHit==false){

                        //if(plr.CharName().CompareTo("PsySword")==0)
                        //	int d2s=2;//checkpt
                        spBox=new SPoint[aBox.iLength][];
                        for(int i=0;i<aBox.iLength;i++)
                            spBox[i]=new SPoint[aBox.jLength[i]];
                        aBox.FetchSPArr(spBox);
                            if(ClashCheck(plr, spBox, aBox.atkAng)){
                            SPoint p1Vel = new SPoint(GetPos().x - plr.GetPos().x, GetPos().y - plr.GetPos().y).GetNormal();
                            float cRat = 0.2f;
                            stats.motion.vel.x = p1Vel.x*cRat;
                            stats.motion.vel.y = p1Vel.y*cRat;
                            plr.stats.motion.vel.x = -p1Vel.x*cRat;
                            plr.stats.motion.vel.y = -p1Vel.y*cRat;
                            fHelper.airborne = true;
                            plr.fHelper.airborne = true;
                            return;
                            }

                        numPoly=aBox.iLength;
                            bool hitCheck = false;
                        for(pInd=0;pInd<numPoly;pInd++){//iterate per poly
                                hitflag=true;
                            atkLen =  aBox.GetJlength(pInd);
                            for(int j = 0; j < atkLen; j++)
                                if(!CheckAxis(aBox.aVtx[pInd][j].pos, aBox.atkAng[pInd][j], plBox, spBox[pInd], hbLen, aBox.GetJlength(pInd)) ) //no axis intersection
                                    hitflag = false;

                            if(hitflag)//test on the axis of the player hit box to confirm
                                for(int j = 0; j < 4; j++)
                                    if(!CheckAxis(plBox[j], plAng[j], plBox, spBox[pInd], hbLen, aBox.GetJlength(pInd))) //no axis intersection
                                        hitflag = false;
                            if(hitflag)
                                    hitCheck=true;

                        }
                            hitflag=hitCheck;
                        //log.str(std::string());
                        /*	for(int i=0;i<aBox.iLength;i++){//tidy up
                            if(!aBox.noHit)
                                delete [] spBox[i];
                        }
                        if(aBox.iLength==0){
                            int ee = 2;
                            //log.str(std::string());
                        }
                        else if(!aBox.noHit){//make sure it was hit
                            if(aBox.iLength>1)
                                delete [] spBox;
                            else
                                delete spBox;
                            spBox=NULL;
                        }*/
                    }else
                        hitflag=false;//abandon
                    if(hitflag){
                        AttkData retOb  = new AttkData(aBox.GetJlength(t));//initilize for holding vals
                        Attack(plr, t, aBox, retOb);
                        if(!retOb.noHit){

                            plr.GetHit(retOb);
                            multiHitFlag=true;
                            t=il;//force exit; one track hit
                        }

                    }

                }
            }
        }
        //seems the ideal place to determine pushback
        //if the difference in z is less than their average width
        if((Mathf.Abs(plr.GetPos().x-GetPos().x) < (plr.stats.size.x+stats.size.x)/2  )
           &&(Mathf.Abs(plr.GetPos().y-GetPos().y) < (plr.stats.size.y+stats.size.y)/2)
           &&(!fHelper.airborne)&&(!plr.fHelper.airborne))
        if(plr.GetPos().x-GetPos().x>0){
            stats.motion.move.x-=0.1f;
            plr.stats.motion.move.x+=0.1f;}
        else{
            stats.motion.move.x+=0.1f;
            plr.stats.motion.move.x-=0.1f;}
    }
Ejemplo n.º 14
0
    public void TakeHit(AttkData hit)
    {
        float dmgScale = 1.0f;
        if (stats.defence != 0)
            dmgScale = stats.damage / stats.defence;

        float tumTime = 0.1f +(0.5f+hit.dmg/250.0f)*dmgScale;
        dmgScale++;

        float uVel, vVel, xVel, yVel;
        uVel =hit.mag*Mathf.Cos(hit.dir);//this determines the height to move up to
        vVel = hit.mag*Mathf.Sin(hit.dir);//this determines rough distance

        if(uVel>0)
            xVel= Mathf.Sqrt(uVel*stats.grav);
        else
            xVel= -Mathf.Sqrt(-uVel*stats.grav);
        if(vVel>0)
            yVel = Mathf.Sqrt(vVel*2*stats.grav);
        else
            yVel = -Mathf.Sqrt(-vVel*2*stats.grav);
        yVel*=dmgScale;
        xVel*=dmgScale;

        //TurnCheck(xVel);
        if(Mathf.Abs(xVel) < 1.2f)
            stats.walk.gndSpeed=xVel*(1+stats.fric);
        else{
            yVel=Mathf.Abs(xVel)/3.0f;
            stats.motion.vel.y=yVel;
            stats.motion.vel.x=xVel;
            Fall();
        }
        if ((!fHelper.airborne)) {//Grounded down momentum changed to up
            if(yVel<0){
                yVel = -0.8f*yVel;
                fHelper.airborne=true;
            }
        }
        if ((fHelper.airborne) || (yVel > Mathf.Abs (xVel) + 0.1f)) {//check to see if the hit was
                fHelper.airborne = true; //hard enough to launch the player into

                stats.motion.vel.y = yVel; //airborne state
                stats.motion.vel.x = xVel;

        }

        dmgFlag = true;
    }
Ejemplo n.º 15
0
    public void Start()
    {
        startPos = new SPoint(transform.position.x, transform.position.y);
        //transform.position = new Vector3(0, 0, 0);

        SetPos(startPos);
        projTmr = new STimer(starCooldown);
        parryTimeout = new STimer(1.0f);
        parryTmr = new STimer(1.0f);
        hovTmr = new STimer(1.0f);
        hovDir = new SPoint(0, 0);
        hovFin = new SPoint(0, 0);
        hovRec = 1;
        dashTmr = new STimer(DASH_TIME);
        ls = transform.localScale;
        rollInvOn = new STimer ();
        rollInvOff = new STimer ();
        debugFadeTmr = new STimer (0.5f);
        atkTmr = new STimer ();
        NORM_ORIENT = new Vector3 (0, 90.0f, 0);
        if (debugModeOn)
            CreateColBox ();
        GameObject go;
        int pCt = 0;
        for (int i=1; i<3; i++) {
            go = GameObject.FindGameObjectWithTag ("Player" + i);
            if (go != null)
                pCt++;
            }
        hitHolder = null;
        stunTimer = new STimer ();
        wallhang = false;
        starTmr = new STimer(starCooldown);
        go=new GameObject();
        for(int i=1;i<pCt+1;i++){
            go =  GameObject.FindGameObjectWithTag("Player"+i);

        }
    }
Ejemplo n.º 16
0
    public void RunTimers(float timeLapsed)
    {
        projTmr.RunTimer(timeLapsed);
        parryTimeout.RunTimer(timeLapsed);
        if (parryTmr.RunTimer(timeLapsed)){
            effects[4].Play();
            parryTimeout.SetTimer(1.0f);
        }
        dashTmr.RunTimer(timeLapsed);
        if (hovTmr.RunTimer(timeLapsed)) {
            hovDir.x = 0;
            hovDir.y = 0;
            hovFin.y = 0;
            hovFin.x = 0;
        }
        else if (!hovTmr.IsReady())
        {
            fHelper.airborne = true;
            float rat = hovTmr.tmr / hovTmr.GetLen();
            stats.motion.accl.y = stats.grav;
            stats.motion.vel.x = (1.0f-rat)*hovDir.x  + rat*hovFin.x;
            stats.motion.vel.y = (1.0f-rat) * hovDir.y + rat * hovFin.y;
            hovRec = 1;
        }
        if (stats.jump.tmr.RunTimer(timeLapsed)){

             if (!fHelper.airborne)
            {
                Jump();
            }
        }
        if(stunTimer.RunTimer(timeLapsed)){
            if(hitHolder!=null)
                TakeHit (hitHolder);
            hitHolder=null;
        }
        if(!debugFadeTmr.IsReady()){
            if(debugFadeTmr.RunTimer (timeLapsed))
                Destroy (attkHitbox);
        }
        if(rollInvOn.RunTimer(timeLapsed)){
            rollInvOff.SetTimer();
            stats.flags.invuln=true;

        }if (rollInvOff.RunTimer (timeLapsed)) {
            stats.flags.invuln=false;
        }
        //attack timer
        atkTmr.RunTimer (timeLapsed);

        //edge timers

            //timer to track pivoting between left/right

            if(stats.walk.shuffle.RunTimer(timeLapsed))
            stats.flags.running=true;

        if(Mathf.Abs(stats.walk.gndSpeed)<stats.walk.maxSpeed/2)
                stats.flags.running =false;
            //time between jump command and action (windup frames)

            //landing stuff added here
            if (stats.land.RunTimer (timeLapsed)) {
                        stats.flags.aBusy = false;
            stats.flags.mBusy=false;
                }
            //actiontimer

            //dodge timer
            if(InState( DODGE)){
                stats.flags.invuln=true;
                if(stats.dodge.RunTimer(timeLapsed)){
                    stats.flags.invuln=false;
                    stats.flags.aBusy=false;
                    stats.flags.mBusy=false;
                     state=IDLE;
                    //Idle();

            }
        }

        //fHelper.RunTimers(timeLapsed);
    }