public override void OnOpen(Intent intent)
    {
        base.OnOpen(intent);
        Debugger.Log("MainPanel Open");
        string ip = PlayerPrefs.GetString("hostIp");

        if (ip != "")
        {
            ipInput.value = ip;
        }
        FieldRoadStation s1 = new FieldRoadStation()
        {
            type  = FieldRoadStationType.Rail,
            point = new ChessPoint(1, 5),
        };
        FieldRoadStation s2 = new FieldRoadStation()
        {
            type  = FieldRoadStationType.Barrack,
            point = new ChessPoint(1, 6),
        };

        Debugger.Warn(ChessAgainst.IsBarrack(new ChessPoint(1, 7)));
        Debugger.Warn(ChessAgainst.InRailArea(new ChessPoint(0, 7)));
        Debugger.Warn(ChessAgainst.InRailArea(new ChessPoint(1, 6)));
        Debugger.Warn(ChessAgainst.InRailArea(new ChessPoint(1, 10)));
        Debugger.Warn(ChessAgainst.InRailArea(new ChessPoint(4, 6)));
        //App.Manager.UI.ReplaceView("UIGamePanel");
        //OnSetIp();
    }
Example #2
0
    /// <summary>
    /// 初始化战场的道路连接数据
    /// </summary>
    public void InitFieldMap()
    {
        m_MapRoadStations.Clear();
        for (int i = 0; i < 12; i++)
        {
            for (int j = 0; j < 5; j++)
            {
                FieldRoadStation roadStation = new FieldRoadStation();
                roadStation.point = new ChessPoint(j, i);
                if (ChessAgainst.InRailArea(roadStation.point))
                {
                    roadStation.type = FieldRoadStationType.Rail;
                }
                else if (ChessAgainst.IsBarrack(roadStation.point))
                {
                    roadStation.type = FieldRoadStationType.Barrack;
                }
                roadStation.id = m_MapRoadStations.Count;
                m_MapRoadStations.Add(roadStation);
            }
        }
        List <int> connetedIds = new List <int>();

        for (int i = 0; i < m_MapRoadStations.Count; i++)
        {
            connetedIds.Clear();
            for (int j = 0; j < m_MapRoadStations.Count; j++)
            {
                if (i != j)
                {
                    if (ChessAgainst.IsConnected(m_MapRoadStations[i], m_MapRoadStations[j]))
                    {
                        connetedIds.Add(j);
                        //Debugger.Warn(m_MapRoadStations[i].point.ToString()+" => "+ m_MapRoadStations[j].point.ToString());
                    }
                }
            }
            m_MapRoadStations[i].connectedPointIds = connetedIds.ToArray();
        }
    }