public void SetObjPointData(IOnPointObject obj, Vector2Int index, int state) { int pointIndex = index.x + index.y * 10; int pivotNum; Pivot pivot; PointData data = null; switch (obj.GetObjType()) { case ObjectType.Reflector: int setState = state; for (int i = 0; i < 6; i++) { setState %= 6; pivotNum = setState; if (setState != 0) { pivotNum--; } pivot = (Pivot)Enum.ToObject(typeof(Pivot), pivotNum); data = GetPointData(pointIndex, pivot); if (data == null) { setState++; continue; } if (data.CanSetObject()) { obj.SetState(setState); obj.SetPosition(data.GetPosition()); obj.SetPointIndex(index); data.SetObjectType(obj.GetObjType()); return; } setState++; } obj.SetState(-1); break; case ObjectType.Goal: case ObjectType.Start: case ObjectType.Wall: case ObjectType.Coin: for (int i = 0; i < Enum.GetNames(typeof(Pivot)).Length; i++) { data = GetPointData(pointIndex, (Pivot)Enum.ToObject(typeof(Pivot), i)); if (data == null) { continue; } if (!data.CanSetObject()) { if (i == 0 || data.GetCurrentObjType() == ObjectType.Reflector) { return; } } } for (int i = 0; i < Enum.GetNames(typeof(Pivot)).Length; i++) { data = GetPointData(pointIndex, (Pivot)Enum.ToObject(typeof(Pivot), i)); if (data == null) { continue; } data.SetObjectType(obj.GetObjType()); } Vector3 offset = new Vector3(0, 0, 0); if (obj.GetObjType() == ObjectType.Goal) { offset = m_pivotPoses[state % 4]; } if (obj.GetObjType() == ObjectType.Start) { offset = m_pivotPoses[(state + 2) % 4]; } data = GetPointData(pointIndex, Pivot.Center); obj.SetState(state); obj.SetPointIndex(index); obj.SetPosition(data.GetPosition() + offset); data.SetObjectType(obj.GetObjType()); break; } }