private AirMove ParseAirMove() { AirMove airMove = new AirMove(); airMove.BeginKeyframe = ParsePoint(); Eat(TokenType.ColonToken); ValueLiteral <int> direction = Eat(TokenType.ValueLiteral) as ValueLiteral <int>; switch (direction.Value) { case 0: airMove.Direction = AirMoveDirection.Left; break; case 1: airMove.Direction = AirMoveDirection.Center; break; case 2: airMove.Direction = AirMoveDirection.Right; break; default: throw new Exception($"Unexpected airmove direction {direction.Value}"); } return(airMove); }
private Note ParseGameObject() { ValueLiteral <int> TypeToken = Peek as ValueLiteral <int>; switch (TypeToken.Value) { case (int)GameObjectType.Tab: return(ParseTab()); case (int)GameObjectType.Hold: return(ParseHold()); case (int)GameObjectType.Slide: return(ParseSlide()); case (int)GameObjectType.AirShort: return(ParseAirShort()); case (int)GameObjectType.AirLong: return(ParseAirLong()); case (int)GameObjectType.AirMove: return(ParseAirMove()); default: throw new Exception($"Unexcepted Object Type {TypeToken}"); } }
private Slide ParseSlide() { Keyframe keyframe = new Keyframe(); keyframe = ParsePoint(); Eat(TokenType.ColonToken); ValueLiteral <int> attribute = Eat(TokenType.ValueLiteral) as ValueLiteral <int>; Eat(TokenType.CommaToken); ValueLiteral <int> id = Eat(TokenType.ValueLiteral) as ValueLiteral <int>; // 끝점일 때, 값 불러와 시작점, 끝점 기록후 중간 점은 리스트에 담아 리턴 if (attribute.Value == (int)GameObjectAttibuteType.End && SlidePoint.ContainsKey(id.Value)) { Slide slide = new Slide(); slide.EndKeyframe = keyframe; var slideList = SlidePoint[id.Value]; slide.BeginKeyframe = slideList.First(); slideList.RemoveAt(0); slide.Points = slideList; SlidePoint.Remove(id.Value); return(slide); } // 점일 때, 슬라이드 중간점 리스트에 삽입 else if (attribute.Value == (int)GameObjectAttibuteType.Point) { SlidePoint[id.Value].Add(keyframe); Slide slide = new Slide(); slide.IsDump = true; return(slide); } // 시작점일 때, 시작점 저장. else if (attribute.Value == (int)GameObjectAttibuteType.Begin) { SlidePoint[id.Value] = new List <Keyframe>(); SlidePoint[id.Value].Add(keyframe); Slide slide = new Slide(); slide.IsDump = true; return(slide); } // 폭발 else { throw new Exception($"Unexcepted end token {keyframe}"); } }
private AirLong ParseAirLong() { Keyframe keyframe = new Keyframe(); keyframe = ParsePoint(); Eat(TokenType.ColonToken); ValueLiteral <int> attribute = Eat(TokenType.ValueLiteral) as ValueLiteral <int>; Eat(TokenType.CommaToken); ValueLiteral <int> id = Eat(TokenType.ValueLiteral) as ValueLiteral <int>; // 끝점일 때, 시작점 불러와 작성후 리턴 if (AirLongPoint.ContainsKey(id.Value)) { AirLong airLong = new AirLong(); airLong.BeginKeyframe = AirLongPoint[id.Value]; airLong.EndKeyframe = keyframe; AirLongPoint.Remove(id.Value); return(airLong); } // 시작점일 때, 시작점 기록후 덤프값 리턴 else if (attribute.Value == (int)GameObjectAttibuteType.Begin) { AirLongPoint.Add(id.Value, keyframe); AirLong airLong = new AirLong(); airLong.IsDump = true; return(airLong); } // 시작점이 없는데 끝점이 나올때, 폭발 else { throw new Exception($"Unexcepted end token {keyframe}"); } }
private Hold ParseHold() { Keyframe keyframe = new Keyframe(); keyframe = ParsePoint(); Eat(TokenType.ColonToken); ValueLiteral <int> attribute = Eat(TokenType.ValueLiteral) as ValueLiteral <int>; Eat(TokenType.CommaToken); ValueLiteral <int> id = Eat(TokenType.ValueLiteral) as ValueLiteral <int>; // 끝점일 때, 시작점 불러와 반환 if (HoldPoint.ContainsKey(id.Value)) { Hold hold = new Hold(); hold.BeginKeyframe = HoldPoint[id.Value]; hold.EndKeyframe = keyframe; HoldPoint.Remove(id.Value); return(hold); } // 시작점일 때, 점 저장 else if (attribute.Value == (int)GameObjectAttibuteType.Begin) { HoldPoint.Add(id.Value, keyframe); Hold hold = new Hold(); hold.IsDump = true; return(hold); } // 폭발 else { throw new Exception($"Unexcepted end token {keyframe}"); } }