// エッジを取得 public List <ArrangementPosition> GetEdgePositions() { var edgePositions = new List <ArrangementPosition> (); var diffs = new List <ArrangementDiff> () { new ArrangementDiff() { dx = -1, dz = -1 }, new ArrangementDiff() { dx = 1, dz = 1 }, new ArrangementDiff() { dx = -1, dz = 1 }, new ArrangementDiff() { dx = 1, dz = -1 } }; foreach (var arrangementPosition in ArrangementPositions) { foreach (var diff in diffs) { var diffPosition = new ArrangementPosition() { x = arrangementPosition.x + diff.dx, z = arrangementPosition.z + diff.dz }; var foundOwnIndex = ArrangementPositions.FindIndex(position => position == diffPosition); if (foundOwnIndex >= 0) { continue; } var foundEdgeIndex = edgePositions.FindIndex(position => position == diffPosition); if (foundEdgeIndex >= 0) { continue; } edgePositions.Add(diffPosition); } } return(edgePositions); }
private IPlayerArrangementTarget Find(ArrangementPosition arrangementPosition) { foreach (var arrangemetTarget in this.arrangementTargetStore) { var findIndex = arrangemetTarget.ArrangementPositions.FindIndex(targetArrangementPosition => { if (targetArrangementPosition.x != arrangementPosition.x) { return(false); } if (targetArrangementPosition.z != arrangementPosition.z) { return(false); } return(true); }); // 見つかったら返却 if (findIndex >= 0) { return(arrangemetTarget); } } return(null); }