Esempio n. 1
0
    public void Skill(Fix64Vector2 actionplace)
    {
        GetComponent <DoSkill>().BeforeSkill();
        Fix64Vector2 singplace      = (Fix64Vector2)GetComponent <Rigidbody2D>().position;
        Fix64Vector2 skilldirection = actionplace - singplace;

        DoFire(singplace + (Fix64)0.76 * skilldirection.normalized(), skilldirection.normalized() * (Fix64)bulletspeed);
        currentcooldown = 0;
        skillavaliable  = false;
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
    public void Skill(Fix64Vector2 actionplace)
    {
        GetComponent <DoSkill>().BeforeSkill();
        GameObject SkillTarget = FindClosestEnemy(actionplace);

        if (SkillTarget != null)
        {
            actionplace = (Fix64Vector2)(Vector2)SkillTarget.transform.position;
        }
        Fix64Vector2 singplace      = (Fix64Vector2)(Vector2)transform.position;
        Fix64Vector2 skilldirection = actionplace - singplace;

        DoFire(singplace + (Fix64)0.76 * skilldirection.normalized(), skilldirection.normalized() * (Fix64)bulletspeed, SkillTarget);
        currentcooldown = 0;
        skillavaliable  = false;
    }
Esempio n. 4
0
    Fix64Vector2 FindClosestVector2()
    {
        GameObject[] Allthem  = GameObject.FindGameObjectsWithTag("Player");
        Fix64        sqrdis   = Fix64.MaxValue;
        Fix64Vector2 position = (Fix64Vector2)GetComponent <Rigidbody2D>().position;
        Fix64Vector2 vector   = (Fix64Vector2)GetComponent <Rigidbody2D>().velocity;

        foreach (GameObject Him in Allthem)
        {
            //Debug.Log(Him.name);
            if (Him == sender)
            {
                continue;               //跳过施法者
            }
            Fix64Vector2 diff        = ((Fix64Vector2)Him.GetComponent <Rigidbody2D>().position - position);
            Fix64        curDistance = diff.LengthSquare(); //向量距离平方
            if (curDistance <= sqrdis)
            {
                sqrdis = curDistance; //更新最近距离
                vector = diff;        //更新向量
            }
            //Debug.Log(vector.LengthSquare());
        }
        Fix64Vector2 v2r = (vector.normalized() * speed);

        return(v2r);
    }
Esempio n. 5
0
    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);
    }
Esempio n. 6
0
    void FFF(Fix64Vector2 direction)
    {
        direction = direction.CCWTurn(-Fix64.Pi / (Fix64)10);
        fireball.GetComponent <SABulletScript>().sender = null;
        Fix64Vector2 spv2 = (Fix64Vector2)GetComponent <Rigidbody2D>().position;

        for (int bnum = 0; bnum < 8; bnum++)
        {
            DoFire((spv2 + direction).ToV2(), (direction.normalized() * (Fix64)BulletSpeed).ToV2());
            direction = direction.CCWTurn(Fix64.Pi / (Fix64)40);
        }
    }
Esempio n. 7
0
    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;
            }
        }
    }
Esempio n. 8
0
    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;
    }
Esempio n. 9
0
    void FixedUpdate()
    {
        if (Target == null)
        {
            return;
        }
        Fix64Vector2 direction = (Fix64Vector2)Target.position - (Fix64Vector2)selfrb2d.position;

        if (direction.LengthSquare() <= (Fix64)0.3)
        {
            gethome();
        }
        selfrb2d.velocity = (direction.normalized() * (Fix64)Speed).ToV2();
    }
Esempio n. 10
0
    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);
    }
Esempio n. 11
0
    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;
    }
Esempio n. 12
0
    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;
    }
Esempio n. 13
0
    public void Skill(Fix64Vector2 actionplace)
    {
        Fix64Vector2 singplace      = (Fix64Vector2)(Vector2)transform.position;
        Fix64Vector2 skilldirection = actionplace - singplace;
        float        realdistance   = Mathf.Min((float)skilldirection.Length(), maxdistance);

        if (realdistance <= 0.51)
        {
            return;
        }   //半径小于自身半径时不施法
        GetComponent <DoSkill>().BeforeSkill();
        currentcooldown = 0;
        skillavaliable  = false;
        bulletspeed     = realdistance * 1.13f / (maxtime - 0.5f);
        Fix64Vector2 fp1 = skilldirection.normalized().CCWTurn(Fix64.Pi / (Fix64)4);

        DoFire(singplace, fp1 * (Fix64)bulletspeed, false);
        fp1 = fp1.CCWTurn(-Fix64.Pi / (Fix64)2);
        DoFire(singplace, fp1 * (Fix64)bulletspeed, true);
    }
Esempio n. 14
0
    public void Skill(Fix64Vector2 actionplace)
    {
        Fix64Vector2 singplace      = (Fix64Vector2)GetComponent <Rigidbody2D>().position;
        Fix64Vector2 skilldirection = actionplace - singplace;
        float        realdistance   = Mathf.Min((float)skilldirection.Length(), maxdistance);

        if (realdistance <= 0.6)
        {
            return;
        }   //半径小于自身半径时不施法
        else
        {
            GetComponent <DoSkill>().BeforeSkill();
            MS.controllable = true;
            currentcooldown = 0;
            skillavaliable  = false;
            float TimeR2 = (float)((Fix64)realdistance / (Fix64)SpeedR2);
            gameObject.GetComponent <ColliderScript>().SetPower(pushPower, pushTime, pushDamage);
            gameObject.GetComponent <ColliderScript>().StartKick(TimeR2);
            gameObject.GetComponent <RBScript>().GetPushed(skilldirection.normalized() * (Fix64)SpeedR2, TimeR2);
        }
    }
Esempio n. 15
0
    public void Skill()
    {
        //photonView.RPC("RealSkill", PhotonTargets.All);
        //gameObject.GetComponent<MoveScript>().stopwalking();
        //gameObject.GetComponent<StealthScript>().StealthEnd();
        currentcooldown = 0;
        skillavaliable  = false;
        float        radius      = 2;
        Vector2      actionplace = transform.position;
        Fix64        rfix        = (Fix64)4;
        Fix64Vector2 apf         = new Fix64Vector2(actionplace);

        Collider2D[] colliders = Physics2D.OverlapCircleAll(actionplace, radius);
        foreach (Collider2D hit in colliders)
        {
            HPScript hp = hit.GetComponent <HPScript>();
            if (hp != null)
            {
                if (hit == gameObject.GetComponent <Collider2D>())
                {
                    hp.GetHurt(Mathf.Min(10, hp.currentHP - 1));
                }
                else
                {
                    Rigidbody2D  rb        = hit.GetComponent <Rigidbody2D>();
                    Fix64Vector2 rbpf      = new Fix64Vector2(rb.position);
                    Fix64Vector2 explforce = rbpf - apf;
                    if (explforce.LengthSquare() > rfix)
                    {
                        continue;
                    }
                    hp.GetHurt(10);
                    hit.GetComponent <RBScript>().GetPushed(explforce.normalized() * (Fix64)9, 1f);
                }
            }
        }
    }