//тип 0 номер 2 public bool Raycaster(InfoGets infogets, int numb, Vector2 vect, SpFunctions sp) { return Physics2D.Raycast(sp.VectorConvert(infogets.infoGets[numb].OBJ[0].transform.position), vect.normalized, infogets.infoGets[numb].PRM2[0], infogets.infoGets[numb].LYR); }
//тип 0 номер 1 public bool Overlaper(InfoGets infogets, int numb,SpFunctions sp) { return Physics2D.OverlapCircle (sp.VectorConvert (infogets.infoGets [numb].OBJ [0].transform.position), infogets.infoGets [numb].PRM2 [0], infogets.infoGets [numb].LYR); k1++; }
//тип 1 номер 7 public void MoveToClimb(Rigidbody2D rigid, Stats stats, InfoGets inf, int numb, SpFunctions sp) { RaycastHit2D hit; rigid.velocity = new Vector2 (0f, 0f); rigid.gravityScale = 0; int koof2; if (rigid.velocity.y>=0) koof2=1; else koof2=-1; bool k = Physics2D.Raycast (inf.infoGets [numb].OBJ [0].transform.position, new Vector2(inf.infoGets [numb].VCT [0].x*sp.realSign(stats.direction), inf.infoGets [numb].VCT [0].y*koof2).normalized, inf.infoGets [numb].PRM2 [0], inf.infoGets [numb].LYR); hit=Physics2D.Raycast (inf.infoGets [numb].OBJ [0].transform.position, new Vector2(inf.infoGets [numb].VCT [0].x*sp.realSign(stats.direction), inf.infoGets [numb].VCT [0].y*koof2).normalized, inf.infoGets [numb].PRM2 [0], inf.infoGets [numb].LYR); float koof = -1*sp.realSign (hit.normal.x); if (k) { rigid.velocity=new Vector2(0f,0f); float length = hit.distance; Vector2 vect = inf.infoGets [numb].VCT [0].normalized; vect = new Vector2 (vect.x *koof* length, vect.y *koof2* length); rigid.gameObject.transform.position = new Vector3 (rigid.gameObject.transform.position.x + vect.x, rigid.gameObject.transform.position.y + vect.y, rigid.gameObject.transform.position.z); } }
//тип 1 номер 6 public void Climb(Rigidbody2D rigid, Stats stats, InfoGetTypes IGT, InfoGets inf, int numb, int targetSpeedX, int targetSpeedY, SpFunctions sp) { rigid.gravityScale = 0f; if (IGT.Raycaster(inf,numb,new Vector2(targetSpeedX*1f,targetSpeedY*1f),sp)) rigid.velocity=new Vector2(targetSpeedX*1f,targetSpeedY*1f); else rigid.velocity=new Vector2(0f,0f); stats.stats.targetSpeedX = targetSpeedX; stats.stats.targetSpeedY = targetSpeedY; }
public void GetInformation(InfoGets inf) { InfoGetTypes infType=GetComponent<InfoGetTypes>(); for (int i=0;i<inf.infoGets.Length;i++) { if (inf.infoGets[i].OBJ[0].GetComponent<Indicator>()!=null) if (!inf.infoGets[i].OBJ[0].GetComponent<Indicator>().isItActive()) continue; if ((inf.infoGets[i].numbOfInfo==1)&&(infType.Overlaper(inf,i,this))|| (inf.infoGets[i].numbOfInfo==2)&&(infType.Raycaster(inf, i, new Vector2 (realSign(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.targetSpeedX)*inf.infoGets[i].VCT[0].x, inf.infoGets[i].VCT[0].y), this))|| (inf.infoGets[i].numbOfInfo==4)&&(infType.Raycaster(inf, i, new Vector2 (realSign(inf.infoGets[i].OBJ[1].GetComponent<Stats>().direction)*inf.infoGets[i].VCT[0].x, inf.infoGets[i].VCT[0].y), this))) { inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.groundness=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.groundness,inf.infoGets[i].stats.groundness); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.obstacleness=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.obstacleness,inf.infoGets[i].stats.obstacleness); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.interaction=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.interaction,inf.infoGets[i].stats.interaction); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.maxInteraction=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.maxInteraction,inf.infoGets[i].stats.maxInteraction); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.hitted=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.hitted,inf.infoGets[i].stats.hitted); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.upness=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.upness,inf.infoGets[i].stats.upness); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.specialness=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.specialness,inf.infoGets[i].stats.specialness); } else if (inf.infoGets[i].typeOfInfo==1) { inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.groundness=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.groundness,inf.infoGets[i].elseStats.groundness); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.obstacleness=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.obstacleness,inf.infoGets[i].elseStats.obstacleness); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.interaction=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.interaction,inf.infoGets[i].elseStats.interaction); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.maxInteraction=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.maxInteraction,inf.infoGets[i].elseStats.maxInteraction); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.hitted=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.hitted,inf.infoGets[i].elseStats.hitted); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.upness=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.upness,inf.infoGets[i].elseStats.upness); inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.specialness=WhatToChange(inf.infoGets[i].OBJ[1].GetComponent<Stats>().stats.specialness,inf.infoGets[i].elseStats.specialness); } if (inf.infoGets[i].numbOfInfo==3) { if (inf.infoGets[i].OBJ[0].GetComponent<Stats>().stats.targetSpeedX>0) inf.infoGets[i].OBJ[0].GetComponent<Stats>().direction=1; if (inf.infoGets[i].OBJ[0].GetComponent<Stats>().stats.targetSpeedX<0) inf.infoGets[i].OBJ[0].GetComponent<Stats>().direction=-1; } } }
void Awake() { actNumb = 0; rigid = gameObject.GetComponent<Rigidbody2D> (); stats = gameObject.GetComponent<Stats> (); animator = GetComponent<CharacterAnimator> (); actions = gameObject.GetComponent<Actions> (); infoGets = gameObject.GetComponent<InfoGets> (); clav = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent<clavisher> (); Sp=GameObject.FindGameObjectWithTag (Tags.gameController).GetComponent<SpFunctions> (); equip = gameObject.GetComponent<Equipment> (); }