Exemple #1
0
		public void SwapPiece(GameModel.Piece piece1, GameModel.Piece piece2, GameModel.Square toSqr, GameModel.Intersection toIntr)
		{	
			MovePiece(piece1, toSqr);
			MovePiece(piece2, toIntr);
			
			GetPieceState(piece1).GetComponent<PieceScript>().CheckSprite();
			GetPieceState(piece2).GetComponent<PieceScript>().CheckSprite();
		}
Exemple #2
0
		// Swaps two pieces position
		public void SwapPiece(GameModel.Piece piece1, GameModel.Piece piece2)
		{
			Vector3 pos1 = GetPieceState(piece1).transform.position;
			Vector3 pos2 = GetPieceState(piece2).transform.position;

			MovePiece(piece1, pos2);
			MovePiece(piece2, pos1);
		}
Exemple #3
0
		// Although the name may be confusing, this returns a GameObject in-game, based on a given Piece
		public GameObject GetPieceState(GameModel.Piece piece)
		{
			foreach(GameObject item in m_pieces)
			{
				if(item.GetComponent<PieceScript>().Piece == piece)
					return item;
			}

			return null;		
		}
Exemple #4
0
		// Removes a piece by passing its reference piece directly
		public void RemovePiece(GameModel.Piece piece)
		{
			GameObject removedPiece = GetPieceState(piece);

			if (!m_pieces.Contains(removedPiece))
				return;
			
			removedPiece.SetActive(false);
			m_pieces.Remove(removedPiece);
			Destroy(removedPiece);
		}
Exemple #5
0
        public PieceScript(PieceType type, Color color, GameModel.Piece piece, Vector3 position)
        {
            m_type  = type;
            m_color = color;

            gameObject.transform.position = position;

            if (!InitSprites())
            {
                Debug.LogError("Error initializating sprites for " + GameModel.GetString.GetStr(piece.Type));
                return;
            }

            CheckSprite();

            gameObject.SetActive(true);
        }
Exemple #6
0
		/* ENDOF COORDINATES TRANSLATORS */

		// Adds a new GameObject containing a SpriteRenderer, BoxCollider2D, PieceScript, fully initiated; on the board
		public void PlacePiece(GameModel.Piece piece, GameModel.Square square)
		{
			GameObject newPiece = new GameObject(piece.Type.ToString());
			
			newPiece.AddComponent<SpriteRenderer>();
			newPiece.AddComponent<BoxCollider2D>();
			newPiece.AddComponent<PieceScript>();

			newPiece.GetComponent<BoxCollider2D>().isTrigger = true;
			newPiece.GetComponent<PieceScript>().Collider = newPiece.GetComponent<BoxCollider2D>();
			newPiece.GetComponent<PieceScript>().Type = piece.Type;
			newPiece.GetComponent<PieceScript>().Color = piece.Color;
			newPiece.GetComponent<PieceScript>().Square = square;
			newPiece.GetComponent<PieceScript>().Piece = piece;
			newPiece.GetComponent<PieceScript>().InitSprites();
			newPiece.GetComponent<PieceScript>().CheckSprite();
			
			
			m_pieces.Add(newPiece);

			Instantiate(newPiece, newPiece.transform.position, Quaternion.identity);
		}
Exemple #7
0
		public void PlacePiece(GameModel.Piece piece, GameModel.Intersection intersection)
		{
			if(piece.Type != PieceType.Tetraglobe)
				return;

			GameObject newPiece = new GameObject(GameModel.GetString.GetStr(piece.Type));

			newPiece.AddComponent<SpriteRenderer>();
			newPiece.AddComponent<BoxCollider2D>();
			newPiece.AddComponent<PieceScript>();

			newPiece.GetComponent<BoxCollider2D>().isTrigger = true;
			newPiece.GetComponent<PieceScript>().Collider = newPiece.GetComponent<BoxCollider2D>();
			newPiece.GetComponent<PieceScript>().Type = piece.Type;
			newPiece.GetComponent<PieceScript>().Color = piece.Color;
			newPiece.GetComponent<PieceScript>().Intersection = intersection;
			newPiece.GetComponent<PieceScript>().Piece = piece;
			newPiece.GetComponent<PieceScript>().InitSprites();
			newPiece.GetComponent<PieceScript>().CheckSprite();
			
			m_pieces.Add(newPiece);

			Instantiate(newPiece, newPiece.transform.position, Quaternion.identity);
		}
Exemple #8
0
 internal void RestorePiece(GameModel.Piece pieceToRestore, GameModel.BoardPosition placeAtLogical)
 {
     _gameBoard.RestorePiece(pieceToRestore, placeAtLogical);
 }
Exemple #9
0
 internal void CapturePiece(GameModel.Piece pieceToCapture, GameModel.BoardPosition removeFromLogical)
 {
     _gameBoard.CapturePiece(pieceToCapture);
 }
Exemple #10
0
 internal void MovePiece(GameModel.Piece pieceToMove, GameModel.BoardPosition fromLogicalPosition, GameModel.BoardPosition toLogicalPosition)
 {
     _gameBoard.MovePiece(pieceToMove, toLogicalPosition);
 }
Exemple #11
0
		// Create a Globule on a given square
		public void CreateGlobule(GameModel.Piece piece, GameModel.Square toSqr)
		{
			PlacePiece(piece, toSqr);
		}
Exemple #12
0
		public void MovePiece(GameModel.Piece piece, GameModel.Square toSqr)
		{
			GetPieceState(piece).transform.position = ToUnityCoord(toSqr);
		}
Exemple #13
0
		public void MovePiece(GameModel.Piece piece, GameModel.Intersection toIntr)
		{
			GetPieceState(piece).transform.position = ToUnityCoord(toIntr);
		}
Exemple #14
0
		private void MovePiece(GameModel.Piece piece, Vector3 position)
		{
			GetPieceState(piece).transform.position = position;
		}