public void Skill(Fix64Vector2 actionplacef) { Vector2 actionplace = actionplacef.ToV2(); Vector2 realplace; GetComponent <DoSkill>().BeforeSkill(); currentcooldown = 0; skillavaliable = false; gameObject.GetComponent <DoSkill>().Fire = null; Rigidbody2D selfrb2d = gameObject.GetComponent <Rigidbody2D>(); Vector2 skilldirection = actionplace - selfrb2d.position; RaycastHit2D hit2D = Physics2D.Raycast(selfrb2d.position + skilldirection.normalized * SelfR, skilldirection - skilldirection.normalized * SelfR); if (hit2D.collider != null) { realplace = hit2D.point; if (hit2D.collider.GetComponent <GoWhereScript>() != null) { hit2D.collider.GetComponent <GoWhereScript>().GoHere(transform.position); } transform.position = realplace; } else { realplace = selfrb2d.position + maxdistance * skilldirection.normalized; transform.position = realplace; } }
public void DoFake(Vector2 Worldv2) { if (!faking) { return; } faking = false; Fix64Vector2 center = (Fix64Vector2)selfRB.position; Fix64Vector2 Realv2 = ((Fix64Vector2)Worldv2 - center).normalized() * (Fix64)2; gameObject.GetComponent <DoSkill>().DoClearJob(); selfRB.position += Realv2.ToV2(); for (int i = 0; i < 2; i++) { Realv2 = Realv2.CCWTurn((Fix64)2 * Fix64.Pi / (Fix64)3); GameObject nm = Instantiate(Faker, (center + Realv2).ToV2(), Quaternion.identity); nm.name = gameObject.name + "f" + i; if (GetComponent <MoveScript>().isme) { nm.GetComponent <SpriteRenderer>().color = Color.yellow; } nm.GetComponent <FakeCircleScript>().Beauty = selfRB; nm.GetComponent <FakeCircleScript>().maxtime = maxfaketime - currentfaketime; } GetComponent <MoveScript>().stopwalking(); }
public void Skillscd(Fix64Vector2 actionplacef) { if (!doscd) { return; } Vector2 actionplace = actionplacef.ToV2(); Vector2 singplace = transform.position; Vector2 skilldirection = actionplace - singplace; float realdistance = Mathf.Min(skilldirection.magnitude, 4); if (realdistance <= 0.51) { return; } //半径小于自身半径时不施法 else { Vector2 realplace = singplace + skilldirection.normalized * realdistance; gameObject.GetComponent <MoveScript>().stopwalking(); //停止走动 gameObject.GetComponent <StealthScript>().StealthEnd(); gameObject.GetComponent <MoveScript>().controllable = true; transform.position = realplace; doscd = false; } }
public void Skill(Fix64Vector2 actionplace) { Fix64 mdf = (Fix64)maxdistance; Fix64Vector2 singplace = (Fix64Vector2)GetComponent <Rigidbody2D>().position; Fix64Vector2 skilldirection = actionplace - singplace; Fix64 rdf = skilldirection.Length(); if (rdf > mdf) { rdf = mdf; } if (rdf <= (Fix64)0.51) { return; } Fix64Vector2 realplace = singplace + skilldirection.normalized() * rdf; GetComponent <DoSkill>().BeforeSkill(); currentcooldown = 0; skillavaliable = false; Vector2 rpv2 = realplace.ToV2(); if (Physics2D.OverlapPoint(rpv2)) { Collider2D hit = Physics2D.OverlapPoint(rpv2); if (hit.GetComponent <HPScript>() != null) { MyLine.GetComponent <BlueLineScript>().BlueLineWorking(hit.GetComponent <Rigidbody2D>()); return; } } MyLine.GetComponent <BlueLineScript>().BlueLineMissed(rpv2); }
public void Skill(Fix64Vector2 actionplace) { Fix64Vector2 singplace = (Fix64Vector2)GetComponent <Rigidbody2D>().position; Fix64Vector2 skilldirection = actionplace - singplace; Fix64Vector2 sn = skilldirection.normalized(); Fix64 md = (Fix64)maxdistance; Fix64 sl = skilldirection.Length(); Fix64 realdistance; if (sl >= md) { realdistance = md + (Fix64)2; } else { realdistance = sl + (Fix64)2; } if (realdistance <= (Fix64)2.5) { return; } //半径小于自身半径时不施法 GetComponent <DoSkill>().BeforeSkill(); currentcooldown = 0; skillavaliable = false; Fix64Vector2 Suiteplace = singplace - sn * (Fix64)2; GameObject MySuite = Instantiate(MySuiteObj, Suiteplace.ToV2(), Quaternion.identity); MySuite.GetComponent <SilenceSuiteScript>().work(sn * realdistance); }
void DoFire(Fix64Vector2 fireplace, Fix64Vector2 speed2d) { GameObject bullet; bullet = Instantiate(fireball, fireplace.ToV2(), Quaternion.identity); bullet.GetComponent <CentrallyConstentField>().sender = gameObject; bullet.GetComponent <CentrallyConstentField>().setspeed(force); bullet.GetComponent <CountdownScript>().maxtime = maxtime; bullet.GetComponent <Rigidbody2D>().velocity = speed2d.ToV2(); }
void DoFire(Fix64Vector2 fireplace, Fix64Vector2 speed2d) { GameObject bullet; fireball.GetComponent <BombExplode>().sender = gameObject; bullet = Instantiate(fireball, fireplace.ToV2(), Quaternion.identity); //bullet.GetComponent<BombExplode>().bombpower = force; bullet.GetComponent <BombExplode>().bombdamage = damage; bullet.GetComponent <Rigidbody2D>().velocity = speed2d.ToV2(); //bullet.GetComponent<BombExplode>().maxtime = maxdistance / bulletspeed; }
void SetTotalVelocity() { if (controllable) { cook(PlayerRb2d, this); PlayerRb2d.velocity = selfvelocity + VelotoAdd; } else { PlayerRb2d.velocity = Givenvelocity.ToV2(); } }
public void Skill(Fix64Vector2 actionplacef) { Vector2 actionplace = actionplacef.ToV2(); GetComponent <DoSkill>().BeforeSkill(); Vector2 singplace = transform.position; Vector2 skilldirection = actionplace - singplace; DoFire(singplace + 1.01f * skilldirection.normalized, skilldirection.normalized * bulletspeed); currentcooldown = 0; skillavaliable = false; }
public void Skill(Fix64Vector2 actionplace) { //DoSkill.singing = 0; //停止吟唱中技能 Fix64Vector2 singplace = (Fix64Vector2)GetComponent <Rigidbody2D>().position; Fix64Vector2 skilldirection = actionplace - singplace; Fix64 md64 = (Fix64)maxdistance; Fix64 skdl = skilldirection.Length(); Fix64 realdistance; if (skdl <= md64) { realdistance = skdl; } else { realdistance = md64; } if (realdistance <= (Fix64)0.51) { return; } //半径小于自身半径时不施法 else { //gameObject.GetComponent<DoSkill>().Fire = null; Fix64Vector2 realplace = singplace + skilldirection.normalized() * realdistance; Rigidbody2D selfrb2d = gameObject.GetComponent <Rigidbody2D>(); GetComponent <DoSkill>().BeforeSkill(); //MS.controllable = true; currentcooldown = 0; skillavaliable = false; Vector2 rpv2 = realplace.ToV2(); if (Physics2D.OverlapPoint(rpv2)) { Collider2D hit = Physics2D.OverlapPoint(rpv2); HPScript hps = hit.GetComponent <HPScript>(); if (hps != null) { Rigidbody2D rb2d = hit.GetComponent <Rigidbody2D>(); selfrb2d.position = rb2d.position; hps.TransferTo(singplace.ToV2()); } else { transform.position = rpv2; } } else { transform.position = rpv2; } } }
public void Skill(Fix64Vector2 actionplacef) { Vector2 actionplace = actionplacef.ToV2(); GetComponent <DoSkill>().BeforeSkill(); Vector2 singplace = transform.position; Vector2 skilldirection = actionplace - singplace; thistime = (Mathf.Min(skilldirection.magnitude, maxdistance) - 0.76f) / bulletspeed; DoFire(singplace + 0.76f * skilldirection.normalized, skilldirection.normalized * bulletspeed); currentcooldown = 0; skillavaliable = false; }
public void work(Fix64Vector2 workdir) { Fix64Vector2 s = workdir.normalized() * (Fix64)speed; Fix64Vector2 sA = s.CCWTurn(turnangle); Fix64Vector2 sB = s.CCWTurn(-turnangle); maxtime = (float)(workdir.Length() * (Fix64)2 / (sA + sB).Length()); cA = Instantiate(SC, transform.position, Quaternion.identity); cB = Instantiate(SC, transform.position, Quaternion.identity); cA.GetComponent <Rigidbody2D>().velocity = sA.ToV2(); cB.GetComponent <Rigidbody2D>().velocity = sB.ToV2(); //enabled = true; }
public void Skill(Fix64Vector2 actionplacef) { Vector2 actionplace = actionplacef.ToV2(); GetComponent <DoSkill>().BeforeSkill(); Vector2 singplace = transform.position; Vector2 skilldirection = actionplace - singplace; float realdistance = Mathf.Min(skilldirection.magnitude, maxdistance); float bulletspeed = realdistance / maxtime; DoFire(singplace, skilldirection.normalized * bulletspeed); currentcooldown = 0; skillavaliable = false; }
public void Skill(Fix64Vector2 actionplacef) { Vector2 actionplace = actionplacef.ToV2(); Vector2 singplace = transform.position; Vector2 skilldirection = actionplace - singplace; GetComponent <DoSkill>().BeforeSkill(); GetComponent <MoveScript>().controllable = true; currentcooldown = 0; skillavaliable = false; ImLSDS = true; gameObject.GetComponent <RBScript>().GetPushed((Fix64Vector2)(skilldirection.normalized * LDspeed), Mathf.Infinity); gameObject.GetComponent <StealthScript>().StealthByTime(Mathf.Infinity, true); }
void DoFire(Fix64Vector2 fireplace, Fix64Vector2 speed2d, GameObject target) { GameObject bullet; Missile.GetComponent <BombExplode>().sender = gameObject; bullet = Instantiate(Missile, fireplace.ToV2(), Quaternion.identity); bullet.GetComponent <MissileScript>().Speed = bulletspeed; //bullet.GetComponent<BombExplode>().bombpower = force; bullet.GetComponent <BombExplode>().bombdamage = damage; bullet.GetComponent <Rigidbody2D>().velocity = speed2d.ToV2(); if (target != null) { bullet.GetComponent <MissileScript>().Target = target.GetComponent <Rigidbody2D>(); } bullet.GetComponent <BombExplode>().maxtime = maxdistance / bulletspeed; }
public void Skill(Fix64Vector2 actionplace) { Fix64Vector2 realplace; Vector2 rpv2; GetComponent <DoSkill>().BeforeSkill(); currentcooldown = 0; skillavaliable = false; //gameObject.GetComponent<DoSkill>().Fire = null; Rigidbody2D selfrb2d = gameObject.GetComponent <Rigidbody2D>(); Fix64Vector2 selfv2f = (Fix64Vector2)selfrb2d.position; Fix64Vector2 skilldirection = actionplace - selfv2f; RaycastHit2D hit2D = Physics2D.Raycast((selfv2f + skilldirection.normalized() * SRF).ToV2(), (skilldirection - skilldirection.normalized() * SRF).ToV2()); if (hit2D.collider != null && (Fix64)hit2D.distance <= (Fix64)maxdistance - SRF) { rpv2 = hit2D.point; realplace = (Fix64Vector2)rpv2; Drawline(rpv2); if (hit2D.collider.GetComponent <DestroyScript>() != null && hit2D.collider.GetComponent <DestroyScript>().breakable == true) { hit2D.collider.GetComponent <DestroyScript>().Destroyself(); } else if (hit2D.collider.GetComponent <RollScript>() != null) { //if (!hit2D.collider.GetComponent<PhotonView>().isMine) //hit2D.collider.GetComponent<DestroyScript>().Destroyself(); return; } else if (hit2D.collider.GetComponent <RBScript>() != null) { Fix64Vector2 kickdirection = (Fix64Vector2)hit2D.collider.GetComponent <Rigidbody2D>().position - realplace; //hit2D.collider.GetComponent<SkillE2b>().lighthit(); hit2D.collider.GetComponent <RBScript>().GetPushed(kickdirection * (Fix64)6, 1); hit2D.collider.GetComponent <HPScript>().GetHurt(10); } } else { rpv2 = selfrb2d.position + maxdistance * skilldirection.ToV2().normalized; Drawline(rpv2); } AudioSource.PlayClipAtPoint(SoundLightning, rpv2); }
public void Skill(Fix64Vector2 actionplace) { Fix64Vector2 singplace = (Fix64Vector2)GetComponent <Rigidbody2D>().position; Fix64Vector2 skilldirection = actionplace - singplace; GetComponent <DoSkill>().BeforeSkill(); Fix64 mdf = (Fix64)maxdistance; if (skilldirection.LengthSquare() > mdf * mdf) { actionplace = singplace + skilldirection.normalized() * mdf; } GameObject MyRock = Instantiate(TheRock, actionplace.ToV2(), Quaternion.identity); MyRock.GetComponent <RockExplode>().damage = damage; MyRock.GetComponent <RockExplode>().bombforce = bombforce; currentcooldown = 0; skillavaliable = false; }
void DoFire(Fix64Vector2 fireplace, Fix64Vector2 speed2d, bool a) { fireball.GetComponent <BananaScript>().sender = gameObject; fireball.GetComponent <BananaScript>().bombdamage = damage; fireball.GetComponent <BananaScript>().maxtime = maxtime; GameObject bullet = Instantiate(fireball, fireplace.ToV2(), Quaternion.identity); bullet.GetComponent <Rigidbody2D>().velocity = speed2d.ToV2(); if (a) { bullet.GetComponent <BananaScript>().setmm(2); } else { bullet.GetComponent <BananaScript>().setmm(-2); } //bullet.GetComponent<BombExplode>().bombpower = force; //bullet.GetComponent<BombExplode>().maxtime = maxdistance / bulletspeed; }
void PCBorn(int MNum) { CreateGround(); Fix64Vector2 fix64Vector2 = new Fix64Vector2((Fix64)0, (Fix64)3); for (int i = MNum - 1; i >= 0; i--) { fix64Vector2 = fix64Vector2.CCWTurn(Fix64.PiTimes2 / (Fix64)MNum); thePC[i] = Instantiate(PlayerCircle, fix64Vector2.ToV2(), Quaternion.identity); thePC[i].name = i.ToString(); theMS[i] = thePC[i].GetComponent <MoveScript>(); theDS[i] = thePC[i].GetComponent <DoSkill>(); thePC[i].GetComponent <HPScript>().ser = GetComponent <Sender>(); thePC[i].GetComponent <CircleSkillMem>().SetCircleSL(Sender.theSLtemp[i]); if (i == Sender.clientNum) { theMS[i].itsme(); } } }
public void Skill(Fix64Vector2 actionplace) { Fix64Vector2 singplace = (Fix64Vector2)GetComponent <Rigidbody2D>().position; Fix64Vector2 skilldirection = actionplace - singplace; GetComponent <DoSkill>().BeforeSkill(); Fix64 mdfx = (Fix64)maxdistance; if (skilldirection.Length() > mdfx) { actionplace = singplace + skilldirection.normalized() * mdfx; } GameObject MyRock = Instantiate(TheStar, actionplace.ToV2(), Quaternion.identity); MyRock.GetComponent <StarScript>().sender = gameObject; MyRock.GetComponent <StarScript>().powerpers = powerpersecond; MyRock.GetComponent <CountdownScript>().maxtime = maxtime; currentcooldown = 0; skillavaliable = false; }
public void Skill(Fix64Vector2 actionplacef) { Vector2 actionplace = actionplacef.ToV2(); Vector2 singplace = transform.position; Vector2 skilldirection = actionplace - singplace; float realdistance = Mathf.Min(skilldirection.magnitude, maxdistance); if (realdistance <= 0.51) { return; } //半径小于自身半径时不施法 else { Vector2 realplace = singplace + skilldirection.normalized * realdistance; GetComponent <DoSkill>().BeforeSkill(); gameObject.GetComponent <MoveScript>().controllable = true; currentcooldown = 0; skillavaliable = false; transform.position = realplace; } }
GameObject FindClosestEnemy(Fix64Vector2 findingplacef) { Vector2 findingplace = findingplacef.ToV2(); GameObject closest = null; // GameObject.FindWithTag("Player"); GameObject[] Allthem = GameObject.FindGameObjectsWithTag("Player"); float sqrdis = Mathf.Infinity; foreach (GameObject Him in Allthem) { if (Him == gameObject) { continue; //跳过施法者 } Vector2 diff = (Him.GetComponent <Rigidbody2D>().position - findingplace); //距离向量 float curDistance = diff.sqrMagnitude; //距离平方 if (curDistance < sqrdis) { closest = Him; //更新最近距离敌人 sqrdis = curDistance; //更新最近距离 } } return(closest); }
void SelfTurn(Fix64Vector2 vector) { GetComponent <Rigidbody2D>().velocity = vector.ToV2(); }