Exemple #1
0
        internal bool directionX(int T)
        {
            Vector2Int Getbutton = Vis.Floattoint(_Mouse_Gameobject.transform.position);

            if (Getbutton.x == T)
            {
                return(true);
            }
            return(false);
        }
Exemple #2
0
 //检查地图中目标位置是否都已经放置了目标
 internal bool TargetCheck()
 {
     foreach (GameObject i in Target)
     {
         if (i != null)
         {
             Vector2Int T = Vis.Floattoint(i.transform.position);
             if (mapData[T.x, T.y] == null || mapData[T.x, T.y].tag != BoxTag.Box_Target.ToString())
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemple #3
0
 //朝上运动
 //朝上推动时返回最远距离的Gameobject
 GameObject UPGameobjet()
 {
     for (int i = mMapData.Distance - 1; i > -1; i--)
     {
         if (mMapData.mapData[buttonObjectup.X_axis, i] != null)
         {
             Vector2Int V = Vis.Floattoint(mMapData.mapData[buttonObjectup.X_axis, i].transform.position);
             if (FindPostionUP(V, new Vector2Int(V.x, V.y + 1)) != V)
             {
                 return(mMapData.mapData[buttonObjectup.X_axis, i]);
             }
         }
     }
     return(null);
 }
Exemple #4
0
 //朝下运动
 //朝下推动时返回最远距离的Gameobjt
 GameObject Downameobjet()
 {
     for (int i = mMapData.Distance; i < mMapData.MapHigh; i++)
     {
         if (mMapData.mapData[buttonObjectdown.X_axis, i] != null)
         {
             Vector2Int V = Vis.Floattoint(mMapData.mapData[buttonObjectdown.X_axis, i].transform.position);
             if (FindPostionDown(V, new Vector2Int(V.x, V.y - 1)) != V)
             {
                 return(mMapData.mapData[buttonObjectdown.X_axis, i]);
             }
         }
     }
     return(null);
 }
Exemple #5
0
 //朝左推动时返回最远距离的Gameobjt
 GameObject LastGameobjet_Left()
 {
     for (int i = mMapData.MapWidth - mMapData.Distance; i < mMapData.MapWidth; i += 1)
     {
         if (mMapData.mapData[i, buttonObjectleft.Y_axis] != null)
         {
             Vector2Int V = Vis.Floattoint(mMapData.mapData[i, buttonObjectleft.Y_axis].transform.position);
             if (FindPostionLeft(V, new Vector2Int(V.x - 1, V.y)) != V)
             {
                 return(mMapData.mapData[i, buttonObjectleft.Y_axis]);
             }
         }
     }
     return(null);
 }
Exemple #6
0
 //朝右推动时返回最远距离的Gameobject
 GameObject LastGameobjet()
 {
     for (int i = mMapData.Distance - 1; i > -1; i -= 1)
     {
         if (mMapData.mapData[i, buttonObjectright.Y_axis] != null)
         {
             Vector2Int V = Vis.Floattoint(mMapData.mapData[i, buttonObjectright.Y_axis].transform.position);
             if (FindPostion(V, new Vector2Int(V.x + 1, V.y)) != V)
             {
                 return(mMapData.mapData[i, buttonObjectright.Y_axis]);
             }
         }
     }
     return(null);
 }
Exemple #7
0
 //初始化遍历各个物体的位置
 public void ForeachBox(GameObject Box)
 {
     foreach (Transform i in Box.GetComponentInChildren <Transform>())
     {
         if (i.tag == BoxTag.Box.ToString() || i.tag == BoxTag.Box_Target.ToString())
         {
             Vector2Int T = Vis.Floattoint(i.position);
             mapData[T.x, T.y] = i.gameObject;
         }
         if (i.tag == BoxTag.Target.ToString())
         {
             Vector2Int T = Vis.Floattoint(i.position);
             Target[T.x, T.y] = i.gameObject;
         }
     }
 }
Exemple #8
0
    //开始朝上移动
    IEnumerator StartMoveUP()
    {
        Vector2Int T = Vis.Floattoint(direction._Mouse_Gameobject.transform.position);

        buttonObjectup = new ButtonObject()
        {
            X_axis = T.x
        };
        if (UPGameobjet() != null)
        {
            for (int i = 0; i < (mMapData.Distance * mMapData.Distance); i++)
            {
                yield return(new WaitForSeconds(0.01f));

                MoveUP();
            }
        }
    }
Exemple #9
0
    //开始朝右移动
    IEnumerator StartMoveRight()
    {
        Vector2Int T = Vis.Floattoint(direction._Mouse_Gameobject.transform.position);

        buttonObjectright = new ButtonObject()
        {
            Y_axis = T.y
        };

        for (int i = 0; i < (mMapData.Distance * mMapData.Distance); i++)
        {
            if (LastGameobjet() != null)
            {
                yield return(new WaitForSeconds(0.01f));

                MoveRight();
            }
            //mMapData.UpdateMapData(Box_mapData);
        }
    }
Exemple #10
0
 //朝下运动
 void MoveDown()
 {
     if (Downameobjet() != null)
     {
         var Thepostion = Vis.Floattoint(Downameobjet().transform.position);
         //获取新的坐标
         Vector2Int Newpostion = FindPostionDown(Thepostion, new Vector2Int(Thepostion.x, Thepostion.y - 1));
         if (Mathf.Abs(Thepostion.y - Newpostion.y) <= 1)
         {
             if (Thepostion != Newpostion)
             {
                 mMapData.mapData[Thepostion.x, Thepostion.y].transform.position = new Vector3(Newpostion.x, Newpostion.y, 0);
                 mMapData.mapData[Newpostion.x, Newpostion.y] = mMapData.mapData[Thepostion.x, Thepostion.y];
                 mMapData.mapData[Thepostion.x, Thepostion.y] = null;
             }
         }
         if (Mathf.Abs(Thepostion.y - Newpostion.y) > 1)
         {
             iteratePostionDown(Newpostion, Thepostion);
         }
     }
 }
Exemple #11
0
 //朝左运动
 void MoveLeft()
 {
     if (LastGameobjet_Left() != null)
     {
         var Thepostion = Vis.Floattoint(LastGameobjet_Left().transform.position);
         //获取新的坐标
         Vector2Int Newpostion = FindPostionLeft(Thepostion, new Vector2Int(Thepostion.x - 1, Thepostion.y));
         if (Mathf.Abs(Thepostion.x - Newpostion.x) <= 1)
         {
             if (Thepostion != Newpostion)
             {
                 mMapData.mapData[Thepostion.x, Thepostion.y].transform.position = new Vector3(Newpostion.x, Newpostion.y, 0);
                 mMapData.mapData[Newpostion.x, Newpostion.y] = mMapData.mapData[Thepostion.x, Thepostion.y];
                 mMapData.mapData[Thepostion.x, Thepostion.y] = null;
             }
         }
         if (Mathf.Abs(Thepostion.x - Newpostion.x) > 1)
         {
             iteratePostionleft(Newpostion, Thepostion);
         }
     }
 }