Example #1
0
    public bool DrawStageBox(SPoint[] v, string mat, int vTot, int ind)
    {
        subMesh[ind].Clear();
        Vector3[] vertices = new Vector3[vTot];
        Color32[] col = new Color32[vTot];
        int vT = (vTot-2)*3;
        if (vT < 1)
            vT = 1;

        int[] tri = new int[vT];

        for (int i = 0; i<vTot; i++) {
            vertices[i]=new Vector3(v[i].x , v[i].y , 0);
            if(mat.CompareTo("platform")==0)
                col[i] = new Color32(130, 150,210,155);
            else
                col[i] = new Color32(20, 20, 210,255);
            if(i==vT){
                i=vT;
            }
            if(i>1){//basic triangle fan
                tri[(i-2)*3]=0;
                tri[(i-2)*3+1]=i-1;
                tri[(i-2)*3+2]=i;
            }

        }
        subMesh[ind].vertices=vertices;
        subMesh[ind].triangles = tri;
        subMesh[ind].colors32 = col;
        return true;
    }
Example #2
0
    public void AttackDetect(Fighter plr)
    {
        //projectile checks
        SPoint[] pHdr = new SPoint[8];
        SPoint[] plBox;
        plBox = plr.GetHitBox();
        int hbLen=4;
        float[] plAng ={0, Mathf.PI/2, Mathf.PI, -Mathf.PI/2};
        bool hitflag = true;
                for (int i=0; i<8; i++)
                        pHdr [i] = new SPoint (v [i].x + pos.x, v [i].y +pos.y);
        float atkLen = GetVNum ();
                for (int j = 0; j < atkLen; j++)
                        if (!CheckAxis (pHdr [0], ang [j], plBox, pHdr, hbLen, 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,GetVNum ())) //no axis intersection
                                        hitflag = false;
                if (hitflag) {
                        active = false;
                        plr.GetHit (hitdata);
                        Detonate ();
                }
    }
Example #3
0
 public void UpdatePos()
 {
     SPoint vec = new SPoint();
     vec.y=target.y-at.y;
     vec.x=target.x-at.x;
     if(distTarget<minDist)
         distTarget=minDist;
     float movDistSq = vec.SqDistFromOrigin();
     float decel=0.5f;
     if(movDistSq>panSpeed*panSpeed){//moving too fast
         float dir = Mathf.Atan2(vec.y, vec.x);
         vec.x=Mathf.Cos(dir)*panSpeed;
         vec.y=Mathf.Sin(dir)*panSpeed;
         at.x+=vec.x*decel;
         at.y+=vec.y*decel;
     }else{
         at.x+=vec.x*decel;
         at.y+=vec.y*decel;
     }
     if(distTarget>dist)
         if(distTarget>dist+zoomSpeed)
             dist+=zoomSpeed;
     else
         dist=distTarget;
     else
         if(distTarget<dist-zoomSpeed)
             dist-=zoomSpeed;
     else
         dist=distTarget;
 }
Example #4
0
 public AttkData(int arrNum)
 {
     noHit=false;
     isThrow = false;
     isVacuum = false;
     mag=0;
     dir=0;
     dmg=0;
     wgt=1;
     adir=1;
     vCount=0;
     dirHold=0;
     lastDist=0;
     firstDist=0;
     perimeter=0;
     curInd=0;
     if(arrNum>MAX_VERTS/2)
         arrNum=MAX_VERTS/2;
     attLen=arrNum;
     arrLmt = arrNum*2 +1;
     //vtxArr = new AttkVtx[arrLmt];
     int i=4;
     cenPt = new SPoint (0, 0);
     pBds = new SPoint[i];
     tSz=3;//determines the 'containment box' around the attack data
     // will occupy 1/tSz of the availiable window
 }
Example #5
0
 public Stats()
 {
     motion.lastPos=new SPoint();
     motion.pos=new SPoint();
     motion.accl=new SPoint();
     motion.move=new SPoint();
     motion.vel=new SPoint();
     walk.shuffle=new STimer(0.5f);
     walk.slopeAng=new SPoint();
     edgegrab.rollSpd = 1.0f;
     edgegrab.edgeTmr=new STimer(1.0f);
     edgegrab.delayTmr=new STimer(0.2f);
     pivot.pTmr = new STimer (0.125f);
     pivot.fastTime=0.125f;
     pivot.slowTime = 0.4f;
     jump.tmr = new STimer (0.1f);
     guard.max = 60.0f*(Mathf.PI/180.0f);
     guard.arc=guard.max;
     guard.dir = 0;
     jump.tmr = new STimer (0.12f);
     jump.airJumps=0;
     jump.maxJumps=1;
     tumble.tmr = new STimer (1.1f);
     thr.dmg = 20;
     thr.dir = -1.0f;
     thr.mag = 3.0f;
     grav = 0.04f;
     grabRange = 24f;
     size = new SPoint ();
     land=new STimer(1.0f);
     dodge = new STimer ();
     flags.mBusy = false;
     flags.aBusy = false;
 }
Example #6
0
 public void addVal(SPoint p, float m, float di, float diDist, float dm, float w)
 {
     vtxArr[curInd]= new AttkVtx(p, m, di, dm, w);
     curInd++;
     if(vCount==0){//indicates a reset
         dir=0;
         wgt=0;
         perimeter=0;
         diDist=0;
         xMin = p.x;
         xMax = p.x;
         yMin = p.y;
         yMax = p.y;
     }
     dir+=di;
     perimeter+=1;
     wgt+=w;
     vCount++;
     if(m>mag)
         mag=m;
     if(dm>dmg)
         dmg=dm;
     if(xMin>p.x)
         xMin=p.x;
     if(xMax<p.x)
         xMax = p.x;
     if(yMin>p.y)
         yMin=p.y;
     if(yMax<p.y)
         yMax=p.y;
 }
Example #7
0
    public virtual bool Fire(Fighter plr, SPoint o, SPoint v)
    {
        plNum = plr.plNum;
        vel = new SPoint (velx*v.x, vely);
        float diff;
        if (!plr.fHelper.IsFacingRight()) {
            diff = ((Mathf.PI / 2) - dir) * 2.0f;
            dir += diff;
        }
        //dir 2.0fis the vector to travel in per second
        //if(active)
        //	return false;
        active=true;
        pos=new SPoint(o.x,o.y+16);
        transform.position = new Vector3 (pos.x, pos.y, 0);

        ttl.SetTimer(2);
        for (int i=0; i<ps.Length; i++) {
            if (ps != null) {
                ps[i].transform.position = new Vector3 (pos.x, pos.y, 0);
                ps[i].enableEmission = true;
                ps[i].Play ();

            }
        }
        return true;
    }
Example #8
0
 public bool Render(string mat, SPoint p, int i)
 {
     bool hr = true;
     if(isActive)
         hr =  DrawColBox(pBounds[0], mat, p, i, GetJlength(0));
     return hr;
 }
Example #9
0
    public void DrawAttkBox(SPoint[] v, string mat, int n, int endN, SPoint p, int pNum,  int t, int poly)
    {
        //specialized manual function for attackboxes
        subMesh [poly] = new Mesh ();
        int vTot = endN - n + 1;
        Vector3[] vertices = new Vector3[vTot];
        Color32[] col = new Color32[vTot];

        //std::stringstream hbName;
        string hbName = "P#" + pNum + "HB-" + t + "-" + poly;

        for (int i = n; i <= endN; i++) {
            vertices [i-n] = new Vector3 (v [i].x + p.x, v [i].y + p.y, 0);
            col [i-n] = new Color32 (0, 250, 20, 150);
        }
        int tTot = (vTot - 2) * 3;
        int[] tri = new int[tTot];
        for (int i = 0; i<(tTot/3);i++) {//triangle fan
            tri[i*3]=0;
            tri[(i*3)+1]=i+1;
            tri[(i*3)+2]=i+2;
        }
        subMesh[poly].vertices=vertices;
        subMesh[poly].triangles = tri;
        subMesh[poly].colors32 = col;
    }
Example #10
0
 public void AllocateSecondIndices(int ind, int num)
 {
     jLength[ind] = num;
     pBounds[ind] = new SPoint[num];
     jLength[ind] = num;
     ang[ind] = new float[num];
     subMesh [ind] = new Mesh ();
 }
Example #11
0
        public static bool IsCollidedRectRect2(SRect Rect0_, SRect Rect1_, SPoint Dir0_, SPoint Dir1_, SCollisionInfo CollisionInfo_)
        {
            if (!IsCollidedRectRect(Rect0_, Rect1_, Dir0_.GetSub(Dir1_), CollisionInfo_))
            {
                return(false);
            }

            CollisionInfo_.Point.Add(Dir1_.GetMulti(CollisionInfo_.Time));
            return(true);
        }
Example #12
0
    static void AssignPointStruct()
    {
        SPoint p = new SPoint(11, 111);
        SPoint q = new SPoint(22, 222);
        SPoint r = new SPoint(33, 333);

        r   = q;
        r.x = 44;
        Console.WriteLine("p = {0}, q = {1}, r = {2}", p, q, r);
    }
Example #13
0
    public CameraController()
    {
        dist=defDist;

        panSpeed=3.1f;
        zoomSpeed=4.1f;
        yFOV_Rad=45.0f*(Mathf.PI/180.0f);//default for ogre's camera deg
        distTarget=90;
        at = new SPoint (0, defDist);
        target = new SPoint (0, 0);
    }
Example #14
0
 public void AllocateSecondIndices(int ind, int num)
 {
     jLength[ind] = num;
     aVtx[ind] = new AttkVtx[num];
     atkAng[ind] = new float[num];
     pBounds[ind] = new SPoint[num];
     for (int i=0; i<num; i++) {
             atkAng [ind] [i] = 0;
         aVtx[ind][i]=new AttkVtx();
         }
 }
Example #15
0
            public SPoint Down(SPoint Point_) // return : Vector
            {
                if (CBase.Distance(_Center, Point_) > _InputRadius)
                {
                    return(null);
                }

                _Enabled = true;

                return(Move(Point_));
            }
        public void Interpolate()
        {
            var p1     = new SPoint(0, 0);
            var pTest1 = new SPoint(6, 0);
            var p2     = new SPoint(10, 0);
            var pTest2 = new SPoint(10, 4);
            var p3     = new SPoint(10, 10);
            var stroke = StrokeFactory.CreateInterpolatingStroke(new SPoint[] { p1, p2, p3 });

            Assert.AreEqual(21, stroke.Count());
            PointListsHelper.AssertPointPresence(stroke, new SPoint[] { p1, pTest1, p2, pTest2, p3 });
        }
Example #17
0
        public void Dashed()
        {
            var p1     = new SPoint(0, 0);
            var p2     = new SPoint(10, 0);
            var p3     = new SPoint(20, 0);
            var p4     = new SPoint(30, 0);
            var s      = new PolyStroke(new SPoint[] { p1, p2, p3, p4 });
            var dashed = new DashedStroke(s, 2);

            Assert.AreEqual(2, dashed.Count());
            PointListsHelper.AssertPointPresence(dashed, new SPoint[] { p1, p3 });
        }
Example #18
0
    public bool CheckAxis(SPoint origin, float dir, SPoint pCen, SPoint[] aBox, int aNum)
    {
        // helper function for the Separating Axis Theorem that takes an axis defined by origin and dir
        //re-conditioned to handle the parameters of the attack box
        bool isHit = true;
        float projMin, projMax, hitMin, hitMax, distSq, projVal, cVal;
        SPoint projVec, nVec, rVec, cVec;
        projVec = new SPoint();
        projMin = 100;
        projMax = -100;
        hitMin = 100;
        hitMax = -100;
          int   pNum = 1;//remove from param list!
        for (int i = 0; i < aNum; i++)
        {
            projVec.x = aBox[i].x - origin.x;
            projVec.y = aBox[i].y - origin.y;

            distSq = projVec.x * projVec.x + projVec.y * projVec.y;
            nVec = projVec.GetNormal();

            cVec = new SPoint(Mathf.Cos(dir + Mathf.PI / 2), Mathf.Sin(dir + Mathf.PI / 2));

            cVal = -cVec.Dot(nVec);
            //projVal = sin(rAng)*abs(sin(rAng))*distSq;
            projVal = cVal * Mathf.Abs(cVal) * distSq;

            if (projVal < projMin)
                projMin = projVal;
            if (projVal > projMax)
                projMax = projVal;
        }
        float eps = 0.00001f;

            projVec.x = pCen.x - origin.x;
            projVec.y = pCen.y - origin.y;
            distSq = projVec.x * projVec.x + projVec.y * projVec.y;
            cVec = new SPoint(Mathf.Cos(dir + Mathf.PI / 2), Mathf.Sin(dir + Mathf.PI / 2));
            nVec = projVec.GetNormal();
            cVal = -cVec.Dot(nVec);
            //projVal = sin(rAng)*abs(sin(rAng))*distSq;
            projVal = cVal * Mathf.Abs(cVal) * distSq;
            if (projVal < hitMin)
                hitMin = projVal;
            if (projVal > hitMax)
                hitMax = projVal;

        if ((projVal >= projMin) && (projVal <= projMax))
            isHit = true;
        else
            isHit = false;
        return isHit;
    }
Example #19
0
 // Use this for initialization
 void Start()
 {
     numPos = 4;
     menuSel = 0;
     vThresh = 0.5f;
     mLoc = new SPoint [4];
     mLoc [0] = new SPoint (-7.1f, 0.35f);
     mLoc [1] = new SPoint (-7.1f, -0.33f);
     mLoc [2] = new SPoint (-7.1f, -0.956f);
     mLoc [3] = new SPoint (-7.1f, -1.69f);
     inputTmr = new STimer (0.4f);
 }
Example #20
0
    public static void Main(String[] args)
    {
        SPoint p = new SPoint(11, 22);

        Console.WriteLine("p = {0}", p);       // Now p = (11, 22)
        p.Move(9, 8);
        Console.WriteLine("p = {0}", p);       // Now p = (20, 30)
        p.Move(5, 5).Move(6, 6);
        Console.WriteLine("p = {0}", p);       // Now p = (25, 35) not (31, 41)
        q.Move(5, 5);
        Console.WriteLine("q = {0}", q);       // Now q = (33, 44) not (38, 49)
    }
Example #21
0
        public void KillUnit(SPoint position)
        {
            String session = OperationContext.Current.SessionId;

            Task.Run(() =>
            {
                foreach (CServerPlayer playerCallback in _players.Where(player => player.Session != session))
                {
                    playerCallback.Callback.UnitHasDied(position);
                }
            });
        }
Example #22
0
        public ICell GetCell(SPoint position)
        {
            var cell = new CCell(position.X, position.Y);

            XElement cellData = GetCellElement(position);

            String terrainType = cellData?.Attribute("terrain")?.Value;

            cell.Terrain = GetTerrain(terrainType);

            return(cell);
        }
Example #23
0
        public void Move(IMovable unit, SPoint oldPosition, SPoint newPosition)
        {
            ICell oldCell        = GetCell(oldPosition);
            ICell newCell        = GetCell(newPosition);
            Int32 transferEnergy = GetPenalty(oldPosition);

            oldCell.Unit       = null;
            newCell.Unit       = unit;
            unit.MovingEnergy -= transferEnergy;
            unit.SetPosition(newPosition);
            MapUpdated?.Invoke(this, EventArgs.Empty);
        }
Example #24
0
 protected void Start()
 {
     startPos[0] = new SPoint(-24*SCALE_FAC, 20*SCALE_FAC);
     startPos[1] = new SPoint(-20*SCALE_FAC, 20*SCALE_FAC);
     startPos[2] = new  SPoint(20, 0);
     startPos[3] = new SPoint(20, 0);
     LoadStage ();
     numPlr = 1;
     for (int i=0; i<numPlr; i++) {
         player[i].fHelper.stats.id.num = i + 1;
         player[i].SetPos(startPos[i]);
     }
 }
Example #25
0
        public static bool IsOverlappedPointRect(SPoint Point_, SRect Rect_)
        {
            if (
                Point_.X >= Rect_.Left &&
                Point_.X <= Rect_.Right &&
                Point_.Y >= Rect_.Bottom &&
                Point_.Y <= Rect_.Top)
            {
                return(true);
            }

            return(false);
        }
Example #26
0
    public float wgt; //weight used in the hit function

    #endregion Fields

    #region Constructors

    public AttkVtx( )
    {
        dmg=0;
        dir=0;
        wgt=0;
        mag=0;
        rad=0;
        pri = 0;
        pos = new SPoint(0,0);
        next = null;
        frame = -1;
        brk = false;
    }
Example #27
0
 public AttkVtx(SPoint p, float m, float d, float dm, float w)
 {
     next = null;
     frame = -1;
     pos = new SPoint(p.x, p.y);
     mag = m;
     dmg = dm;
     dir = d;
     pri = 0;
     brk = false;
     wgt = w;
     rad = 0;
 }
Example #28
0
 // Use this for initialization
 void Start()
 {
     numPos = 4;
     menuSel = 1;
     vThresh = 0.5f;
     mLoc = new SPoint [4];
     mLoc [0] = new SPoint (100.0f, 5.0f);
     mLoc [1] = new SPoint (100.0f,-35.0f);
     mLoc [2] = new SPoint (100.0f, -75.0f);
     mLoc [3] = new SPoint (100.0f, -115.0f);
     inputTmr = new STimer (0.3f);
     if (Time.deltaTime == 0)
         Time.timeScale = 1;
 }
Example #29
0
 public void CopyFrom(AttkVtx s)
 {
     if (this == s)
         return ;
     next = s.next;
     frame = s.frame;
     mag = s.mag;
     dmg = s.dmg;
     dir = s.dir;
     brk = s.brk;
     wgt = s.wgt;
     pos = s.pos;
     rad = s.rad;
 }
Example #30
0
    public static void Main()
    {
        SPoint sp1 = new SPoint(1, 1);
        CPoint cp1 = new CPoint(1, 2);

        SPoint sp2 = sp1; // 객체 2개. 객체 자체를 복사
        CPoint cp2 = cp1; // 참조(주소)복사, 객체 한개

        sp2.x = 10;
        Console.WriteLine(sp1.x); // 1

        cp2.x = 10;
        Console.WriteLine(cp1.x); // 10
    }
Example #31
0
    public static void Main(String[] args)
    {
        SPoint p = new SPoint(11, 22);            // Create a struct value in p

        SPoint[] arr = { p, p };                  // Two more copies of p
        arr[0].x = 33;
        Console.WriteLine(arr[0] + " " + arr[1]); // Prints (33, 22) (11, 22)
        Object o = p;                             // Another copy of p, in heap

        p.x = 44;
        Console.WriteLine(p + " " + o);         // Prints (44, 22) (11, 22)
        Console.WriteLine(o is SPoint);         // Prints True
        Console.WriteLine(o is int);            // Prints False
    }
Example #32
0
 public void AllocateFirstIndices(int num)
 {
     iLength = num;
     pBounds = new SPoint[iLength][];
     jLength = new int[iLength];
     isPform = new bool[iLength];
     ang = new float[iLength][];
     rLipAr = new bool[iLength];
     lLipAr = new bool[iLength];
     for (int i=0; i<iLength; i++) {
         rLipAr[i] = false;
         lLipAr[i] = false;
     }
 }
Example #33
0
 // Use this for initialization
 void Start()
 {
     mh = GameObject.FindGameObjectWithTag ("MatchHelper").GetComponent ("MatchHelper") as MatchHelper;
     numPos = 4;
     menuSel = 0;
     vThresh = 0.5f;
     mLoc = new SPoint [4];
     mLoc [0] = new SPoint (-280.0f, 120.0f);
     mLoc [1] = new SPoint (-280.0f, 60.0f);
     mLoc [2] = new SPoint (-280.0f, 0.0f);
     mLoc [3] = new SPoint (-280.0f, -100.0f);
     inputTmr = new STimer (0.2f);
     isSelected = false;
 }
Example #34
0
    public static void Main()
    {
        CPoint cp1;                // 객체 생성 아님. 참조 변수 생성
        CPoint cp2 = new CPoint(); // 객체 생성.

        SPoint sp1;                // 객체 생성
        SPoint sp2 = new SPoint(); // 객체 생성, initobj

        sp1.x = 10;
        xp2.x = 10;

        Console.WriteLine($"{sp1.x}");
        Console.WriteLine($"{sp2.x}");
    }
Example #35
0
    public bool DrawColBox(SPoint[] v, string mat,SPoint p, int pNum, int vTot)
    {
        //specialized manual function for attackboxes
        //name derived from material name.
        mesh.Clear();
        Vector3[] vertices = new Vector3[vTot];
        Color32[] col = new Color32[vTot];

        for (int i = 0; i<vTot; i++) {
            vertices[i]=new Vector3(v[i].x + p.x, v[i].y + p.y, 0);
            if(mat.CompareTo("HitBox")==0)
                col[i] = new Color32(30, 250,10,155);
            else if(mat.CompareTo("AttkBox")==0)
                col[i] = new Color32(250,30,10,255);
            else if(mat.CompareTo("IsHit")==0)
                    col[i] = new Color32(230, 210,210,255);

        }
        int[] tri = new int[6];
        if (vTot == 6)
            tri = new int[12];
        tri [0] = 0;
        tri [1] = 1;
        tri [2] = 2;
        tri [3] = 0;
        tri [4] = 2;
        tri [5] = 3;

        if (vTot == 6) {
            tri = new int[12];
            tri [0] = 0;
            tri [1] = 1;
            tri [2] = 2;
            tri [3] = 0;
            tri [4] = 2;
            tri [5] = 3;
            tri [6] = 0;
            tri [7] = 3;
            tri [8] = 5;
            tri [9] = 3;
            tri [10] = 4;
            tri [11] = 5;

        }
        mesh.vertices=vertices;
        mesh.triangles = tri;
        mesh.colors32 = col;
        return true;
    }
Example #36
0
 void Start()
 {
     numPos = 3;
     menuSel = 0;
     vThresh = 0.3f;
     mLoc = new SPoint [4];
     mLoc [0] = new SPoint (-60.0f, -10.0f);
     mLoc [1] = new SPoint (-60.0f, -35.0f);
     mLoc [2] = new SPoint (-60.0f, -60.0f);
     paused = false;
     plrP = 0;
     inputTmr = new STimer (0.35f);
     tmrT = Time.deltaTime;
     //transform.Translate( new Vector3(-1000.0f, -1000.0f,0.0f) );
 }
Example #37
0
        public void Rotate()
        {
            var color = new Vec3b(128, 192, 255);
            var p1    = new SPoint(0, 0, color);
            var p2    = new SPoint(10, 0);
            var p3    = new SPoint(20, 0);
            var s     = StrokeFactory.CreateRotatingStroke(new SPoint[] { p1, p2, p3 }, 90.0, 5.0);

            Assert.AreEqual(3, s.Count());
            PointListsHelper.AssertPointPresence(s, new SPoint[] {
                PointListsHelper.Shift(p1, 0, -5),
                PointListsHelper.Shift(p2, -5, 0),
                PointListsHelper.Shift(p3, 0, 5)
            });
        }
Example #38
0
    protected void Start()
    {
        startPos[0] = new SPoint(-24*SCALE_FAC, 20*SCALE_FAC);
        startPos[1] = new SPoint(-20*SCALE_FAC, 20*SCALE_FAC);
        startPos[2] = new  SPoint(20, 0);
        startPos[3] = new SPoint(20, 0);

        LoadStage ();
        numPlr = 2;
        for (int i=0; i<numPlr; i++) {
        //	player[i].fHelper.stats.id.num = i + 1;
        //	player[i].SetPos(startPos[i]);
        }
        matchModeOn=GameObject.FindGameObjectWithTag("MatchHelper").GetComponent<MatchHelper>().isMatch;
    }
Example #39
0
        public void MultipleIterationsByPolystroke()
        {
            const int numberOfIterations = 3;
            var       p1 = new SPoint(0, 0);
            var       p2 = new SPoint(10, 0);
            var       p3 = new SPoint(10, 10);
            var       p4 = new SPoint(0, 10);
            var       s  = new PolyStroke(new SPoint[] { p1, p2, p3, p4 });

            s.NumberOfIterations = numberOfIterations;
            var points = s.ToArray();

            Assert.AreEqual(4 * numberOfIterations, points.Length);
            PointListsHelper.AssertPointPresence(s, new SPoint[] { p1, p2, p3, p4 }, 3);
        }
Example #40
0
        void SudokuBoard_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (selected == null)
            {
                return;
            }

            if (e != null && ((e.KeyChar == 48 && board[selected] != 0) || (e.KeyChar > 48 && e.KeyChar <= 57)))
            {
                board[selected].ChangeOriginal(e.KeyChar - 48);
                Logger.Log("Changed cell", new Cell[] { board[selected] }, board[selected].ToString());
                CellChanged?.Invoke(board[selected]);
            }
            selected = null;
            ReDraw(false);
        }
Example #41
0
    public static void Main()
    {
        CPoint cp1 = new CPoint(5, 5);  // newobj
        SPoint sp1 = new SPoint(5, 5);  // call 생성자
        CPoint cp2 = new CPoint(2);
        SPoint sp2 = new SPoint(2);
        CPoint cp3 = new CPoint();
        SPoint sp3 = new SPoint();              // initobj

        Console.WriteLine($"{cp1.x}, {cp1.y}"); // 5, 5
        Console.WriteLine($"{sp1.x}, {sp1.y}"); // 5, 5
        Console.WriteLine($"{cp2.x}, {cp2.y}"); // 2, 1
        Console.WriteLine($"{sp2.x}, {sp2.y}"); // 2, 1
        Console.WriteLine($"{cp3.x}, {cp3.y}"); // 1, 1
        Console.WriteLine($"{sp3.x}, {sp3.y}"); // 0, 0
    }
Example #42
0
 // Use this for initialization
 void Start()
 {
     numPos = 3;
     menuSel = 0;
     vThresh = 0.5f;
     mLoc = new SPoint [numPos];
     mLoc [0] = new SPoint (100.0f, 5.0f);
     mLoc [1] = new SPoint (100.0f, -15.0f);
     mLoc [2] = new SPoint (100.0f, -35.0f);
     inputTmr = new STimer (lTime);
     selTmr = new STimer (lTime);
     mh = GameObject.FindGameObjectWithTag ("MatchHelper").GetComponent ("MatchHelper") as MatchHelper;
     DebugSelDisplay (mh.GetDebugMode ());
     stockNum = mh.GetStocks ();
     stockDisp.text=stockNum.ToString();
 }
Example #43
0
    public bool Fire(SPoint o, SPoint v)
    {
        //dir is the vector to travel in per second
        if(active)
            return false;
        active=true;
        pos=o;
        vel=v;
        ttl.SetTimer(2);
        if (ps != null) {
            ps.transform.position=new Vector3(pos.x, pos.y,0);
            ps.enableEmission=true;

        }
        return true;
    }
Example #44
0
        public static bool MoveTowards(SPoint Current_, SPoint Target_, float DistanceDelta_) // return true : reached
        {
            var Vector = Target_.GetSub(Current_);
            var Scalar = Vector.GetScalar();

            if (Scalar > DistanceDelta_)
            {
                Current_.Add(new SPoint(Vector.X * DistanceDelta_ / Scalar, Vector.Y * DistanceDelta_ / Scalar));
                return(false);
            }
            else
            {
                Current_.Set(Target_);
                return(true);
            }
        }
Example #45
0
 public static void TryReverse()
 {
     SPoint[] arr = new SPoint[5];
     for (int i = 0; i < arr.Length; i++)
     {
         arr[i] = new SPoint(i * 11, i * 22);
     }
     // Reverse((ValueType[])arr); // Cannot convert SPoint[] to ValueType[]
     Console.WriteLine("Reversed input:");
     Console.WriteLine("--------------------");
     foreach (SPoint q in arr)
     {
         Console.WriteLine(q);
     }
     Console.WriteLine("--------------------");
 }
Example #46
0
        public static bool IsCollidedRectRect(SRect Rect0_, SRect Rect1_, SPoint Dir_, SCollisionInfo CollisionInfo_)
        {
            if (Dir_.X > 0.0)
            {
                if (IsCollidedVSegmentVSegment(
                        new SVSegment(new SVLine(Rect0_.Right), Rect0_.Bottom, Rect0_.Top),
                        new SVSegment(new SVLine(Rect1_.Left), Rect1_.Bottom, Rect1_.Top),
                        Dir_, CollisionInfo_))
                {
                    return(true);
                }
            }
            else if (Dir_.X < 0.0)
            {
                if (IsCollidedVSegmentVSegment(
                        new SVSegment(new SVLine(Rect0_.Left), Rect0_.Bottom, Rect0_.Top),
                        new SVSegment(new SVLine(Rect1_.Right), Rect1_.Bottom, Rect1_.Top),
                        Dir_, CollisionInfo_))
                {
                    return(true);
                }
            }

            if (Dir_.Y > 0.0)
            {
                if (IsCollidedHSegmentHSegment(
                        new SHSegment(new SHLine(Rect0_.Top), Rect0_.Left, Rect0_.Right),
                        new SHSegment(new SHLine(Rect1_.Bottom), Rect1_.Left, Rect1_.Right),
                        Dir_, CollisionInfo_))
                {
                    return(true);
                }
            }
            else if (Dir_.Y < 0.0)
            {
                if (IsCollidedHSegmentHSegment(
                        new SHSegment(new SHLine(Rect0_.Bottom), Rect0_.Left, Rect0_.Right),
                        new SHSegment(new SHLine(Rect1_.Top), Rect1_.Left, Rect1_.Right),
                        Dir_, CollisionInfo_))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #47
0
    static void PassClassStruct()
    {
        double d1 = 1.1, d2 = 2.2;

        int[] a1 = new int[4], a2 = new int[4];
        M(d1, ref d2, a1, ref a2);
        Console.WriteLine("d1 = {0}, d2 = {1}", d1, d2);
        Console.WriteLine("a1.Length = {0}, a1[0] = {1}", a1.Length, a1[0]);
        Console.WriteLine("a2.Length = {0}, a2[0] = {1}", a2.Length, a2[0]);

        Point  pc1 = new Point(55, 555), pc2 = new Point(66, 666);
        SPoint ps1 = new SPoint(77, 777), ps2 = new SPoint(88, 888);

        M(pc1, ref pc2, ps1, ref ps2);
        Console.WriteLine("pc1 = {0}, pc2 = {1}", pc1, pc2);
        Console.WriteLine("ps1 = {0}, ps2 = {1}", ps1, ps2);
    }
Example #48
0
        public void RotationPreservesColorAndLineWidth()
        {
            var color = new Vec3b(128, 192, 255);
            var p1    = new SPoint(0, 0, color, 1);
            var p2    = new SPoint(10, 0, color, 2);
            var p3    = new SPoint(20, 0, color, 3);
            var s     = StrokeFactory.CreateRotatingStroke(new SPoint[] { p1, p2, p3 }, 90.0, 5.0);

            Assert.AreEqual(3, s.Count());
            var points = s.ToArray();

            Assert.AreEqual(color, points[0].Color);
            for (int i = 1; i < 3; i++)
            {
                Assert.AreEqual(i + 1, points[i].LineWidth);
            }
        }
Example #49
0
    public override void AttackDetect(Fighter plr)
    {
        AttkTrack[] aBox=null;
        int pState;
        SPoint rePos = new SPoint(0,0);

        stats.motion.pos.AddTo(rePos, 1);
        base.AttackDetect(plr);
        stats.motion.pos.AddTo(rePos, -1);
        if(psysword.atkMode>0){
            pState=psysword.atkMode;
            if((pState==SPC)||(is_B(pState))){
                psysword.stats.motion.pos.y-=12.0f;
                psysword.AttackDetect(plr);
                psysword.stats.motion.pos.y+=12.0f;
            }
        }
    }
Example #50
0
    public static void M1()
    {
        Point p = new Point(11, 111), q = new Point(22, 222);

        p   = q;
        p.x = 33;
        SPoint r = new SPoint(44, 444), s = new SPoint(55, 555);

        r   = s;
        r.x = 66;
        int[] iarr1 = new int[4];
        int[] iarr2 = iarr1;
        iarr1[0] = 77;
        SPoint[] sarr = new SPoint[3];
        sarr[0].x = 88;
        Console.WriteLine("q.x={0} s.x={1} iarr2[0]={2}", p.x, s.x, iarr2[0]);
        M2(2);
    }
        public void TestRequiresQuadPrecision()
        {
            string     connectionId  = "dummy";
            int        maxIterations = 100;
            CanvasSize canvasSize    = new CanvasSize(1000, 1000);

            //DPoint leftBot = new DPoint(-0.7764118407199196, 0.13437492059936854);
            //DPoint rightTop = new DPoint(-0.7764117329761986, 0.13437499747905846);

            SPoint leftBot  = new SPoint("-0.7764118407199196", "0.13437492059936854");
            SPoint rightTop = new SPoint("-0.7764118407199300", "0.13437499747905846");

            SCoords    coords = new SCoords(leftBot, rightTop);
            MapSection area   = new MapSection(new Point(0, 0), canvasSize.GetWholeUnits(Engine.BLOCK_SIZE));

            SMapWorkRequest mapWorkRequest        = new SMapWorkRequest("FET2", coords, canvasSize, area, maxIterations, connectionId);
            bool            requiresQuadPrecision = mapWorkRequest.RequiresQuadPrecision();
        }
        public void InterpolatedPointListTest()
        {
            var p1     = new SPoint(0, 0, new Vec3b(0, 0, 0));
            var p2     = new SPoint(10, 0, new Vec3b(20, 20, 20));
            var s      = new TestInterpolatingStroke(null);
            var points = s.GetPointsBetween(p1, p2).ToArray();
            var pTest  = new SPoint(5, 0, new Vec3b(10, 10, 10));

            Assert.AreEqual(11, points.Length);
            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(i, points[i].X);
                Assert.AreEqual(0, points[i].Y);
                for (int j = 0; j < 3; j++)
                {
                    Assert.AreEqual(2 * i, points[i].Color[j]);
                }
            }
        }
Example #53
0
        public Boolean TryMoveUnit(SPoint position, SPoint newPosition)
        {
            Boolean transferResult = _serverMap.TryMove(position, newPosition, out CHeroBase hero);

            if (transferResult)
            {
                String session = OperationContext.Current.SessionId;

                Task.Run(() =>
                {
                    foreach (CServerPlayer playerCallback in _players.Where(player => player.Session != session))
                    {
                        playerCallback.Callback.HeroHasMoved(hero, position, newPosition);
                    }
                });
            }

            return(transferResult);
        }
Example #54
0
        public void BasicOperations()
        {
            var sp = new SPoint(10, 20);

            sp.Color = new Vec3b(255, 255, 255);
            Assert.AreEqual(10, sp.X);
            Assert.AreEqual(20, sp.Y);

            var sp2 = new SPoint(sp);

            Assert.AreEqual(sp.X, sp2.X);
            Assert.AreEqual(sp.Y, sp2.Y);
            Assert.AreEqual(sp.Color, sp2.Color);
            Assert.AreEqual(sp, sp2);

            var color = new Vec3b(20, 30, 40);
            var sp3   = new SPoint(10, 20, new Vec3b(20, 30, 40));

            Assert.AreEqual(color, sp3.Color);
        }
        public static void Run()
        {
            SPoint point1 = new SPoint {
                X = 1, Y = 3
            };
            SPoint point1Copy = point1; //assigned by value

            point1.X = 3;
            System.Console.WriteLine("Point 1 X: {0}", point1.X);
            System.Console.WriteLine("Point 1 Copy X: {0}", point1Copy.X);

            CPoint point2 = new CPoint {
                X = 2, Y = 3
            };
            CPoint point2Copy = point2; //assigned by reference

            point2.X = 4;
            System.Console.WriteLine("Point 2 X: {0}", point2.X);
            System.Console.WriteLine("Point 2 Copy X: {0}", point2Copy.X);
        }
Example #56
0
            public SPoint Move(SPoint Point_) // return : Vector
            {
                if (!_Enabled)
                {
                    return(null);
                }

                _Vector.X = Point_.X - _Center.X;
                _Vector.Y = Point_.Y - _Center.Y;

                var Distance = CBase.Distance(_Center, Point_);

                if (Distance > _EffectiveRadius)
                {
                    var Ratio = _EffectiveRadius / Distance;
                    _Vector.X *= Ratio;
                    _Vector.Y *= Ratio;
                }

                return(_Vector);
            }
Example #57
0
    public Stats()
    {
        motion.lastPos=new SPoint();
        motion.pos=new SPoint();
        motion.accl=new SPoint();
        motion.move=new SPoint();
        motion.vel=new SPoint();
        walk.shuffle=new STimer(0.5f);
        walk.slopeAng=new SPoint();

        jump.tmr = new STimer (0.1f);

        jump.tmr = new STimer (0.12f);

        grav = 0.04f;
        grabRange = 24f;
        size = new SPoint ();
        land=new STimer(1.0f);
        dodge = new STimer ();
        flags.mBusy = false;
        flags.aBusy = false;
    }
Example #58
0
        private Boolean TransferUnit(IMovable movableUnit, SPoint newPosition)
        {
            ICell destinationCell = _map.GetCell(newPosition);

            if (destinationCell.Unit != null)
            {
                return(false);
            }

            Int32 transferEnergy = destinationCell.Terrain?.MovementPenalty ?? 0;

            if (transferEnergy > movableUnit.MovingEnergy)
            {
                return(false);
            }

            SPoint oldPosition = movableUnit.Position;

            _map.Move(movableUnit, oldPosition, newPosition);

            return(true);
        }
Example #59
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);
 }
Example #60
0
    public void AllocateFirstIndices(int num)
    {
        iLength = num;
        jLength = new int[iLength];
        hit = new bool[iLength][];
        atkAng = new float[iLength][];
        aVtx = new AttkVtx[iLength][];
        pBounds = new SPoint[iLength][];
        centre = new AttkVtx();
        polyNum = new int[iLength];
        for(int i = 0; i < iLength;i++){
            aVtx[i]=null;
            if(iLength>1)//issues with null arrays
                atkAng[i]=null;
            pBounds[i] = null;
            jLength[i]=0;
            polyNum[i]=1;

            hit[i]=new bool[4];
            for(int j=0;j<4;j++)
                hit[i][j]=false;
        }
    }