public void Clear() { StartStronghold = null; EndStronghold = null; LineList.Clear(); ValidLineCountChange = null; ValidLineCount = 0; }
private void PointDown() { m_ChainInfo.StartStronghold = null; m_ChainInfo.EndStronghold = null; if (m_ChainInfo.LineList == null) { m_ChainInfo.LineList = new List <Line>(); } m_ChainInfo.LineList.Clear(); //第一个点 m_Line = null; m_LineOrigin = null; Cell c = GetCell(Input.mousePosition); if (c != null) { Stronghold s = c.GetStronghold(); if (s != null) { if (!s.HasConnectStronghold()) { bool isOk = true; if (GameLevelSceneCtrl.Instance.IsGuide) { if (GameLevelSceneCtrl.Instance.ContainsGuideObj(c.gameObject)) { isOk = true; } else { isOk = false; } } if (isOk) { GameObject go = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.Item, "Building/Line", isCache: true, isClone: true); m_Line = go.GetComponent <Line>(); m_Line.AddCell(c); m_LineOrigin = c; m_Line.Parent = null; m_ChainInfo.Start(s, OnValidLineCountChange); m_ChainInfo.AddLine(m_Line); EazySoundManager.PlaySound(ClickStronghold); } } else { ChainInfo info = m_AllChainInfo.Find(x => x.StartStronghold == s || x.EndStronghold == s); if (!info.IsEmpty()) { m_AllChainInfo.Remove(info); info.Destory(); } } } } }
public void Start(Stronghold startStronghold, Action <int> validLineCountChange) { StartStronghold = startStronghold; ValidLineCountChange = validLineCountChange; if (StartStronghold != null) { ValidLineCount = StartStronghold.Range; } ValidLineCount = StartStronghold.Range; }
public void Destory() { if (StartStronghold != null) { StartStronghold.ConnectStronghold = null; StartStronghold.ShowOrHideFlag(false); StartStronghold = null; } if (EndStronghold != null) { EndStronghold.ConnectStronghold = null; EndStronghold.ShowOrHideFlag(false); EndStronghold = null; } int count = LineList.Count; for (int i = 0; i < count; i++) { GameObject.Destroy(LineList[LineList.Count - 1].gameObject); LineList.RemoveAt(LineList.Count - 1); } ValidLineCount = 0; Clear(); }
private void Point() { if (m_LineOrigin != null) { Cell c = GetCell(Input.mousePosition); if (c != null) { bool isNeighbours = GridManager.Instance.IsNeighbours(m_LineOrigin.Node, c.Node); //有效点 if (isNeighbours) { //判断是否回退 if (m_Line.Parent != null && c == m_Line.Parent.Cell1) { Line line1 = m_Line; Line line2 = m_Line.Parent; if (line2.Parent == null) { m_Line = line2; } else { m_Line = line2.Parent; } if (line1 != null) { m_ChainInfo.RemoveLine(line1); Destroy(line1.gameObject); } if (line2 != null) { m_ChainInfo.RemoveLine(line2); Destroy(line2.gameObject); } } //判断是否和其他点相交 if (!CheckLineIntersect(c, m_Line)) { //判断是否在范围内 if (m_ChainInfo.CheckInRange()) { //线段完成 m_Line.AddCell(c); m_LineOrigin = null; //判断是否是终点 Stronghold s = c.GetStronghold(); if (s != null && !s.HasConnectStronghold()) { //链条成功 if (s != m_ChainInfo.StartStronghold) { m_ChainInfo.EndStronghold = s; m_ChainInfo.Scueess(); //复制 m_AllChainInfo.Add(m_ChainInfo.Clone()); m_ChainInfo.Clear(); GameLevelSceneCtrl.Instance.Turn(false); EazySoundManager.PlaySound(ClickStronghold); OnValidLineCountChange(-1); if (OnGuideEnd != null) { OnGuideEnd(); } } } else { //下一条线的起点 //第一点 m_LineOrigin = c; GameObject go = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.Item, "Building/Line", isCache: true, isClone: true); Line line = go.GetComponent <Line>(); line.Parent = m_Line; m_Line = line; m_Line.AddCell(m_LineOrigin); m_ChainInfo.AddLine(m_Line); EazySoundManager.PlaySound(ClickCell); } } else { OnInvalidPoint(true); } } else { OnInvalidPoint(true); } } else { OnInvalidPoint(); } } else { OnInvalidPoint(); } } }