private bool tapCard(TouchType eventtype, TouchRect touchbox, int x, int y, bool collide) { if (eventtype == TouchType.TouchDown) { if (State.CardAnimationMotion != null) { return(false); } Client.PlaySoundEffect(Assets.Sounds.Click); var gc = (Goal)touchbox.State; IImage goalImage = GoalPiece.GetGoalImage(gc); Goal[] goals = GameService.ClassicGameState.UnusedGoals; int topRow = goals.Length / 2; int bottomRow = goals.Length / 2 + goals.Length % 2; int posx, posy; int index = Array.IndexOf(goals, gc); int yAnimateOffset = 0; if (index < topRow) { int centerOffset = (Positions.BottomCardAreaWidth / (topRow)) / 2; posx = ((Positions.BottomCardAreaWidth / topRow * (index))) + centerOffset; posy = (Positions.BottomCardSize / 2) - Positions.CardShadowHeight; yAnimateOffset = 0; } else { int centerOffset = (Positions.BottomCardAreaWidth / (bottomRow)) / 2; posx = ((Positions.BottomCardAreaWidth / bottomRow * (index - topRow))) + centerOffset; posy = Positions.BottomCardSize - 40 + Positions.BottomCardSize / 2 - Positions.CardShadowHeight; yAnimateOffset = 300; } State.CurrentlySelectedGoal = gc; State.CardAnimationMotion = MotionManager.StartMotion(posx, posy, new AnimationMotion(Positions.Layout.Width / 2, posy - 850 - yAnimateOffset, 1500, AnimationEasing.BounceEaseIn)) .Motion(new WaitMotion(1000)) .Motion(new AnimationMotion(Positions.Layout.Width / 2, -3000, 1000, AnimationEasing.CubicEaseOut)) .OnRender((layer, posX, posY, animationIndex, percentDone) => { MainLayer.DrawImage(goalImage, posX, posY, true); }) .OnComplete(() => { gc.Used = true; GameService.ClassicGameState.CurrentGoal = gc; State.CardAnimationMotion = null; GameService.ClassicGameState.GameState = GameSelectionState.SearchingBoard; ScreenTransitioner.ChangeToBoardViewingScreen(); }); return(false); } return(true); }
void LoadPrefabs() { movablePiecePrefab = Resources.Load <NormalPiece>("Prefabs/GamePieces/NormalPiece"); backgroundPiece = Resources.Load <GameObject>("Prefabs/GamePieces/Background"); staticPiecePrefab = Resources.Load <StaticPiece>("Prefabs/GamePieces/StaticPiece"); goalPiecePrefab = Resources.Load <GoalPiece>("Prefabs/GamePieces/Goal"); objectivePiecePrefab = Resources.Load <ObjectivePiece>("Prefabs/GamePieces/Objective"); }
private void drawBottomInfo() { IImage baseImage = GoalPiece.GetBaseImage(GameService.ClassicGameState.CurrentGoal); IImage goalImage = GoalPiece.GetGoalImage(GameService.ClassicGameState.CurrentGoal); IImage goalArrow = Assets.Images.Layouts.Arrow; IImage smallGoalArrow = Assets.Images.Layouts.Arrow; if ((GameService.ClassicGameState.GameState == GameSelectionState.ChooseNumber && GameService.ClassicGameState.ChosenNumbers.Count == 0) || GameService.ClassicGameState.GameState == GameSelectionState.SearchingBoard) { MainLayer.DrawImage(Assets.Images.Layouts.HelperImage1, Positions.Help1Position, true); MainLayer.DrawImage(goalArrow, Positions.CardArrowPosition.X, Positions.CardArrowPosition.Y, true); MainLayer.DrawImage(baseImage, Positions.CardCharacterPosition.X, Positions.CardCharacterPosition.Y, 192, 192, true); MainLayer.DrawImage(goalImage, Positions.CardGoalPosition.X, Positions.CardGoalPosition.Y, 192, 192, true); MainLayer.DrawImage(Assets.Images.Layouts.HelperImage2, Positions.Help2Position, true); } else { int index = 0; for (int chosenNumberIndex = Math.Max(GameService.ClassicGameState.ChosenNumbers.Count - 4, 0); chosenNumberIndex < GameService.ClassicGameState.ChosenNumbers.Count; chosenNumberIndex++) { ChosenNumber chosenNumber = GameService.ClassicGameState.ChosenNumbers[chosenNumberIndex]; if (chosenNumberIndex == GameService.ClassicGameState.ChosenNumbers.Count - 1) { IImage flagImage = Assets.Images.Character.Banners.Big.LongBanner[chosenNumber.Character.CharacterNumber + 1]; MainLayer.DrawImage(flagImage, Positions.FlagLongPositions[index].X, Positions.FlagLongPositions[index].Y, true); MainLayer.DrawString((Assets.Fonts.BabyDoll._90), chosenNumber.Number.ToString(), Positions.FlagLongPositionNumbers[index].X, Positions.FlagLongPositionNumbers[index].Y); } else { IImage flagImage = Assets.Images.Character.Banners.Small.ShortBanner[chosenNumber.Character.CharacterNumber + 1]; MainLayer.DrawImage(flagImage, Positions.FlagPositions[index].X, Positions.FlagPositions[index].Y, true); MainLayer.DrawString((Assets.Fonts.BabyDoll._90), chosenNumber.Number.ToString(), Positions.FlagPositionNumbers[index].X, Positions.FlagPositionNumbers[index].Y); } if (GameService.ClassicGameState.GameState != GameSelectionState.ChooseNumber) { long timeLeft = Math.Max(GetTimeLeft(), 0); MainLayer.DrawString((Assets.Fonts.BabyDoll._240), timeLeft.ToString(), Positions.TimePosition.X, Positions.TimePosition.Y, Positions.BlackColor); MainLayer.DrawString((Assets.Fonts.BabyDoll._48), "time left", Positions.TimePosition.X, Positions.TimePosition.Y + 100, Positions.BlackColor); } index++; } MainLayer.DrawImage(baseImage, Positions.SmallCardCharacterPosition.X, Positions.SmallCardCharacterPosition.Y, 150, 150, true); MainLayer.DrawImage(smallGoalArrow, Positions.SmallCardArrowPosition.X, Positions.SmallCardArrowPosition.Y, 50, 30, true); MainLayer.DrawImage(goalImage, Positions.SmallCardGoalPosition.X, Positions.SmallCardGoalPosition.Y, 150, 150, true); } }
private void drawBottomInfo() { MainLayer.Save(); MainLayer.Translate(0, BoardConstants.TopAreaHeight); IImage smallGoalArrow = Assets.Images.Layouts.Arrow; int index = 0; for (int chosenNumberIndex = Math.Max(GameService.ClassicGameState.ChosenNumbers.Count - 4, 0); chosenNumberIndex < GameService.ClassicGameState.ChosenNumbers.Count; chosenNumberIndex++) { ChosenNumber chosenNumber = GameService.ClassicGameState.ChosenNumbers[chosenNumberIndex]; if (chosenNumberIndex == GameService.ClassicGameState.ChosenNumbers.Count - 1) { IImage flagImage = Assets.Images.Character.Banners.Big.LongBanner[chosenNumber.Character.CharacterNumber + 1]; MainLayer.DrawImage(flagImage, Positions.FlagLongPositions[index].X, Positions.FlagLongPositions[index].Y, true); MainLayer.DrawString((Assets.Fonts.BabyDoll._90), chosenNumber.Number.ToString(), Positions.FlagLongPositionNumbers[index].X, Positions.FlagLongPositionNumbers[index].Y); } else { IImage flagImage = Assets.Images.Character.Banners.Small.ShortBanner[chosenNumber.Character.CharacterNumber + 1]; MainLayer.DrawImage(flagImage, Positions.FlagPositions[index].X, Positions.FlagPositions[index].Y, true); MainLayer.DrawString((Assets.Fonts.BabyDoll._90), chosenNumber.Number.ToString(), Positions.FlagPositionNumbers[index].X, Positions.FlagPositionNumbers[index].Y); } MainLayer.DrawString((Assets.Fonts.BabyDoll._240), getMovesLeft().ToString(), Positions.NumberPosition, Positions.BlackColor); MainLayer.DrawString((Assets.Fonts.BabyDoll._48), "total moves", Positions.NumberPosition.X, Positions.NumberPosition.Y + 100, Positions.BlackColor); index++; } MainLayer.DrawImage(smallGoalArrow, Positions.SmallCardArrowPosition.X, Positions.SmallCardArrowPosition.Y, true); IImage baseImage = GoalPiece.GetBaseImage(GameService.ClassicGameState.CurrentGoal); IImage goalImage = GoalPiece.GetGoalImage(GameService.ClassicGameState.CurrentGoal); MainLayer.DrawImage(baseImage, Positions.SmallCardCharacterPosition.X, Positions.SmallCardCharacterPosition.Y, 150, 150, true); MainLayer.DrawImage(smallGoalArrow, Positions.SmallCardArrowPosition.X, Positions.SmallCardArrowPosition.Y, 50, 30, true); MainLayer.DrawImage(goalImage, Positions.SmallCardGoalPosition.X, Positions.SmallCardGoalPosition.Y, 150, 150, true); MainLayer.Restore(); MainLayer.DrawRectangle(new Color(252, 252, 252), 0, Positions.UndoButtonRect.Y, Layout.Width, Positions.UndoButtonRect.Height); MainLayer.DrawRectangle(new Color(37, 170, 255), Positions.UndoButtonRect); MainLayer.DrawString((Assets.Fonts.BabyDoll._120), "Undo", Positions.UndoButtonRect.Center); MainLayer.DrawRectangle(new Color(37, 170, 255), Positions.PassButtonRect); MainLayer.DrawString((Assets.Fonts.BabyDoll._120), "Pass", Positions.PassButtonRect.Center); }
private void PlayerWon(GoalPiece goal) { Point pos = Positions.CharacterPositions[State.CurrentChosenNumber.Character.CharacterNumber]; State.Congrats = true; IImage goalImage = GoalPiece.GetGoalImage(GameService.ClassicGameState.CurrentGoal); State.CardAnimationMotion = MotionManager.StartMotion(Positions.CongratsPosition.X, Positions.CongratsPosition.Y, new WaitMotion(200)) .Motion(new AnimationMotion(pos.X + 0, pos.Y + BoardConstants.TopAreaHeight, 2000, AnimationEasing.BounceEaseOut)) .OnRender((layer, posX, posY, animationIndex, percentDone) => { MainLayer.Save(); MainLayer.SetDrawingTransparency(1 - percentDone); MainLayer.DrawImage(goalImage, posX, posY, 220, 220, true); MainLayer.Restore(); }).OnComplete(() => { GameService.ClassicGameState.Board.SquarePieces.Remove(goal); GameService.ClassicGameState.CharacterWon(State.CurrentChosenNumber.Character); ScreenTransitioner.ChangeToBoardCardSelectionScreen(); }); }
public void SetGoalPiece(GoalPiece goalPiece) { this.goalPiece = goalPiece; this.goalPosBoard = this.goalPiece.Position; }