public IEnumerator SetControllingTeamAnimation(GameManager.Player newControllingTeam, ActionMarker.ActionSprite action) { float ballAnimationTime = settingController.GetAnimationSpeed(); ActionMarker actionMarker; if (newControllingTeam == GameManager.Player.A) { actionMarker = GameObject.Find("Player A Areas").GetComponentInChildren <ActionMarker> (); } else { actionMarker = GameObject.Find("Player B Areas").GetComponentInChildren <ActionMarker> (); } actionMarker.SetMarker(action); yield return(new WaitForSeconds(ballAnimationTime / 2)); controllingTeam = newControllingTeam; if (controllingTeam == GameManager.Player.A) { GetComponent <Image>().sprite = teamASprite; } else { GetComponent <Image>().sprite = teamBSprite; } yield return(new WaitForSeconds(ballAnimationTime / 2)); actionMarker.RemoveMarker(); }
public void PassTurn(GameManager.Player player) { string data = JsonUtility.ToJson(player); socket.Emit("pass turn", new JSONObject(data)); Debug.Log("emit pass turn"); }
public static void GoalScored(GameManager.Player scoringPlayer) { if (scoringPlayer == GameManager.Player.A) { scoreA++; } else { scoreB++; } }
public virtual bool Play() { //play GameManager.Player p = GameManager.self.curPlayer; if (p.resources >= cost) { p.resources -= cost; return(true); } return(false); }
void controlCannon() { // Rotate cannon int x = 0, y = 0; if (Input.GetKey(KeyCode.I)) { y = 1; } else if (Input.GetKey(KeyCode.K)) { y = -1; } if (Input.GetKey(KeyCode.J)) { x = -1; } else if (Input.GetKey(KeyCode.L)) { x = 1; } if (x != 0 || y != 0) { // FIXME needs a better way for figuring out which rotator is which CannonRotator[] rotators = gameManager.CurrentPlayer.Cannon.GetComponentsInChildren <CannonRotator>(); if (x != 0) { rotators[1].Rotate(360 * x * Time.deltaTime); } if (y != 0) { rotators[0].Rotate(360 * y * Time.deltaTime); } } // Fire current cannon if (Input.GetKeyDown(KeyCode.Keypad0) || Input.GetKeyDown(KeyCode.Alpha0)) { GameManager.Player player = gameManager.CurrentPlayer; CannonController cannon = player.Cannon.GetComponent <CannonController>(); cannon.Fire(); } if (Input.GetKeyDown(KeyCode.Keypad3) || Input.GetKeyDown(KeyCode.Alpha3)) { Debug.Log("DEBUG suicide"); GameManager.Player player = gameManager.CurrentPlayer; IDestroyableObject destroyable = player.Cannon.GetComponent <IDestroyableObject>(); destroyable.OnDestroyObject(); } }
public void SetControllingTeam(GameManager.Player newControllingTeam) { controllingTeam = newControllingTeam; if (controllingTeam == GameManager.Player.A) { GetComponent <Image>().sprite = teamASprite; } else { GetComponent <Image>().sprite = teamBSprite; } }
private void changeTileOwner(int x, int y, GameManager.Player newOwner) { GameObject tempTile; tempTile = tileStore[x, y]; if (newOwner == GameManager.Player.PLAYER_BLACK) { tempTile.GetComponent <MeshRenderer>().material = blackTile; } else { tempTile.GetComponent <MeshRenderer>().material = whiteTile; } tempTile.GetComponent <TileScript>().SetOwner(newOwner); }
/// <summary> /// Counts the tiles that are owned by the given player and returns the amount /// </summary> /// <param name="player">The player who is being checked for</param> /// <returns>An int value representing the number of tiles</returns> public int GetScore(GameManager.Player player) { int tempScore = 0; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { if (this.tileStore[x, y].GetComponent <TileScript>().GetOwner() == player) { tempScore++; } } } return(tempScore); }
/// <summary> /// Using this. Populate the data for each player /// </summary> /// <param name="formationCountNumber"></param> /// <param name="playsCounter"></param> public void Populate(int formationCountNumber, int playsCounter) { if (playerStats.Points != null) { var play = new GameManager.Player(); play.PlayerName = playerStats.PlayerName; play.PlayerID = playerStats.PlayerID; play.PlayerPointerType = playerStats.PlayerPointerType; play.Points = playerStats.Points; play.PointerPosition = playerStats.PointerPosition; play.PointerRotation = playerStats.PointerRotation; play.PlayerLocalPosition = playerStats.PlayerLocalPosition;// transform.position; Debug.Log("punam data za formacija i play" + GameManager.Instance.allFormations.AllFormmations[formationCountNumber].LinkedPlaysWithFormation[playsCounter].PlayName); GameManager.Instance.allFormations.AllFormmations[formationCountNumber].LinkedPlaysWithFormation[playsCounter].LinkedPlayersWithPlays.Add(play); } }
public List <Vector3> GetOpKingsPositions(Vector3 point, GameManager.Player pl) { Debug.Log("King at: " + point); List <Vector3> positions = new List <Vector3>(); foreach (Vector3 p in kingPositions) { Vector3 pos = p + point; if (GameManager.Instance.HasPiece(pos) == false || GameManager.Instance.EnemyPieceAtLocationOpPlayer(pos, pl) == false) { positions.Add(pos); } } Debug.Log("Before: " + positions.Count); positions.RemoveAll(pos => pos.x < 1 || pos.x > 8 || pos.z < 11 || pos.z > 18); Debug.Log("After: " + positions.Count); return(positions); }
public IEnumerator DrawToHand(List <Card> hand, GameObject playerAreas, GameManager.Player player) { GameObject deckObject = playerAreas.transform.Find("Deck").gameObject; GameObject handObject = playerAreas.transform.Find("Hand").gameObject; foreach (Card playingCard in hand) { // Only draw cards which are still in the deck if (playingCard.transform.parent == deckObject.transform) { // Prepare param hashtable for calling SetCardParentAfterAnimation when iTween finishes Hashtable param = new Hashtable(); param.Add("Card", playingCard); param.Add("parentToSet", handObject); if (player == GameManager.Player.A) { param.Add("showFace", true); } else { param.Add("showFace", false); } Vector3 handPos = handObject.transform.position; iTween.MoveTo( playingCard.gameObject, iTween.Hash("x", handPos.x + 1.2, "y", handPos.y + 0.8, "time", 0.5, "easeType", "easeInOutQuad", "oncomplete", "SetCardParentAfterAnimation", "oncompletetarget", gameObject, "oncompleteparams", param)); yield return(new WaitForSeconds(0.2f)); } } }
private static int[][] SelectEfficiencyTable(GameManager.Player controllingPlayer, Ball.BallPosition ballPosition) { if ((controllingPlayer == GameManager.Player.B) && (ballPosition != Ball.BallPosition.PlayerAField)) { return(case1); } else if ((controllingPlayer == GameManager.Player.B) && (ballPosition == Ball.BallPosition.PlayerAField)) { return(case2); } else if ((controllingPlayer == GameManager.Player.A) && (ballPosition != Ball.BallPosition.PlayerBField)) { return(case3); } else if ((controllingPlayer == GameManager.Player.A) && (ballPosition == Ball.BallPosition.PlayerBField)) { return(case4); } else { Debug.LogWarning("No efficiency table was selected for he AI. Returning default table"); return(case1); } }
// Needs to be called every frame public void Update() { int inc = 0; switch (checkInput()) { case Action.PREVIOUS: inc = -1; break; case Action.NEXT: inc = 1; break; } if (inc != 0) { GameManager.Player player = gameManager.CurrentPlayer; int index = mod(player.CurrentTeleportIndex + inc, player.TeleportLocations.Count); player.CurrentTeleportIndex = index; TeleportTo(player.TeleportLocations[index]); } }
void controlCamera() { // Teleport to current cannon if (Input.GetKeyDown(KeyCode.Keypad1) || Input.GetKeyDown(KeyCode.Alpha1)) { GameManager.Player player = gameManager.CurrentPlayer; Vector3 pos = player.TeleportLocations[0].Position; Vector3 fwd = player.Cannon.transform.forward; Vector3 finalPos = pos - fwd * 2; finalPos.y += 1; mainCamera.transform.position = finalPos; mainCamera.transform.LookAt(pos); } // Camera movement Vector3 vec = Vector2.zero; if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) { vec.z += 1; } else if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) { vec.z -= 1; } if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) { vec.x -= 1; } else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) { vec.x += 1; } if (Input.GetKey(KeyCode.Q) || Input.GetKey(KeyCode.KeypadPlus)) { vec.y += 1; } else if (Input.GetKey(KeyCode.Z) || Input.GetKey(KeyCode.KeypadMinus)) { vec.y -= 1; } Transform t = mainCamera.transform; t.position += t.forward * vec.z * Time.deltaTime; t.position += t.right * vec.x * Time.deltaTime; t.position += t.up * vec.y * Time.deltaTime; // Camera rotation if (Input.GetMouseButton(0)) { Vector3 mousePos = Input.mousePosition; if (mouseDown) { Vector3 dm = mousePos - lastMousePos; float x = dm.x / Screen.width; float y = -dm.y / Screen.height; mainCamera.transform.Rotate(0, x * 45, 0, Space.World); mainCamera.transform.Rotate(y * 45, 0, 0); } mouseDown = true; lastMousePos = mousePos; } else { mouseDown = false; } }
public static Card SelectCardToPlay(string AILevel, List <Card> AIhand, List <Card> deckPlayer, GameManager.Player controllingPlayer, Ball.BallPosition ballPosition) { if (AILevel == "Hard") { Card selectedCard = null; int cardEfficiency; int bestEfficiency = -1000; int[][] efficiencyTable = SelectEfficiencyTable(controllingPlayer, ballPosition); foreach (Card cardHand in AIhand) { // Rank one is a special case if (cardHand.GetRank() == 1) { cardEfficiency = SelectRankOneEfficiency(); } else { cardEfficiency = CalculateEfficiency(cardHand, deckPlayer, efficiencyTable); } if (cardEfficiency > bestEfficiency) { bestEfficiency = cardEfficiency; selectedCard = cardHand; } } return(selectedCard); } // On easy mode return a random card from the hand return(AIhand [Random.Range(0, AIhand.Count)]); }
// This function is an asynchronous coRoutine because all the animations need to finish before the code resumes public IEnumerator MoveBallAction(GameManager.Player movingPlayer, ActionMarker.ActionSprite action) { float ballAnimationTime = settingController.GetAnimationSpeed(); float moveBy = 2.1f; // Move only if the controlling team is the one moving if (movingPlayer == controllingTeam) { if (movingPlayer == GameManager.Player.A) { ActionMarker actionMarker = GameObject.Find("Player A Areas").GetComponentInChildren <ActionMarker> (); actionMarker.SetMarker(action); if (ballPosition == BallPosition.PlayerAField) { iTween.MoveBy(gameObject, iTween.Hash("y", moveBy, "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.Middle; yield return(new WaitForSeconds(ballAnimationTime)); } else if (ballPosition == BallPosition.Middle) { iTween.MoveBy(gameObject, iTween.Hash("y", moveBy, "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.PlayerBField; yield return(new WaitForSeconds(ballAnimationTime)); } else if (ballPosition == BallPosition.PlayerBField) { iTween.MoveBy(gameObject, iTween.Hash("y", moveBy / 2, "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.PlayerBGoal; yield return(new WaitForSeconds(ballAnimationTime)); } actionMarker.RemoveMarker(); } else // movingPlayer == PlayerB { ActionMarker actionMarker = GameObject.Find("Player B Areas").GetComponentInChildren <ActionMarker> (); actionMarker.SetMarker(action); if (ballPosition == BallPosition.PlayerBField) { iTween.MoveBy(gameObject, iTween.Hash("y", -moveBy, "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.Middle; yield return(new WaitForSeconds(ballAnimationTime)); } else if (ballPosition == BallPosition.Middle) { iTween.MoveBy(gameObject, iTween.Hash("y", -moveBy, "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.PlayerAField; yield return(new WaitForSeconds(ballAnimationTime)); } else if (ballPosition == BallPosition.PlayerAField) { iTween.MoveBy(gameObject, iTween.Hash("y", -(moveBy / 2), "time", ballAnimationTime, "easeType", "easeInOutQuad")); ballPosition = BallPosition.PlayerAGoal; yield return(new WaitForSeconds(ballAnimationTime)); } actionMarker.RemoveMarker(); } } else { yield return(SetControllingTeamAnimation(movingPlayer, action)); } }
private bool ownedByOpponent(GameObject tile) { GameManager.Player owner = tile.GetComponent <TileScript>().GetOwner(); return(owner != gameManager.GetCurrentPlayer() && owner != GameManager.Player.NONE); }