Ejemplo n.º 1
0
    public void MoveTheSquareHere(int tempX, int tempY, bool MakeTargetSquares)
    {
        if (tempX > GridSize | tempX <-GridSize | tempY> GridSize | tempY < -GridSize)
        {
            return;
        }

        GameObject workingPrefab;

        if (MakeTargetSquares)
        {
            workingPrefab = (GameObject)Instantiate(Resources.Load("prefabs/Target square prefab"));
        }
        else
        {
            workingPrefab = (GameObject)Instantiate(Resources.Load("prefabs/Effect square prefab"));
        }

        if (MakeTargetSquares)
        {
            TargetSquare workingSquare = workingPrefab.GetComponent <TargetSquare>();
            workingSquare.MoveToPoint(tempX, tempY);
        }
        else
        {
            EffectSquare workingEffectSquare = workingPrefab.GetComponent <EffectSquare>();
            workingEffectSquare.MoveToPointAndFadeOut(tempX, tempY);
        }
    }
Ejemplo n.º 2
0
 public override void Make(Position position)
 {
     if (position.Board[RookMove.SourceSquare.x, RookMove.SourceSquare.y] == null)
     {
         string s = "";
         for (int x = 0; x < Position.Size; x++)
         {
             for (int y = 0; y < Position.Size; y++)
             {
                 Piece piece = position.Board[x, y];
                 if (piece == null)
                 {
                     s += ".";
                 }
                 else
                 {
                     string t = "?";
                     if (piece is Pawn)
                     {
                         t = "p";
                     }
                     if (piece is Rook)
                     {
                         t = "r";
                     }
                     if (piece is Knight)
                     {
                         t = "n";
                     }
                     if (piece is Bishop)
                     {
                         t = "b";
                     }
                     if (piece is Queen)
                     {
                         t = "q";
                     }
                     if (piece is King)
                     {
                         t = "k";
                     }
                     if (piece.Color == Color.White)
                     {
                         t = t.ToUpper();
                     }
                     s += t;
                 }
             }
             s += "\n";
         }
         s += SourceSquare.ToString() + " " + TargetSquare.ToString();
         File.WriteAllText(@"/Users/danielmalec/Desktop/filed.txt", s);
     }
     position.Board[RookMove.TargetSquare.x, RookMove.TargetSquare.y] =
         position.Board[RookMove.SourceSquare.x, RookMove.SourceSquare.y].Move(RookMove.TargetSquare);
     position.Board[RookMove.SourceSquare.x, RookMove.SourceSquare.y] = null;
     base.Make(position);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Game start function
        /// </summary>
        private void startGame()
        {
            if (aisquares == null)
            {
                numberOfOpponents = 50;
                directions        = new int[numberOfOpponents];       //Make and fill array of random direction modifiers to apply to targets
                aisquares         = new Rectangle[numberOfOpponents]; //Make and fill array of target squares
            }

            xloc = 0;
            yloc = 0;

            //Fill array of target squares
            for (int i = 0; i < aisquares.Length; i++)
            {
                bool good = false;
                if (i < 24)
                {
                    good = true;
                }
                TargetSquare aitoadd    = new TargetSquare(globalSeed, good); //Create new target object
                Rectangle    fromtarget = aitoadd.makeTheShape();             //Get reutrned rectangle from target
                aisquares[i] = fromtarget;                                    //Add the target to the traget array
                mainGrid.Children.Add(aisquares[i]);                          //Add the target to the grid
                aisquares[i].Visibility = Visibility.Collapsed;
                directions[i]           = globalSeed.Next(0, 8);              //Add random direction modifier to square using global seed
            }

            //hide menu and display the game
            rectPlayer.Margin = new Thickness(xloc, yloc, 0, 0);
            lblScore.Margin   = new Thickness(xloc, yloc, 0, 0);

            MainMenu.Visibility   = Visibility.Collapsed;
            rectPlayer.Visibility = Visibility.Visible;
            lblScore.Visibility   = Visibility.Visible;
            playerScore           = 0;
            playerSize            = 20;
            speed = 2;
            lose  = false;
            //Show the targets
            for (int i = 0; i < aisquares.Length; i++)
            {
                aisquares[i].Visibility = Visibility.Visible;
            }


            aiClock.Enabled        = true; //start AI movement
            collisionTimer.Enabled = true; //start collision detection
        }
Ejemplo n.º 4
0
    /// <summary>
    /// Main method 2; Executes whatever action is set to happen
    /// </summary>
    public void ReleaseCursor()
    {
        switch (currentCursorAction)
        {
        case CursorActions.Info:
            ShowInfo();
            break;

        case CursorActions.StairMove:
            if (S.GameControlInst.MovesLeft > 0)
            {
                S.GameControlInst.AddMoves(-1);
                S.ShopControlInst.GoalCheck("Move X times in one turn");
                S.ShopControlInst.GoalCheck("Don't move X turns in a row");
                S.ShopControlInst.GoalCheck("Don't deal damage or move X turns in a row");
                S.ShopControlInst.GoalCheck("Don't move X turns in a row");
            }
            else
            {
                ButtonAnimate moveButton =
                    GameObject.Find("move end button").GetComponent <ButtonAnimate>();
                moveButton.ErrorAnimation();
            }
            break;

        case CursorActions.Move:
            if (walkableObstacleToWalkInto != null)
            {
                walkableObstacleToWalkInto.StepIn();
            }
            if (moveDirection != null)
            {
                playerObject.GetComponent <Player>().MoveClick(moveDirection);
            }
            else
            {
                Debug.LogError("there should be a move direction set already. oops");
            }
            break;

        case CursorActions.Poke:
            GridUnit playerGU = playerObject.GetComponent <GridUnit>();
            playerGU.PokeTowards(playerGU.AdjacentPosition(currentCursorTarget.GetComponent <GridUnit>()));
            break;

        case CursorActions.Punch:
            playerObject.GetComponent <Player>().Punch(currentCursorTarget);
            break;

        case CursorActions.TargetSquare:
            TargetSquare square = currentCursorTarget.GetComponent <TargetSquare>();
            if (Tutorial.TutorialLevel != 0)
            {
                if (square.XCoor == 0 && square.YCoor == -2)
                {
                    S.GameControlInst.gameObject.GetComponent <Tutorial>().TutorialTrigger(5);
                }
                else
                {
                    S.GameControlInst.gameObject.GetComponent <Tutorial>().TutorialMessage = "iolksdcbelp";
                    return;
                }
            }
            S.GameControlInst.TargetSquareCallback.TargetSquareCalledThis(square.XCoor, square.YCoor);
            break;

        case CursorActions.None:
            break;

        default:
            Debug.Log("shouldn't be showing info! bug!");
            break;
        }

        UnpresentCursor();
    }