public FroggerAnimation(FroggerAnimationSpec spec) { this.spec=spec; this.frame=0; this.state=0.0f; }
private static Dictionary<string, FroggerAnimationSpec> load_animations(string filename) { Dictionary<string, FroggerAnimationSpec> specs=new Dictionary<string, FroggerAnimationSpec>(); StreamReader reader=new StreamReader(Config.GetDataDir()+filename); String s=reader.ReadLine(); while(s!=null) { //jeżeli linia kończy się \ to dołącz następną linię if(s.EndsWith("\\")) { //s = s.Remove(s.Length - 1); string tmp = reader.ReadLine(); if (tmp == null) s = null; else s += tmp; continue; } String[] fields=Regex.Split(s,"[^\\w\\._]+"); if(fields.Length>=3 && !s.StartsWith("#")) { String name=fields[0]; String img_name=fields[1]; int length=int.Parse(fields[2]); FroggerAnimationSpec spec=new FroggerAnimationSpec(); spec.image=load_image(img_name); spec.frames=new SysRectangle[length]; spec.times=new float[length]; for(int i=0;i<length;i++) { if("INF".Equals(fields[i*5+3])) spec.times[i]=float.PositiveInfinity; else spec.times[i]=float.Parse(fields[i*5+3].Replace('.',',')); spec.frames[i]=new SysRectangle( int.Parse(fields[i*5+4]), int.Parse(fields[i*5+5]), int.Parse(fields[i*5+6]), int.Parse(fields[i*5+7]) ); } specs.Add(name,spec); } s=reader.ReadLine(); } return specs; }