예제 #1
0
        private static Fix64Vector2 Support(MGFObject a, MGFObject b, Fix64Vector2 d)
        {
            Fix64Vector2 InA = a.Support(d);
            Fix64Vector2 InB = b.Support(-d);

            return(InA - InB);
        }
예제 #2
0
        public Fix64 A64Sq()
        {
            var a = new Fix64Vector2(r.NextDouble() * 11111, r.NextDouble() * 11111);
            var b = new Fix64Vector2(r.NextDouble() * 11111, r.NextDouble() * 11111);

            return(Fix64Vector2.DistanceSquared(a, b));
        }
예제 #3
0
파일: RBScript.cs 프로젝트: xz000/testingLL
 public void GetPushed(Fix64Vector2 velo, float time)
 {
     MS.controllable  = false;
     MS.Givenvelocity = velo;
     timepassed       = 0;
     timetostop       = time;
 }
예제 #4
0
    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;
        }
    }
예제 #5
0
    public void Skill(Fix64Vector2 actionplace)
    {
        //DoSkill.singing = 0;
        //gameObject.GetComponent<DoSkill>().Fire = null;
        GetComponent <DoSkill>().BeforeSkill();
        Fix64        bsf = (Fix64)bulletspeed;
        GameObject   bullet;
        Fix64Vector2 skilldirection;
        Fix64Vector2 singplace = (Fix64Vector2)GetComponent <Rigidbody2D>().position;

        skilldirection = actionplace - singplace;
        Fix64 turntime = (skilldirection.Length() - (Fix64)0.76) / bsf;

        leecher.GetComponent <LeechScript>().sender      = gameObject;
        leecher.GetComponent <LeechScript>().turntime    = (float)turntime;
        leecher.GetComponent <LeechScript>().leechdamage = damage;
        Fix64Vector2 sdnf = skilldirection.normalized();

        bullet = Instantiate(leecher, (singplace + (Fix64)0.76 * sdnf).ToV2(), Quaternion.identity);
        bullet.GetComponent <LeechScript>().speed    = bsf;
        bullet.GetComponent <Rigidbody2D>().velocity = (sdnf * bsf).ToV2();
        //bullet.GetComponent<LeechScript>().maxtime = maxdistance / bulletspeed;
        currentcooldown = 0;
        skillavaliable  = false;
    }
예제 #6
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);
    }
예제 #7
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);
    }
예제 #8
0
        /// <summary>
        /// 射线
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public IEnumerable <MGFObject> RayCast2D(Fix64Vector2 start, Fix64Vector2 end)
        {
            HashSet <MGFObject> ls = new HashSet <MGFObject>();

            foreach (var item in m_Objects)
            {
                Fix64Vector2   hit;
                Fix64Vector2[] vertex  = item.GetVertex();
                Fix64Vector2[] vertexN = new Fix64Vector2[vertex.Length];
                for (int j = 0; j < vertexN.Length; j++)
                {
                    vertexN[j] = vertex[j] + item.GetPos();
                }
                for (int j = 0; j < 4; j++)
                {
                    int nt = j + 1;
                    if (j == 3)
                    {
                        nt = 0;
                    }
                    if (MGFPhysics.lineIntersection(start, end, vertexN[j], vertexN[nt], out hit))
                    {
                        Debug.Log(item.name + " line P1" + vertexN[j] + " P2 " + vertexN[nt] + " hit " + hit);
                        ls.Add(item);
                        break;
                    }
                }
            }
            return(ls);
        }
예제 #9
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);
    }
예제 #10
0
    public void RealSkill()
    {
        Fix64        ff           = (Fix64)bombforce;
        Vector2      actionplacev = transform.position;
        Fix64Vector2 actionplacef = (Fix64Vector2)actionplacev;

        Collider2D[] colliders = Physics2D.OverlapCircleAll(actionplacev, radius + 0.1f);
        foreach (Collider2D hit in colliders)
        {
            /*Fix64 dfs = ((Fix64Vector2)(Vector2)hit.transform.position - actionplacef).LengthSquare();
             * if (dfs > rfs)
             *  continue;*/
            HPScript hp = hit.GetComponent <HPScript>();
            if (hp != null)
            {
                hp.GetHurt(damage);
                Rigidbody2D rb = hit.GetComponent <Rigidbody2D>();
                if (rb != null)
                {
                    Fix64Vector2 explforce;
                    explforce = (Fix64Vector2)rb.position - actionplacef;
                    hit.GetComponent <RBScript>().GetPushed(explforce.normalized() * ff, pushtime);
                }
            }
        }
    }
예제 #11
0
    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();
    }
예제 #12
0
    public void powerrr(int PNO, List <ClickData> LCD)
    {
        foreach (ClickData CD in LCD)
        {
            if (CD.SC != null)
            {
                thePC[PNO].SendMessage("Go" + CD.SC.ToString());
            }
            if (CD.blr != null)
            {
                switch (CD.blr)
                {
                case MButton.left:
                    Fix64Vector2 v2l = new Fix64Vector2((Fix64)CD.xPos, (Fix64)CD.yPos);
                    theDS[PNO].justdoit(v2l);
                    break;

                case MButton.right:
                    Vector2 v2r = new Vector2((float)CD.xPos, (float)CD.yPos);
                    theMS[PNO].SetTarget(v2r);
                    break;
                }
            }
            if (CD.gn != string.Empty)
            {
                Fix64Vector2 v2s = (Fix64Vector2)GameObject.Find(CD.gn).GetComponent <Rigidbody2D>().position;
                theDS[PNO].justdoit(v2s);
            }
        }
        LCD.Clear();
    }
예제 #13
0
        /// <summary>
        /// 射线
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public List <MGFObject> RayCast2D(Fix64Vector2 start, Fix64Vector2 end)
        {
            List <MGFObject> ls = new List <MGFObject>();

            for (int i = 0; i < m_Objects.Count; i++)
            {
                Fix64Vector2   hit;
                Fix64Vector2[] vertex  = m_Objects[i].GetVertex();
                Fix64Vector2[] vertexN = new Fix64Vector2[vertex.Length];
                for (int j = 0; j < vertexN.Length; j++)
                {
                    vertexN[j] = vertex[j] + m_Objects[i].GetPos();
                }
                for (int j = 0; j < 4; j++)
                {
                    int nt = j + 1;
                    if (j == 3)
                    {
                        nt = 0;
                    }
                    if (MGFPhysics.lineIntersection(start, end, vertexN[j], vertexN[nt], out hit))
                    {
                        Debug.Log(m_Objects[i].name + " line P1" + vertexN[j] + " P2 " + vertexN[nt] + " hit " + hit);
                        ls.Add(m_Objects[i]);
                        break;
                    }
                }
            }
            return(ls);
        }
예제 #14
0
파일: SkillR1b.cs 프로젝트: xz000/testingLL
    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;
        }
    }
예제 #15
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        Fix64Vector2 sp = -(Fix64Vector2)selfRB.velocity;
        Fix64Vector2 vp = (Fix64Vector2)(Vector2)(collision.transform.position - transform.position);

        selfRB.velocity = Fix64Vector2.MirrorBy(sp, vp).ToV2();
    }
예제 #16
0
 private void RotateVec(Fix64 rot)
 {
     for (int i = 0; i < vertexInit.Length; i++)
     {
         vertex[i] = Fix64Vector2.Rotate(vertexInit[i], -rot);
     }
     Forward = Fix64Vector2.Rotate(initForward, -rot);
 }
예제 #17
0
        internal static bool CheckBoundings(MGFObject a, MGFObject b)
        {
            Fix64Vector2 posA = a.GetPos();
            Fix64Vector2 posB = b.GetPos();

            return(Fix64.Abs(posA.X - posB.X) < a.GetHalfSize().X + b.GetHalfSize().X&&
                   Fix64.Abs(posA.Y - posB.Y) < a.GetHalfSize().Y + b.GetHalfSize().Y);
        }
예제 #18
0
파일: SkillT2.cs 프로젝트: xvzan/testingLL
 public void Skill(Fix64Vector2 actionplace)
 {
     GetComponent <DoSkill>().BeforeSkill();
     currentcooldown = 0;
     skillavaliable  = false;
     drt             = (actionplace - (Fix64Vector2)GetComponent <Rigidbody2D>().position).normalized().CCWTurn((Fix64)maxfiretime * Fix64.Pi / (Fix64)90);
     firetimes       = 0;
     firestart       = true;
 }
예제 #19
0
 void FFF(Fix64Vector2 direction)
 {
     direction = direction.CCWTurn(-Fix64.Pi / (Fix64)6);
     for (int bnum = 0; bnum < bulletamount; bnum++)
     {
         DoFire((spf + (direction * (Fix64)0.6)).ToV2(), (direction * (Fix64)bulletspeed).ToV2());
         direction = direction.CCWTurn(Fix64.Pi / (Fix64)8);
     }
 }
예제 #20
0
파일: SkillY3.cs 프로젝트: xvzan/testingLL
    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();
    }
예제 #21
0
파일: DoSkill.cs 프로젝트: xvzan/testingLL
 public void justdoit(Fix64Vector2 fv2)
 {
     if (Fire == null)
     {
         return;
     }
     BeforeSkill();
     Fire(fv2);
     FireReset();
 }
예제 #22
0
    public void Skill(Fix64Vector2 actionplace)
    {
        GetComponent <DoSkill>().BeforeSkill();
        currentcooldown = 0;
        skillavaliable  = false;
        spf             = (Fix64Vector2)GetComponent <Rigidbody2D>().position;
        Fix64Vector2 skilldirection = (actionplace - spf).normalized();

        FFF(skilldirection);
    }
예제 #23
0
    public void Skill(Fix64Vector2 actionplace)
    {
        GetComponent <DoSkill>().BeforeSkill();
        Fix64Vector2 singplace      = (Fix64Vector2)GetComponent <Rigidbody2D>().position;
        Fix64Vector2 skilldirection = (actionplace - singplace).normalized();

        DoFire((singplace + (Fix64)0.81 * skilldirection).ToV2(), (skilldirection * (Fix64)bulletspeed).ToV2());
        currentcooldown = 0;
        skillavaliable  = false;
    }
예제 #24
0
파일: DoSkill.cs 프로젝트: xz000/testingLL
 public void justdoit(Fix64Vector2 fv2)
 {
     if (Fire == null)
     {
         return;
     }
     BeforeSkill();
     Fire(fv2);
     //Debug.Log("Just Fired to " + fv2.ToV2().x);
     FireReset();
 }
    private Rectangle GetSecneSize()
    {
        Fix64Vector2 halfSize = new Fix64Vector2(0, 0);
        Fix64Vector2 center   = new Fix64Vector2((Fix64)Ground.transform.position.x, (Fix64)Ground.transform.position.z);

        halfSize.X = (Fix64)X;
        halfSize.Y = (Fix64)Y;
        Rectangle rt = new Rectangle(center, halfSize);

        return(rt);
    }
예제 #26
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;
        //Debug.Log("TestSkill01 To" + actionplace.ToV2().x);
    }
예제 #27
0
    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;
    }
예제 #28
0
파일: SkillT2.cs 프로젝트: xvzan/testingLL
 public void FFF()
 {
     DoFire(((Fix64Vector2)GetComponent <Rigidbody2D>().position + (Fix64)0.6 * drt).ToV2(), (drt * (Fix64)bulletspeed).ToV2());
     firetime -= 0.1f;
     if (firetimes > maxfiretime)
     {
         firestart = false;
         return;
     }
     firetimes++;
     drt = drt.CCWTurn(-Fix64.Pi / (Fix64)90);
 }
    public T CreateFromPool <T>(string name, Fix64Vector2 fv, Fix64 rot) where T : MGFObject
    {
        T obj = m_Op.CreateObj <T>(name);

        obj.IsCollisionAble = true;
        PhysicsManager.Instance.AddObject(obj);
        obj.v.Show();
        obj.MoveTo(fv);
        obj.RotateTo(rot);
        obj.MGFEnable();
        return(obj);
    }
예제 #30
0
파일: SkillE1b.cs 프로젝트: xz000/testingLL
    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;
    }