public void Reset(int[] lengths, float xStart, float yStart, float xDelta, float yDelta) { if (lengths == null || lengths.Length == 0) { throw new Exception("Invalid lengths"); } // init Lengths = lengths; IsAngry = false; Row = 0; Column = 0; IsDone = false; XStart = xStart; YStart = yStart; XDelta = xDelta; YDelta = yDelta; // reset indexs TailIndex.Reset(); FaceIndex.Reset(); for (int i = 0; i < LegIndexes.Length; i++) { LegIndexes[i].Reset(); } }
public void Draw(IGraphics graphics) { // nothing to draw if (Lengths == null || Lengths.Length == 0) { return; } // draw paw prints (the tracks we have already been through for (int i = 0; i < Lengths.Length && i <= Row; i++) { var tx = XStart; var ty = YStart + (YDelta * i); var maxx = (i < Row) ? XStart + (Lengths[i] * XDelta) : XStart + (Column * XDelta) - Width; while (tx < maxx) { // display paw-prints graphics.Image(PawPrintImage.Image, tx, ty, Width, Height); tx += Width; } } // the cat reached the end, this should not be possible in a normal game if (IsDone) { return; } // set the cat x,y based on the current track var x = XStart + (XDelta * Column) - (Width * 0.9f); var y = YStart + (Row * YDelta); var index = 0; // add the body graphics.Image(BodyImage.Image, x, y, Width, Height); // draw legs for (int i = 0; i < LegIndexes.Length; i++) { index = LegIndexes[i].Increment(); graphics.Image(LegImages[i][index].Image, x, y, Width, Height); } // draw tail graphics.Image(TailImages[TailIndex.Increment()].Image, x, y, Width, Height); // draw face index = FaceIndex.Increment(); graphics.Image(FaceImages[index].Image, x, y, Width, Height); if (index < 7) { // add a mood graphics.Image(IsAngry ? AngryImage.Image : HappyImage.Image, x, y, Width, Height); } }