public bool UpdateValidMovesMatrix(ePlayer i_NumOfPlayer) { bool isThereAMove = false; for (int i = 0; i < m_GameMatrix.GetLength(0); i++) { for (int j = 0; j < m_GameMatrix.GetLength(1); j++) { if (m_GameMatrix[i, j] == eBoardSign.Empty) { if (i_NumOfPlayer == ePlayer.Xplayer) { m_ValidMovesMatrix[i, j] = checkSquare(i, j, eBoardSign.X); } else { m_ValidMovesMatrix[i, j] = checkSquare(i, j, eBoardSign.O); } } else { m_ValidMovesMatrix[i, j] = false; } isThereAMove |= m_ValidMovesMatrix[i, j]; } } return(isThereAMove); }
public BombedGuessResponseMessage(int scoreYou, int scoreOpponent, Word word, int[] bombs, ePlayer player) { this.scoreYou = scoreYou; this.scoreOpponent = scoreOpponent; this.bombs = bombs; this.Word = word; this.Player = player; }
/// <summary> /// Spawns units from this tower and sends them toward the target position. This doesn't actually have to be an attack as reinforcements work the same way. /// This coroutine waits for unitSpawnRate seconds between spawning units. The number to spawn is determined by the number of units in the tower when called /// multiplied by percentOfUnitsPerAttack /// </summary> /// <param name="targetPos">Position to send units toward</param> /// <returns></returns> public IEnumerator SpawnAttack(Vector3 targetPos) { //Debug.Log("spawn Attack, selected: " + selected); GameObject prefabToSpawn; //Select the proper unit prefab to spawn prefabToSpawn = (myOwner == ePlayer.Player1) ? Player1UnitPrefab : Player2UnitPrefab; //Calculate the point at which the units should spawn (just outside the tower in the proper direction) Vector3 vecToTarget = targetPos - transform.position; //line between source and target Vector3 spawnPoint = vecToTarget; //a point on the line to target just outside the collider of the tower and unit spawnPoint.Normalize(); spawnPoint *= (transform.localScale.x + prefabToSpawn.transform.localScale.x); //could be more efficient math here but this is what I came up with to scale spawnPoint *= .5f; spawnPoint = new Vector3(spawnPoint.x + transform.position.x, spawnPoint.y + transform.position.y, 0); //then translate int unitsToSend = (int)(units * percentOfUnitsPerAttack); //Calculate the number of units to spawn ePlayer myOwnerWhenStarted = myOwner; //Ownership could change while SpawnAttack is sleeping //Keep sending till all units are sent or the tower runs out of units or switches sides while (unitsToSend > 0 && units > unitsToSend && myOwner == myOwnerWhenStarted) { //Create a unit and decrement GameObject go = (GameObject)GameObject.Instantiate(prefabToSpawn, spawnPoint, Quaternion.LookRotation(Vector3.forward, vecToTarget)); unitBehavior spawnedUnit = go.GetComponent <unitBehavior>(); //set the owner of the new unit spawnedUnit.destination = targetPos; spawnedUnit.myOwner = myOwner; unitsToSend--; units--; yield return(new WaitForSeconds(unitSpawnRate)); //wait to spawn another } }
public static bool IsTargetFit(eSkill_TargetBelong target_side, ePlayer target, ePlayer self_side) { switch (target_side) { case eSkill_TargetBelong.All: return(true); case eSkill_TargetBelong.Both_Player: return(target == ePlayer.Player1 || target == ePlayer.Player2); case eSkill_TargetBelong.Opponent: return(target != self_side && target != ePlayer.None); case eSkill_TargetBelong.Teammate: return(target == self_side); case eSkill_TargetBelong.Scene: return(target == ePlayer.None); default: Debug.Log("技能目标错误"); break; } return(false); }
public void MakePlayerTurn(int i_Row, int i_Col, eBoardSign i_Sign) { bool isGameOver; ePlayer nextPlayer = getNextPlayer(); m_AreThereMovesForO = true; m_AreThereMovesForX = true; m_Board.FlipSquaresSigns(i_Row, i_Col, i_Sign); isGameOver = updateGameAccordingToMove(nextPlayer); if (m_NumOfUserPlayers == 1 && m_AreThereMovesForO) { do { System.Threading.Thread.Sleep(2000); chooseAndApplyPcrMove(); isGameOver = updateGameAccordingToMove(ePlayer.Xplayer); }while (!m_AreThereMovesForX && m_AreThereMovesForO); } if (isGameOver) { handleGameResult(); } }
IEnumerator GameoverCorotine(ePlayer lusir) { Main.Inst.GameOver(lusir); float duration = 0.5f; int step = 10; GameObject showgirl; if (lusir == ePlayer.Player2) { //showgirl = showgirl = Main.Inst.win_kuroko; } else { showgirl = Main.Inst.win_shiroi; } for (int i = 0; i < step; i++) { showgirl.transform.Rotate(Vector3.right * 90 / step); //Debug.Log("翻转" + i.ToString()); yield return(new WaitForSeconds(duration / step)); } Debug.Log("翻转结束"); yield return(null); }
// sets ability public void setAbility1(ePlayer owner) { if (currentAbility == ability.none) { bombOwner = owner; currentAbility = ability.ability1; } }
public MensajeMover(eOwn owner, ePlayer objetivo, int posX, int posY) { tipo = eTipoMensaje.Movimiento; this.owner = owner; this.objetivo = objetivo; this.posX = posX; this.posY = posY; }
public void Start() { //random player start if (m_CurrentTurn == ePlayer.eNone) { Random random = new Random(); m_CurrentTurn = (ePlayer)random.Next(0, 2); } }
public SoundData(float volBgm, float volUi, eBgm clipBgm, eUi clipEffect, ePlayer clipPlayer, eAction clipAction, bool mute, bool isChangeWalk) { this.volBgm = volBgm; this.volUi = volUi; this.clipBgm = clipBgm; this.clipUi = clipEffect; this.clipPlayer = clipPlayer; this.clipAction = clipAction; this.isMute = mute; this.isChangeWalk = isChangeWalk; }
private void makeBomb(ePlayer owner) { //recursion GameObject e = GameObject.Instantiate(bombManagerPrefab, this.transform.position, Quaternion.LookRotation(Vector3.forward, Vector3.forward)) as GameObject; BombManager BM = e.GetComponent <BombManager>(); if (BM != null) { BM.changeOwner(owner); } }
public void InitializePlayer(string i_Name, ePlayer i_PlayerChosen) { if (m_FirstPlayer == null) { m_FirstPlayer = new Player(i_Name, eCell.PlayerOne, i_PlayerChosen); } else { m_SecondPlayer = new Player(i_Name, eCell.PlayerTwo, i_PlayerChosen); } }
private void updateValidMovesMembers(ePlayer i_Player) { if (i_Player == ePlayer.Xplayer) { m_AreThereMovesForX = m_Board.UpdateValidMovesMatrix(i_Player); } else { m_AreThereMovesForO = m_Board.UpdateValidMovesMatrix(i_Player); } }
private void m_Game_gameOverListeners(ePlayer i_WinnerNAme, bool i_IsTie) { string gameOverMessage, winnerName, questionMsg = "Would you like another round?"; int winnerScore, loserScore, winsCounter; if (i_IsTie) { gameOverMessage = string.Format( @"It's a Tie! ({0}/{1}) {2}", m_Game.Board.XScore, m_Game.Board.OScore, questionMsg); } else { if (i_WinnerNAme == ePlayer.Xplayer) { winnerName = k_XPlayerColor; winnerScore = m_Game.Board.XScore; loserScore = m_Game.Board.OScore; winsCounter = m_Game.XwinningCounter; } else { winnerName = k_OPlayerColor; winnerScore = m_Game.Board.OScore; loserScore = m_Game.Board.XScore; winsCounter = m_Game.OwinningCounter; } gameOverMessage = string.Format( @"{0} Won!! ({1}/{2}) ({3}/{4})) {5}", winnerName, winnerScore, loserScore, winsCounter, m_Game.XwinningCounter + m_Game.OwinningCounter, questionMsg); } DialogResult dialogResult = MessageBox.Show(gameOverMessage, "Othello", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { m_Game.StartNewGame(); } else { m_FormBoard.Hide(); } }
//check 3 cells, if identical mark this owner as winner void CheckSameState(int i1, int i2, int i3) { if (m_Winner != ePlayer.eNone) { return; } if (m_BoardState[i1] == m_BoardState[i2] && m_BoardState[i2] == m_BoardState[i3]) { m_Winner = m_BoardState[i1]; m_WinnerStateIndex = new int[] { i1, i2, i3 }; } }
//下棋 探索模式没有召唤截断操作 override public void setChessPlayer(int card_id, ePlayer card_belong, ChessContainer grid) { return; if (Main.Inst.select_card == null || Main.Inst.moving_chess != null) { return; } setChess(card_id, card_belong, grid, AI.eAI_Type.Default, false, GameRule.PlayerChessEventID, 0); Debug.Log("从explore召唤"); return; }
//----------------------------------------------------------------------------------------------------------------------------- #region SelectAll //Called from individual towers to notify all of the same player's towers to deselect a certain location public void SelectAll(bool isPlayer1) { ePlayer playerToDeselect = (isPlayer1 == true) ? ePlayer.Player1 : ePlayer.Player2; foreach (KeyValuePair <Vector3, Tower> entry in towerLookup) { if (!entry.Value.Selected && entry.Value.myOwner == playerToDeselect) { entry.Value.ToggleSelect(); entry.Value.updateSprite(); } } }
void OnTriggerEnter2D(Collider2D other) { if (null == other || other.gameObject.tag.Contains("Untagged")) { return; } //Flip owner if hit by magnet ability if (other.gameObject.tag.Contains("Magnet")) { return; } //Used to check the destination of units; Units spawned by the magnet have no destination and should collide with any tower Vector3 target = other.gameObject.GetComponent <unitBehavior>().destination; bool isRogue = other.gameObject.GetComponent <unitBehavior>().rogue; if (!isRogue) { Vector3 here = this.transform.position; Vector3 distance = target - here; if (distance.magnitude > 2) { return; } } ePlayer otherOwner = other.gameObject.GetComponent <unitBehavior>().myOwner; if (myOwner == otherOwner && otherOwner != ePlayer.Neutral) { units++; } else { units -= attackedDamage; if (units < 0) //Can happen when multiple units hit at same time; might watnt to use math.clamp { units = 0; } if (units == 0 && otherOwner != ePlayer.Neutral) //Switch control when all units are lost { SwitchOwner(otherOwner); } other.gameObject.GetComponent <unitBehavior>().makeBurst(); } if (other.gameObject.tag.Contains("Unit")) { GameObject.Destroy(other.gameObject); } }
public void setAbility2(ePlayer thrower) { //Cant initialize on start as towers aren't placed until game begins if (p1DeathRay == null || p2DeathRay == null) { p1DeathRay = GameObject.Find("DeathRayPlayer1(Clone)"); p2DeathRay = GameObject.Find("DeathRayPlayer2(Clone)"); } active = true; currentAbility = ability.ability2; throwMagFrom = (thrower == ePlayer.Player1) ? p1DeathRay.transform.position : p2DeathRay.transform.position; clickTime = Time.time; magThrower = thrower; //Used for the ability2() }
public bool isMoveBan(ePlayer runner) { foreach (Buff buff in my_buffs) { if (buff.my_buff_info.effect == eBuff_Effect.Move_BAN) { if (BKTools.IsTargetFit(buff.my_buff_info.my_TargetBelong, runner, buff.stand_side)) { return(true); } } } return(false); }
private void Awake() { if (transform.position.x < 0) { player = ePlayer.Left; } else { player = ePlayer.Right; } view = GetComponent <PhotonView>(); }
//Called from individual towers to notify all of the same player's towers to attack a certain location public void AttackToward(Vector3 targetPosition, ePlayer attackingPlayer) { foreach (KeyValuePair <Vector3, Tower> entry in towerLookup) { if (entry.Value.Selected && entry.Value.myOwner == attackingPlayer) { StartCoroutine(entry.Value.SpawnAttack(targetPosition)); } } if (ClearSelectionAfterAttack) { DeselectTowers(attackingPlayer == ePlayer.Player1); } }
/// <summary> /// 设置自动出牌的状态切换 /// </summary> /// <param name="btnInt"></param> /// <param name="count"></param> /// <param name="p1"></param> /// <param name="outCard"></param> /// <param name="offset"></param> void SetState(string btnInt, ePlayer p, int count, Vector3 outCard, float offset) { //UIManager.Instance.SetBtnInter(btnInt); //nowPlayer = PlayerManager.instance.GetPlayer(count); //if (CountDown(clockPos[count].position) == 1) //{ // cm.RandomOneHitCard(nowPlayer.GetAllCard(),nowPlayer.GetAllOutHitCard()); // cm.OutCard(nowPlayer.GetAllCard(), nowPlayer.GetAllOutHitCard(),gm.hitCardPos[count], outCard, offset); // if (btnInt != "d") // { // cm.CancelBackCard((nowPlayer as OtherPlayer).GetAllBlackCard(), 1); // } // hitPlayer = p; //} }
public Player(ePlayer i_WhichPlayer) { m_WhichPlayerAmI = i_WhichPlayer; if (m_WhichPlayerAmI == ePlayer.Player1) { m_PlayersSoldierSign = (char)ePlayerSigns.Player1Soldier; m_PlayersKingSign = (char)ePlayerSigns.Player1King; } else { m_PlayersSoldierSign = (char)ePlayerSigns.Player2Soldier; m_PlayersKingSign = (char)ePlayerSigns.Player2King; } }
//下棋 //下棋成功后前往主要阶段2 override public void setChessPlayer(int card_id, ePlayer card_belong, ChessContainer grid) { if (Main.Inst.select_card == null || Main.Inst.Action_Chance == 0) { return; } //非战斗区域不能进入 if (!Main.Inst.lv_ctrl.AreaBattle.Contains(grid.number)) { return; } setChess(card_id, card_belong, grid, BKKZ.POW01.AI.eAI_Type.Default, true, GameRule.PlayerChessEventID, 0); //流程标志 Main.Inst.Action_Chance--; GoNext(); }
void Update() { if (this.transform.parent.gameObject.name == "tower(Clone)") { parentsOwner = this.transform.parent.gameObject.GetComponent <Tower>().myOwner; } else if (this.transform.parent.gameObject.name == "ShockTower(Clone)") { parentsOwner = this.transform.parent.gameObject.GetComponent <Tower>().myOwner; } else { parentsOwner = this.transform.parent.gameObject.GetComponent <DeathRay>().myOwner; } buildConnections(); updateConnectionColors(); }
// Return a list of towers ordered by how many units the towers have // 0 position is most units, .Length position is least units // // player is the players unit returned. i.e. ePlayer.Player1 returns all // the player 1 towers sorted by unit count public TowerState[] getTowersByUnit(ePlayer player) { // Code is not tested var towers = this.mtowers; var towerList = new List <TowerState>(); for (int i = 0; i < towers.Length; i++) { if (player == towers[i].mPlayer) { towerList.Add(towers[i]); towers[i].mVisited = true; } } return(towerList.ToArray()); }
private void addScore(ePlayer i_PlayerType) { switch (i_PlayerType) { case ePlayer.Player1: m_Player1.AddScore(); break; case ePlayer.Player2: m_Player2.AddScore(); break; case ePlayer.PlayerAI: m_PlayerAI.AddScore(); break; } }
// Returns the number of units a player has on screen // // player is the players unit to be counted public int getUnitsOnScreenCount(ePlayer player) { Debug.LogError("getUnitsOnScreenCount not initilized"); /* * Code is not tested * var unitsOnScreen = GameObject.FindGameObjectsWithTag("Units"); * var unitCount = 0; * for (int i = 0; i < unitsOnScreen.Length; i++ ) * { * if(unitsOnScreen[i].GetComponent<unitBehavior>()) * { * unitCount++; * } * } */ return(-1); }
public GameLogics(string i_Player1Name, string i_Player2Name) { m_Player1 = new Player(i_Player1Name); if (i_Player2Name != string.Empty) { m_Player2 = new Player(i_Player2Name); m_PlayerAI = null; s_Opponent = ePlayer.Player2; } else { m_PlayerAI = new AIPlayer(); m_Player2 = null; s_Opponent = ePlayer.PlayerAI; } m_TurnNumber = 1; }
public void BFS(GameObject root) { Dictionary <GameObject, LineRenderer> rootAdjacent = root.GetComponentInChildren <Connection>().connections; //todo reduce the .getComponent<> calls they are expensive foreach (var node in rootAdjacent) { if (root.GetComponent <DeathRay>().myOwner == node.Key.GetComponent <Tower>().myOwner) { TowerQ.Enqueue(node.Key); node.Key.GetComponent <Tower>()._visited = true; if (root.GetComponent <DeathRay>().myOwner == ePlayer.Player1) { //player1Score += 10; // this was the old version player1Score += node.Key.GetComponent <Tower>().Units; node.Key.GetComponent <Tower>().PlayPlusTen(); } } } while (TowerQ.Count != 0) { GameObject currentNode = TowerQ.Dequeue(); //remove the first element ePlayer myOwner = currentNode.GetComponent <Tower>().myOwner; // get the owner of current if (!currentNode.GetComponent <Tower>()._visited) { if (root.GetComponent <DeathRay>().myOwner == ePlayer.Player1) { player1Score += 10; currentNode.GetComponent <Tower>().PlayPlusTen(); } currentNode.GetComponent <Tower>()._visited = true; } Dictionary <GameObject, LineRenderer> adjacent = currentNode.GetComponentInChildren <Connection>().connections; foreach (var node in adjacent) { ePlayer childOwner = node.Key.GetComponent <Tower>().myOwner; // get the owner of the child node if (myOwner == childOwner && node.Key.GetComponent <Tower>()._visited == false) { TowerQ.Enqueue(node.Key); } } } }
public BoardState(eSquare[,] currentBoard) { currentPlayerTurn = ePlayer.Naught; this.currentBoard = currentBoard; calculateBoardScore(); }
public BoardState() { currentPlayerTurn = ePlayer.Naught; }
private void setCurrentPlayerTurn(ePlayer ePlayer) { currentPlayerTurn = ePlayer; }
private void WordScored(ePlayer player, Word word) { bool yourScore = player == ePlayer.You; if (word.Bombed) yourScore = !yourScore; switch (yourScore) { case true: CrunchCore.yourWords.Add(word); foreach (GameSquare s in word.GameSquares) { yourParticles.AddParticles(new Vector2(s.rect.X + 50, s.rect.Y + 50)); //if (word.Bombed) //{ // bombParticles.AddParticles(new Vector2(s.rect.X + 50, s.rect.Y + 50)); //} //else //{ //} } break; case false: CrunchCore.opponentsWords.Add(word); foreach (GameSquare s in word.GameSquares) { enemyParticles.AddParticles(new Vector2(s.rect.X + 50, s.rect.Y + 50)); } break; } }
public GoodGuessResponseMessage(int scoreYou, int scoreOpponent, ePlayer player, Word word) { this.scoreYou = scoreYou; this.scoreOpponent = scoreOpponent; this.Player = player; this.Word = word; }