Example #1
0
        internal Pawn Generate(PawnType _PT, Controller _Controller, Vector2 _SpawnPoint, float _Scale = 1.0f, float _Rotation = 0.0f)
        {
            Pawn pawn = GetPawn(_PT, _SpawnPoint, _Scale, _Rotation);

            _Controller.Possess(pawn);
            return(pawn);
        }
Example #2
0
    /// <summary>
    /// Attack the other pawn.
    /// </summary>
    /// <param name="other">The other pawn</param>
    /// <param name="moveToOpponent">True if should move to opponent  position after attack, false otherwise</param>
    /// <returns>True if the attack leads to a success, false otherwise.</returns>
    private bool Attack(Pawn other, bool moveToOpponent)
    {
        if (!isOpponent(other))
        {
            return(false);
        }

        if (CanBeat(other))
        {
            // Destorying the opponent and take his place
            type = other.type;
            UpdateMaterial();
            Vector3 otherPos        = other.transform.position;
            Vector3 snappedPosition = SnapPosition(otherPos, otherPos.y);
            Destroy(other.gameObject);
            if (moveToOpponent)
            {
                Target = snappedPosition;
            }
            return(true);
        }
        // loose against opponent = get eat
        else if (other.CanBeat(this))
        {
            other.Attack(this, false);
        }
        return(false);
    }
Example #3
0
        public static void UpgradeUnit(PawnType newPawnType, Pawn pawn)
        {
            MeshFilter meshFilter = pawn.modelOfType.GetComponent <MeshFilter>();

            MeshFilterManager mfm = GameObject.FindObjectOfType <MeshFilterManager>();

            switch (newPawnType)
            {
            case PawnType.Rook:
                meshFilter.mesh = mfm.rookMesh.mesh;
                break;

            case PawnType.Bischop:
                meshFilter.mesh = mfm.bischopMesh.mesh;
                break;

            case PawnType.Knight:
                meshFilter.mesh = mfm.knightMesh.mesh;
                break;

            case PawnType.Queen:
                meshFilter.mesh = mfm.queenMesh.mesh;
                break;
            }

            pawn.pawnType = PawnType.Queen;
        }
Example #4
0
 public void AfterSpawnSetting(Pawn pawn, PawnType type)
 {
     if (photonView.isMine)
     {
         photonView.RPC("RPCAfterSpawnSetting", PhotonTargets.AllBuffered, pawn.GetComponent <PhotonView>().viewID, (int)type);
     }
 }
Example #5
0
 public Pawn(Position position, PawnColor pawnColor, PawnType pawnType, IMoveStrategy moveStrategy)
 {
     Position     = position;
     PawnColor    = pawnColor;
     PawnType     = pawnType;
     MoveStrategy = moveStrategy;
 }
Example #6
0
    public void InitializePawn(PawnType type, string name, int initlevel,
                               int initattack, int initmagicAttack, int initdefense, int initmagicDefense, int inithp, int initdexterity, int initattackRange)
    {
        pawnType = type;
        Name     = name;
        level    = initlevel;

        attack       = currentAttack = initattack;
        defense      = currentDefense = initdefense;
        hp           = currentHP = inithp;
        dexterity    = currentDexterity = initdexterity;
        attackRange  = currentAttackRange = initattackRange;
        magicAttack  = currentMagicAttack = initmagicAttack;
        magicDefense = currentMagicDefense = initmagicDefense;

        skipCounter = 0;
        isSkip      = false;

        isIgnoreDefense = isIgnoreMagicDefense = false;
        animator        = this.transform.GetChild(0).GetComponent <Animator>();
        if (animator == null)
        {
            UnityEngine.Debug.Log("animator==null!");
        }

        uilog = FindObjectOfType <GameManager>().GetComponent <GameManager>().gameInteraction.uilog;

        InitPawn();
    }
Example #7
0
    public CharacterDescription GetCharacterDescription(PawnType type, string name)
    {
        CharacterDescription data = new CharacterDescription();

        string     xpath = "";
        XmlElement node  = null;

        if (type == PawnType.Monster)
        {
            xpath = "/character/monster//" + name;
            node  = (XmlElement)xmlDocDescription.SelectSingleNode(xpath);
        }
        else if (type == PawnType.Enemy)
        {
            xpath = "/character/enemy//" + name;
            node  = (XmlElement)xmlDocDescription.SelectSingleNode(xpath);
        }
        if (node == null)
        {
            Debug.Log("On CharacterReader GetCharacterDescription: " + name + " not found");
            return(null);
        }
        data.race        = (node["race"].InnerXml);
        data.story       = (node["story"].InnerXml);
        data.description = (node["description"].InnerXml);
        return(data);
    }
	/* 
	 * Méthode appelée lorsque le joueur décide de poser un pion (clic gauche).
	 * Cette méthode génère un pion "réel" et détruit le pion fantome si celui-ci est toujours vivant.
	 */
	public void			OnMouseDown () {
		Color pawnColor;
		Color newColor;

		if (Time.timeScale != 0.0f) {
			if (this.pawn == null && this.instantiated != null) {
				this.pawnType = TurnBasedSystem.INSTANCE.GetCurrentPawnType ();
				this.RetrieveDirectionsValues ();
				this.UpdateAdjacentIntersections ();
				this.UpdateFreeLines();
				if (!this.CheckFreeLinePatterns()) {
					this.pawn = (GameObject)Instantiate (BoardManager.INSTANCE.pawn, this.gameObject.transform.position, Quaternion.identity);
					this.pawn.transform.parent = this.gameObject.transform;
					pawnColor = TurnBasedSystem.INSTANCE.GetCurrentPawnColor ();
					newColor = new Color (pawnColor.r, pawnColor.g, pawnColor.b);
					newColor.a = 1.0f;
					this.pawn.GetComponent<Renderer> ().material.color = newColor;
					this.ProcessCaptures ();
					this.CheckCapturePatterns ();
					this.ProcessConnectFive ();
					this.OnMouseExit ();
					foreach (Freeline fl in BoardManager.INSTANCE.excluded)
						BoardManager.INSTANCE.freelines.Remove(fl);
					TurnBasedSystem.INSTANCE.EndTurn ();
				} else {
					this.ResetDirectionValues ();
					this.pawnType = PawnType.NONE;
					this.CheckCaptureOnDestruction ();
					this.directions = new int[8] {0, 0, 0, 0, 0, 0, 0, 0};
					this.Catchable = 0;
					BoardManager.INSTANCE.excluded.Clear();
				}
			}
		}
	}
    //inizializza le winning boards per le celle pari (diagonale si)
    private static PawnType[,] InitWinningBoardEven(int r, int c)
    {
        PawnType[,] oneBoard = new PawnType[7, 7];
        //setto l'intorno del centro dato come oche
        for (int roundR = r - 1; roundR <= r + 1; roundR++)
        {
            for (int roundC = c - 1; roundC <= c + 1; roundC++)
            {
                if (!IsPositionOutOfCross(roundR, roundC))
                {
                    oneBoard[roundR, roundC] = PawnType.Goose;
                }
            }
        }
        int roundR2 = r - 2;

        while (roundR2 <= r + 2)
        {
            int roundC = c - 2;
            while (roundC <= c + 2)
            {
                if (!IsPositionOutOfCross(roundR2, roundC))
                {
                    //Console.WriteLine("Sono triste: " + roundR2 + roundC + !IsPositionOutOfCross(roundR2, roundC));
                    oneBoard[roundR2, roundC] = PawnType.Goose;
                }
                roundC = roundC + 2;
            }
            roundR2 = roundR2 + 2;
        }
        // setto il centro come volpe
        oneBoard[r, c] = PawnType.Fox;
        return(oneBoard);
    }
 //inizializza le winning boards per le celle dispari (diagonale no)
 private static PawnType[,] InitWinningBoardOdd(int r, int c)
 {
     //Console.WriteLine("Sono triste: " + r + c);
     PawnType[,] oneBoard = new PawnType[7, 7];
     //setto l'intorno del centro dato come oche
     for (int roundR = r - 2; roundR <= r + 2; roundR++)
     {
         if (!IsPositionOutOfCross(roundR, c))
         {
             //Console.WriteLine("Sono triste: " + roundR + c + !IsPositionOutOfCross(roundR, c));
             oneBoard[roundR, c] = PawnType.Goose;
         }
     }
     for (int roundC = c - 2; roundC <= c + 2; roundC++)
     {
         if (!IsPositionOutOfCross(r, roundC))
         {
             //Console.WriteLine("Sono triste: " + r + roundC + !IsPositionOutOfCross(r, roundC));
             oneBoard[r, roundC] = PawnType.Goose;
         }
     }
     // setto il centro come volpe
     oneBoard[r, c] = PawnType.Fox;
     return(oneBoard);
 }
 public AlphaBeta(PawnType aiPlayer, int maxPly, WeightsForBoardEval weights, bool random)
 {
     this.aiPlayer = aiPlayer;
     this.maxPly   = maxPly;
     this.weights  = weights;
     this.random   = random;
 }
Example #12
0
        internal Pawn Generate(PawnType _PT, ControllerType _CT, Vector2 _SpawnPoint, float _Scale = 1.0f, float _Rotation = 0.0f)
        {
            Controller controller = GetController(_CT);
            Pawn       pawn       = GetPawn(_PT, _SpawnPoint, _Scale, _Rotation);

            controller.Possess(pawn);
            return(pawn);
        }
Example #13
0
 //costruttore
 public Move(PawnType pawnType, int startingX, int startingZ, int finalX, int finalZ)
 {
     this.pawnType  = pawnType;
     this.startingX = startingX;
     this.startingZ = startingZ;
     this.finalX    = finalX;
     this.finalZ    = finalZ;
 }
Example #14
0
	private void mergeAdjacentPawnList(PawnType type, AdjacentPawnList targetList, List<Pawn> srcList) {
		foreach (Pawn pawn in srcList) {
			_gridFlags[(int)type, pawn.gridIndex].adjacentPawnList = targetList;
			if (!targetList.finalList.Contains(pawn)) {
				targetList.finalList.Add(pawn);
			}
		}
	}
Example #15
0
 // Constructor
 public Pawn(World world, PawnType type, Cell cell)
 {
     this.world      = world;
     this.type       = type;
     CurrentCell     = cell;
     DestinationCell = cell;
     NextCell        = cell;
 }
Example #16
0
	private void collectAdjacentPawns() {
		for (int traverseType = 0; traverseType < (int)TraverType.Count; ++traverseType) {
			AdjacentPawnJudger judger = _adjacentJudgers[traverseType];
			int[][] traverseIndice = _traverseIndice[traverseType];
			int dim0 = traverseIndice.GetLength(0);
			for (int i = 0; i < dim0; ++i) {
				int[] indiceOnDim = traverseIndice[i];
				if (indiceOnDim == null) {
					Debug.Log(string.Format("collectAdjacentPawns: indiceOnDim is empty traverseType={0} dim0={1}", traverseType, i));
					continue;
				}

				for (int j = 0; j < CHECK_PAWN_TYPES.Length; ++j) {
					PawnType checkType = CHECK_PAWN_TYPES[j];
					List<Pawn> adjacentPawnList = null;
					Pawn lastPawn = null;

					for (int k = 0; k < indiceOnDim.Length; ++k) {
						int gridIndex = indiceOnDim[k];
						Pawn pawn = getPawnByGridIndex(gridIndex);
						if (pawn != null && pawn.type == checkType) {
							if (lastPawn == null) {
								lastPawn = pawn;
								if (adjacentPawnList == null) {
									adjacentPawnList = new List<Pawn>();
								}

								adjacentPawnList.Add(pawn);
							} else {
								// adjacent
								if (judger(pawn, lastPawn)) {
									adjacentPawnList.Add(pawn);
								} else {
									if (adjacentPawnList != null && adjacentPawnList.Count > 0) {
										checkAndAddAdjacentPawnList(checkType, adjacentPawnList);
										adjacentPawnList = null;
									}

									if (adjacentPawnList == null) {
										adjacentPawnList = new List<Pawn>();
									}

									adjacentPawnList.Add(pawn);
								}
								
								lastPawn = pawn;
							}
						}
					}

					if (adjacentPawnList != null) {
						checkAndAddAdjacentPawnList(checkType, adjacentPawnList);
						adjacentPawnList = null;
					}
				}
			}
		}
	}
Example #17
0
        /// <summary>Pobiera kolor piona na podstawie jego typu</summary>
        /// <param name="pt">Typ piona</param>
        /// <returns>Kolor piona</returns>
        public static PawnColor GetColor(PawnType pt)
        {
            if (pt == PawnType.BlackPawn || pt == PawnType.BlackQueen)
                return PawnColor.Black;
            if (pt == PawnType.WhitePawn || pt == PawnType.WhiteQueen)
                return PawnColor.White;

            return PawnColor.None;
        }
Example #18
0
        /// <summary>
        /// Porównanie dwóch pionów ze względu na ich kolor (z pominięciem typu)
        /// </summary>
        public static bool EqualColor(PawnColor pc, PawnType pt)
        {
            if (pc == PawnColor.Black && (pt == PawnType.BlackPawn || pt == PawnType.BlackQueen))
                return true;
            if (pc == PawnColor.White && (pt == PawnType.WhitePawn || pt == PawnType.WhiteQueen))
                return true;

            return false;
        }
Example #19
0
	private void checkAchieve(int eliminateNeighborCount, PawnType pawnType) {
		int[] parameters = new int[]{ eliminateNeighborCount, (int)pawnType };
		List<int> newlyFinishedAchieves = AchievementConfig.instance().checkAchieve(
			AchievementConfig.Condition.CLEAR_BY_TYPE, parameters, GameApp.instance().finishedAchieves);

		if (newlyFinishedAchieves.Count > 0) {
			_newlyFinishedAchieves.AddRange(newlyFinishedAchieves);
			GameApp.instance().saveAchieveChange();
		}
	}
Example #20
0
    /** Rotates pawns */
    private IEnumerator RotatePawns(PawnType pawnType)
    {
        yield return(new WaitForSeconds(0.3f));

        RotatePawn[] pawns = FindObjectsOfType <RotatePawn>();
        foreach (RotatePawn pawn in pawns)
        {
            pawn.Rotate(matchController.localPlayer.pawnType);
        }
    }
	/*
	 * Méthode appelée lorsque le BoardManager initialise le Goban.
	 * Lors de l'initialisation du goban, chaque intersection est elle-meme initialisée
	 * avec des valeurs par défaut : le x, le y, le fait qu'il n'y ait aucun pion et
	 * le tableau des "poids" des directions.
	 * La texture est proprement assignée en fonction de la position de l'Intersection.
	 * Le nom de l'objet quant à lui est formaté ainsi : [x, y]
	 */
	public void			Initialize(int x, int y) {
		this.X = x;
		this.Y = y;
		this.pawnType = PawnType.NONE;
		this.Catchable = 0;
		this.directions = new int[8] {0, 0, 0, 0, 0, 0, 0, 0};
		this.captures = new PawnType[8] {0, 0, 0, 0, 0, 0, 0, 0};
		BoardManager.INSTANCE.SetProperTexture (this.gameObject);
		this.Name = "[" + this.X + ", " + this.Y + "]";
	}
Example #22
0
 public void SetPawnType(PawnType pawnType)
 {
     _pawnType = pawnType;
     if (pawnType == PawnType.Normal)
     {
         SetSize(0.55f, 0.55f);
     }
     else if (pawnType == PawnType.Small)
     {
         SetSize(0.25f, 0.25f);
     }
 }
Example #23
0
	private int getNeighborOppoCount(PawnType type, Vector2 pos) {
		int result = 0;
		for (int i = 0; i < NEIGHBOR_GRID_OFFSETS.Length; ++i) {
			Vector2 offset = NEIGHBOR_GRID_OFFSETS[i];
			Pawn pawn = getPawnAtPos((int)(offset.x + pos.x), (int)(offset.y + pos.y));
			if (pawn != null && pawn.type != type) {
				++result;
			}
		}

		return result;
	}
Example #24
0
	private void modifyScore(int score, PawnType scorePawnType) {
		_score += score;
		modifyExp(calculateExp(score));
		invalidUI();
		_titleLayer.setScorePawnType(scorePawnType);

		_gameRecord.score = _score;
		if (_score > _gameRecord.highScore) {
			_gameRecord.highScore = _score;
			updateGameRecord();
		}
	}
Example #25
0
 // Static Methods
 public static InputTask PawnFactory(PawnType type)
 {
     return(new InputTask(InputMode.Single, (cells, selected) => {
         foreach (Cell cell in cells)
         {
             cell.World.AddPawn(new Pawn(cell.World, type, cell));
         }
     }, (cell, spriteBatch) => {
         Pawn preview = new Pawn(cell.World, type, cell);
         preview.Draw(spriteBatch, cell.X * World.BlockSize, cell.Y * World.BlockSize);
     }));
 }
Example #26
0
    /** Receives the results of the coin toss*/
    private void OnCoinToss(object sender, object args)
    {
        bool coinToss = (bool)args;

        matchController.hostPlayer.pawnType   = coinToss ? PawnType.Fox : PawnType.Goose;
        matchController.clientPlayer.pawnType = coinToss ? PawnType.Goose : PawnType.Fox;
        ClearBoard();
        PawnType localPawnType = matchController.localPlayer.pawnType;

        mainCamera.GetComponent <MoveCamera>().PositionCamera(localPawnType);
        game = new Game(settings.geeseNumber);
        CheckState();
    }
Example #27
0
 public Pawn(PawnColor color, PawnType type) : base("MasterMindPawn")
 {
     _effect = new Particle.ParticleSystem("light");
     _effect.SetLifeTime(10, 20);
     _effect.SetParent(this.EntityId);
     _effect.SetSize(0.2f, 0.2f);
     _effect.SetSpread(Helpers.PhysicsAndPositions.PI * 2);
     _effect.SetRandomSpeed(true, 0.05f);
     SetPawnColor(color);
     SetPawnType(type);
     SetTexture("pawn");
     Selected = false;
 }
Example #28
0
	private Pawn putPawn(int gridX, int gridY, PawnType type, Side side, bool skipUpdateScene = false) {
		Pawn pawnAtPos = getPawnAtPos(gridX, gridY);
		if (pawnAtPos != null) {
			return null;
		}

		Pawn pawn = new Pawn(type, gridX, gridY, side, this);
		if (!skipUpdateScene) {
			updateScenePawnState();
		}

		return pawn;
	}
Example #29
0
        private Pawn GetPawn(PawnType _PT, Vector2 _SpawnPoint, float _Scale = 1.0f, float _Rotation = 0.0f)
        {
            switch (_PT)
            {
            case PawnType.Dummy:
                return(new DummyPawn(_SpawnPoint, _Scale, _Rotation));

            case PawnType.Player:
                return(new PlayerPawn(_SpawnPoint, _Scale, _Rotation));

            default:
                throw new System.Exception("Illegal PawnType Specified");
            }
        }
Example #30
0
 public Pawn(PawnColor color, PawnType type)
     : base("MasterMindPawn")
 {
     _effect = new Particle.ParticleSystem("light");
     _effect.SetLifeTime(10, 20);
     _effect.SetParent(this.EntityId);
     _effect.SetSize(0.2f, 0.2f);
     _effect.SetSpread(Helpers.PhysicsAndPositions.PI * 2);
     _effect.SetRandomSpeed(true, 0.05f);
     SetPawnColor(color);
     SetPawnType(type);
     SetTexture("pawn");
     Selected = false;
 }
    private void UpdatePanel(PawnType type, int attack, int def, int hp, int dex, int atkRange, string displayname, string name, int maxHp, int level, int magic, int resistance, int remainedStep, ActionType actionType)
    {
        txtAttak.text   = "ATK:" + attack;
        txtDefense.text = "DEF:" + def;
        if ((float)hp / maxHp < 0.4f)
        {
            txtHP.text = "<color=#FF0000>" + hp + "</color>/" + maxHp;
        }
        else
        {
            txtHP.text = hp + "/" + maxHp;
        }
        txtDexterity.text   = "DEX:" + dex;
        txtAttackRange.text = "RNG:" + atkRange;
        txtMagic.text       = "MAG:" + magic;
        txtResistant.text   = "RES:" + resistance;
        txtName.text        = displayname;
        txtLevel.text       = "." + level;
        if ((sprite = Resources.Load("UI/avatar/" + name, typeof(Sprite)) as Sprite) != null)
        {
            imgAvatar.sprite = sprite;
        }
        else
        {
            int lv = level;
            while ((sprite = Resources.Load("UI/avatar/" + name + lv, typeof(Sprite)) as Sprite) == null && lv > 1)
            {
                lv--;
            }
            if ((sprite = Resources.Load("UI/avatar/" + name + lv, typeof(Sprite)) as Sprite) != null)
            {
                imgAvatar.sprite = sprite;
            }
        }

        if (type == PawnType.Monster)
        {
            txtRemainedStep.gameObject.SetActive(true);
            txtRemainedStep.text = "" + remainedStep;
            txtActionType.gameObject.SetActive(true);
            txtActionType.text = actionType.ToString();
        }
        else
        {
            txtRemainedStep.transform.gameObject.SetActive(false);
            txtActionType.transform.gameObject.SetActive(false);
        }

        currentPawn.isUIupdated = true;
    }
Example #32
0
		public Pawn(PawnType type, int gridX, int gridY, Side side, MainState container) {
			_container = container;
			GameObject pawnObj = (GameObject)Instantiate(container.PawnPrefab, Vector3.zero, Quaternion.identity);
			_obj = pawnObj.GetComponent<PawnDisplayer>();
			pawnObj.transform.SetParent(container._chessBoard.transform, true);
			pawnObj.transform.localScale = Vector3.one;
			pawnObj.name = "pawn[" + gridY + "][" + gridX + "]";

			this.type = type;
			this.side = side;
			this.gridIndex = container._chessBoard.gridPosToIndex(gridX, gridY);

			_container._pawns.Add(this);
		}
    /** Rotates this pawn to the correct rotation */
    public void Rotate(PawnType pawnType)
    {
        Vector3 correctRotation = Vector3.zero;

        if (pawnType == PawnType.Fox)
        {
            correctRotation = rotationWhenFox;
        }
        else if (pawnType == PawnType.Goose)
        {
            correctRotation = rotationWhenGoose;
        }
        gameObject.transform.localRotation = Quaternion.Euler(correctRotation);
    }
Example #34
0
        private Dialog_Rules(PawnType type) : base(new Vector2(700f, 600f))
        {
            var defaultRules = Registry.GetDefaultRules(type);

            _type     = type;
            _template = defaultRules.ClonePreset();
            _preset   = new Listing_Preset <Rules>(type, defaultRules, new[] { Registry.GetVoidPreset <Rules>(type) }, UpdateSelected, CommitTemplate, RevertTemplate);

            foreach (var pawnType in PawnType.List)
            {
                _floatMenuViews.Add(new FloatMenuOption(Lang.Get("Dialog_Rules.DefaultType", pawnType.Label), () => ChangeType(pawnType)));
            }

            _floatMenuAssign = GetAssignmentOptions();
        }
Example #35
0
 /* Invoked when the user has chosen which player he wants to play as */
 private void OnPlayerChosen(object sender, object args)
 {
     humanPlayer = (PawnType)args;
     cpuPlayer   = humanPlayer == PawnType.Fox ? PawnType.Goose : PawnType.Fox;
     ClearBoard();
     mainCamera.GetComponent <MoveCamera>().PositionCamera(humanPlayer);
     game = new Game(15, false);
     //weights must be in absolute value
     alphaBeta = new AlphaBeta(cpuPlayer, 5, new WeightsForBoardEval(4, 3, 0, -1, 0, 0, 0), false);
     CheckState();
     if (game.turn == cpuPlayer)
     {
         AiMoves();
     }
 }
	private char		GetLetter (PawnType type) {
		char			letter;

		switch (type) {
		case PawnType.PLAYER:
			letter = 'P'; break;
		case PawnType.OPPONENT:
			letter = 'O'; break;
		case PawnType.NONE:
			letter = 'N'; break;
		default:
			letter = 'E'; break;
		}
		return (letter);
	}
	public void		DeletePawn () {
		this.ResetDirectionValues ();
		this.pawnType = PawnType.NONE;
		this.CheckCaptureOnDestruction ();
		this.directions = new int[8] {0, 0, 0, 0, 0, 0, 0, 0};
		this.Catchable = 0;
		Destroy (this.pawn);
		this.pawn = null;
	}
Example #38
0
 /// <summary>Sprawdza, czy typ reprezentuje normalny pion (dowolnego koloru)</summary>
 /// <param name="pt">Typ pionu</param>
 /// <returns>Zwraca true jeśli typ reprezentuje zwykły pion</returns>
 public static bool IsNormalPawn(PawnType pt)
 {
     return (pt == PawnType.BlackPawn || pt == PawnType.WhitePawn);
 }
Example #39
0
 /// <summary>Sprawdza, czy typ reprezentuje damę (dowolnego koloru)</summary>
 /// <param name="pt">Typ pionu</param>
 /// <returns>Zwraca true jeśli typ reprezentuje damę</returns>
 public static bool IsQueenPawn(PawnType pt)
 {
     return (pt == PawnType.BlackQueen || pt == PawnType.WhiteQueen);
 }
 public void IAputPawn(PawnType turn)
 {
     if (this.pawn == null)
     {
         this.pawnType = turn;
         this.RetrieveDirectionsValues();
         this.UpdateAdjacentIntersections();
         this.CheckCapturePatterns();
     }
 }
Example #41
0
 public static bool IsNone(PawnType pt)
 {
     return pt == PawnType.None;
 }
	public Freeline(Intersection A, Intersection B) {
		segment = new Segment (new Point (A.X, A.Y), new Point (B.X, B.Y));
		type = A.GetPawnType ();
	}
 public void DeleteIAPawn()
 {
     this.ResetDirectionValues();
     this.pawnType = PawnType.NONE;
     this.directions = new int[8] { 0, 0, 0, 0, 0, 0, 0, 0 };
     this.Catchable = 0;
     //Destroy(this.pawn);
     this.pawn = null;
 }
	public void		UpdateScore (PawnType type) {
		if (type == PawnType.PLAYER)
			this.playerScore.text = this.GetPlayerScore ();
		else
			this.opponentScore.text = this.GetOpponentScore ();
	}
Example #45
0
 public void AfterSpawnSetting(Pawn pawn,PawnType type,int rTeam)
 {
     if (photonView.isMine) {
         photonView.RPC("RPCAfterSpawnSetting",PhotonTargets.AllBuffered,pawn.GetComponent<PhotonView>().viewID,(int)type,rTeam);
     }
 }
Example #46
0
 private void InternalSetPawn(string field_address, PawnType pt)
 {
     Point p = Pawn.FieldAddressToPoint(field_address);
     this.pawn_matrix[p.Y, p.X] = pt;
 }
Example #47
0
 private void InternalSetPawn(Point p, PawnType pt)
 {
     Debug.Assert(Pawn.InBound(p));
     this.pawn_matrix[p.Y, p.X] = pt;
 }
Example #48
0
        private PawnType GetPawn(Point p, PawnType default_type)
        {
            if (!Pawn.InBound(p))
                return default_type;

            return GetPawn(p);
        }
        public Point[] GetMovementCoordinates(string field_address, PawnType hypotetical_pawn_type)
        {
            Point pselected = Pawn.FieldAddressToPoint(field_address);
            List<Point> directions = new List<Point>();

            // jeżeli typ hipotetycznego piona nie jest pusty (none) to udaj, że PT(pselected) == hipotetyczny
            PawnType pt_selected = this.GetPawn(pselected);
            if (hypotetical_pawn_type != PawnType.None)
                pt_selected = hypotetical_pawn_type;

            if (Pawn.IsNormalPawn(pt_selected))
            {
                // sprawdź wszystkie kierunki dla piona
                Point[] deltas;
                if (Pawn.GetColor(pt_selected) == PawnColor.White)
                {
                    // białe - tylko w dół
                    deltas = new Point[] { new Point(1, 1), new Point(-1, 1) };
                }
                else
                {
                    // czarne - tylko w górę
                    deltas = new Point[] { new Point(1, -1), new Point(-1, -1) };
                }

                if (this.dbg.chkAllowNormalPawnMoveBack.Checked) // hack :)
                    deltas = new Point[] { new Point(1, 1), new Point(1, -1), new Point(-1, -1), new Point(-1, 1) }; // wszystkie cztery przekątne

                // w najbliższym sąsiedztwie musi być wolne pole
                foreach (Point delta in deltas)
                {
                    Point pn = pselected.Add(delta);
                    if (Pawn.IsNone(this.GetPawn(pn, PawnType.None)) && Pawn.InBound(pn))
                        directions.Add(pn);
                }
            }

            if (Pawn.IsQueenPawn(pt_selected))
            {
                // sprawdź wszystkie kierunki dla damy
                foreach (Point delta in new Point[] { new Point(1, 1), new Point(1, -1), new Point(-1, -1), new Point(-1, 1) })
                {
                    // mozna bić, jeśli pion przeciwnika ma wolne pole po nim (przed może stać dama)
                    Point p = pselected;
                    p = p.Add(delta);
                    while (Pawn.InBound(p))
                    {
                        PawnType pt = this.GetPawn(p);
                        if (!Pawn.IsNone(pt))
                            break; // już tutaj i dalej dama nie może się poruszać

                        directions.Add(p);
                        p = p.Add(delta); // przejdź o jedno pole w kierunku pdest
                    }
                }
            }
            return directions.ToArray();
        }
Example #50
0
 public void SetPawnType(PawnType pawnType)
 {
     _pawnType = pawnType;
     if(pawnType == PawnType.Normal){
         SetSize(0.55f,0.55f);
     }
     else if( pawnType == PawnType.Small)
     {
         SetSize(0.25f,0.25f);
     }
 }
 public VirtualBoard(MainWindow base_form, DebugWindow dbg, PawnType[,] pawn_matrix)
 {
     this.base_form = base_form;
     this.dbg = dbg;
     this.pawn_matrix = pawn_matrix.Clone() as PawnType[,];
 }
 public string[] GetMovementFields(string field_address, PawnType hypotetical_pawn_type)
 {
     return Pawn.PointToFieldAddress(this.GetMovementCoordinates(field_address, hypotetical_pawn_type));
 }
        public Point[] GetCaptureCoordinates(string field_address, PawnType hypotetical_pawn_type)
        {
            Point pselected = Pawn.FieldAddressToPoint(field_address);
            List<Point> directions = new List<Point>();

            // jeżeli typ hipotetycznego piona nie jest pusty (none) to udaj, że PT(pselected) == hipotetyczny
            PawnType pt_selected = this.GetPawn(pselected);
            if (hypotetical_pawn_type != PawnType.None)
                pt_selected = hypotetical_pawn_type;

            if (Pawn.IsNormalPawn(pt_selected))
            {
                // w najbliższym sąsiedztwie musi być pion/dama o przeciwnym kolorze oraz następne pola muszą być puste
                foreach (PawnColor pc in new PawnColor[] { PawnColor.White, PawnColor.Black })
                    foreach (Point delta in new Point[] { new Point(1, 1), new Point(1, -1), new Point(-1, -1), new Point(-1, 1) })
                    {
                        Point pn = pselected.Add(delta);
                        Point pnn = pn.Add(delta);
                        if (!Pawn.InBound(pn) || !Pawn.InBound(pnn))
                            continue;
                        if ((Pawn.GetColor(pt_selected) == pc) &&
                            (Pawn.GetColor(this.GetPawn(pn, PawnType.None)) == Pawn.GetOpponentColor(pc)) &&
                            (Pawn.IsNone(this.GetPawn(pnn, PawnType.None))))
                            directions.Add(pnn);
                    }
            }

            if (Pawn.IsQueenPawn(pt_selected))
            {
                PawnColor my_color = Pawn.GetColor(pt_selected);
                PawnColor opponent_color = Pawn.GetOpponentColor(my_color);

                // dama może bić w każdym kierunku
                foreach (Point delta in new Point[] { new Point(1, 1), new Point(1, -1), new Point(-1, -1), new Point(-1, 1) })
                {
                    Point p = pselected;
                    bool opponent_pawn_found = false;
                    int capture_count = 0; // licznik zbić dam/pionów przeciwnika
                    p = p.Add(delta);
                    while (Pawn.InBound(p))
                    {
                        PawnType pt = this.GetPawn(p);

                        // jeśli miejsce jest puste a coś udało mi się zbić, to mogę tutaj postawić damę
                        if (Pawn.IsNone(pt) && (capture_count > 0))
                            directions.Add(p);

                        // dama nie może przeskoczyć nad własnym pionem (tego samego koloru)
                        if (Pawn.GetColor(pt) == my_color)
                            break;

                        if (!Pawn.IsNone(pt) && opponent_pawn_found) // dwa piony przciwnika pod rząd - nie można bić
                            break;
                        opponent_pawn_found = !Pawn.IsNone(pt);

                        if (opponent_pawn_found)
                            capture_count++;

                        p = p.Add(delta); // przejdź o jedno pole w kierunku pdest
                    }
                }
            }

            return directions.ToArray();
        }
	public PawnType			GetOppositePawnType (PawnType type) {
		if (type == PawnType.PLAYER)
			return (PawnType.OPPONENT);
		return (PawnType.PLAYER);
	}