Esempio n. 1
0
    private void RUN_NONE_SELECTED()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit2D hit = Physics2D.Raycast(Input.mousePosition, Vector2.zero);

            if (hit.collider != null)
            {
                if (hit.collider.GetComponent <ED_FM_Ply>() != null)
                {
                    Debug.Log("Hit grid square");
                    Debug.Log(hit.transform.position);
                    ED_FM_Ply p = hit.collider.GetComponent <ED_FM_Ply>();
                    for (int i = 0; i < mAths.Count; i++)
                    {
                        if (mAths[i].mTag == p.mTag)
                        {
                            ixPly = i;
                            EXIT_UNSELECTED();
                            ENTER_SELECTED();
                            break;
                        }
                    }
                }
            }
        }
    }
Esempio n. 2
0
    private void LoadAndDisplayFormation(string name)
    {
        DATA_Formation f = IO_Formations.FLOAD_FORMATION(name);

        Debug.Log("Num Players: " + f.mSpots.Length);
        for (int i = 0; i < f.mSpots.Length; i++)
        {
            int x = (int)mSnapSpot.x;
            // int y = (int)mSnapSpot.y;
            int y = 0;
            x += (int)(f.mSpots[i].x / 2);
            y += (int)f.mSpots[i].y / 2;
            Vector3 vPos  = rGrid.FGetPos(x, y);
            var     clone = Instantiate(PF_Player, vPos, transform.rotation);
            clone.rectTransform.SetParent(rGrid.transform);

            ED_FM_Ply p = clone.GetComponent <ED_FM_Ply>();
            p.mTag = f.mTags[i];
            p.x    = x;
            p.y    = y;
            mAths.Add(p);
        }
    }
Esempio n. 3
0
    // Pass in how far to the right, and up you want to move them.
    private void RepositionPlayer(ED_FM_Ply p, int x, int y)
    {
        int newX = p.x + x;
        int newY = p.y - y;

        foreach (ED_FM_Ply ply in mAths)
        {
            if (ply.x == newX && ply.y == newY)
            {
                Debug.Log("There's already a player on that spot");
                return;
            }
        }

        p.x += x;
        if (p.x > rGrid.mAxisLength - 1)
        {
            p.x = rGrid.mAxisLength - 1;
        }
        if (p.x < 0)
        {
            p.x = 0;
        }
        p.y -= y;
        if (p.y > rGrid.mAxisLength - 1)
        {
            p.y = rGrid.mAxisLength - 1;
        }
        if (p.y < 0)
        {
            p.y = 0;
        }
        Vector3 v = rGrid.FGetPos(p.x, p.y);

        p.transform.position = v;
    }