// Use this for initialization void Start() { if (hand == null) { Debug.LogError("Hand is not set"); } handBehaviour = hand.GetComponent<HandBehaviour>(); }
public void Start() { m_time = m_timePerTurn; m_hand = GameObject.FindObjectOfType<HandBehaviour>(); m_board = (BoardBehaviour)GameObject.FindObjectOfType<BoardBehaviour>(); InvokeRepeating("CountDown", 1, 1); InvokeRepeating("SetTimeSandFloat", 0, 1); }
protected IEnumerator SuckUpHandCards(HandBehaviour hand) { var startPositions = new Vector3[hand.Cards.Count]; var startRotations = new Quaternion[hand.Cards.Count]; for (var i = 0; i < hand.Cards.Count; i++) { startPositions[i] = hand.Cards[i].transform.position; startRotations[i] = hand.Cards[i].transform.rotation; } // Rotate all cards back to face down. var startTime = Time.time; var endTime = startTime + hand.ShiftTime; var targetEuler = transform.rotation.eulerAngles + new Vector3(0, 180, 0); var targetRotation = Quaternion.Euler(targetEuler.x, targetEuler.y, targetEuler.z); while (Time.time < endTime) { var iLerp = Mathf.InverseLerp(startTime, endTime, Time.time); for (var i = 0; i < hand.Cards.Count; i++) { hand.Cards[i].transform.rotation = Quaternion.Lerp(startRotations[i], targetRotation, iLerp); } yield return(null); } // Suck all cards back to the deck. startTime = Time.time; endTime = startTime + hand.ShiftTime; while (Time.time < endTime) { var iLerp = Mathf.InverseLerp(startTime, endTime, Time.time); for (var i = 0; i < hand.Cards.Count; i++) { hand.Cards[i].transform.position = Vector3.Lerp(startPositions[i], transform.position, iLerp); } yield return(null); } for (var i = hand.Cards.Count - 1; i >= 0; i--) { Deck.AddCard(hand.Cards[i].Card); DestroyImmediate(hand.Cards[i].gameObject); } hand.Cards.Clear(); }
/// <summary> /// Start a game of Ultimate Texas Holdem. /// </summary> /// <param name="numPlayers">Number of players.</param> /// <param name="playerPosition">Position of human player among players.</param> public void StartGame(int numPlayers, int playerPosition) { gameObject.SetActive(true); NumPlayers = numPlayers; PlayerPosition = playerPosition; Hands = new HandBehaviour[numPlayers]; if (NumPlayers % 2 == 1) { CreateOddHands(); } else { CreateEvenHands(); } Hands[PlayerPosition].IsPlayerHand = true; StartCoroutine(DealHands()); }
private void OnTriggerEnter(Collider other) { HandBehaviour hand = other.GetComponent <HandBehaviour>(); if (hand != null) { handsInside.Add(hand); hand.isDecreasing = false; hand.SetRotation(transform.parent.position); HandAudio handAd = hand.GetComponent <HandAudio>(); if (classCounter[handAd.GetClass()] < maxCounter) { classCounter[handAd.GetClass()]++; handsAudios.Add(handAd); handAd.Play(); } } }
IEnumerator iGetHand() { WWWForm form = new WWWForm(); form.AddField("playerID", m_joinResponse.playerID); form.AddField("gameID", m_joinResponse.gameID); UnityWebRequest www = UnityWebRequest.Post(m_host + "/game/get-hand", form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Debug.Log(www.downloadHandler.text); Game game = m_game.GetComponent <Game>(); HandBehaviour hand = game.m_player_hand.GetComponent <HandBehaviour> (); hand.SetHand(JsonUtility.FromJson <PlayedHand> (www.downloadHandler.text).hand); } }
private void Update() { if (IsGrounded() && Input.GetKeyDown(KeyCode.Space)) // Jump { m_Animator.SetBool("m_Jump", true); // Add anim for jump if (!m_Hide) { if (m_OnPogostick) { GetComponent <AudioSource>().PlayOneShot(pogoSound, 1.0f); m_Rigidbody2D.AddForce(new Vector2(0, m_JumpForcePogo)); m_OnPogostick = false; } else { m_Rigidbody2D.AddForce(new Vector2(0, m_JumpForce)); } } } if (Input.GetKeyDown(KeyCode.S) && !m_Hide && handRight == null) // Hide { m_Hide = true; handRight = Instantiate <HandBehaviour>(m_HandPrefab, new Vector3(6.8f, -10.0f, -5.0f), new Quaternion()); handLeft = Instantiate <HandBehaviour>(m_HandPrefab, new Vector3(-6.8f, -10.0f, -5.0f), Quaternion.Euler(0, 180.0f, 0)); } if (Input.GetKeyUp(KeyCode.S) && m_Hide) // Show { m_Hide = false; StartCoroutine(handRight.Disappear()); StartCoroutine(handLeft.Disappear()); } if (m_Hide && m_handCooldown == 300) { m_Hide = false; StartCoroutine(handRight.Disappear()); StartCoroutine(handLeft.Disappear()); m_handCooldown = 0; } if (m_Hide) { m_handCooldown++; } if (m_ToysPrefab != null && Input.GetMouseButtonDown(0) && !m_UsedToys[m_IndexToy]) { if (m_ToysPrefab[m_IndexToy].name == "Pogostick") { m_OnPogostick = true; m_UsedToys[m_IndexToy] = true; } else { if (m_FacingRight) { Flip(); } Toy toy = Instantiate(m_ToysPrefab[m_IndexToy]); toy.CharacterController = this; m_UsedToys[m_IndexToy] = true; m_Animator.SetBool("m_Throw", true); Physics2D.IgnoreCollision(GetComponent <BoxCollider2D>(), toy.GetComponent <BoxCollider2D>()); Vector3 newPos = transform.position; newPos.z = 5.0f; toy.transform.position = newPos; toy.LaunchLeft(); m_Animator.SetBool("m_Throw", false); } } if (m_ToysPrefab != null && Input.GetMouseButtonDown(1) && !m_UsedToys[m_IndexToy]) { if (m_ToysPrefab[m_IndexToy].name == "Pogostick") { m_OnPogostick = true; m_UsedToys[m_IndexToy] = true; } else { if (!m_FacingRight) { Flip(); } Toy toy = Instantiate(m_ToysPrefab[m_IndexToy]); toy.CharacterController = this; m_UsedToys[m_IndexToy] = true; m_Animator.SetBool("m_Throw", true); Physics2D.IgnoreCollision(GetComponent <BoxCollider2D>(), toy.GetComponent <BoxCollider2D>()); Vector3 newPos = transform.position; newPos.z = 5.0f; toy.transform.position = newPos; toy.LaunchRight(); } } if (m_ToysPrefab != null) { if (Input.GetKeyDown(KeyCode.Alpha1)) { m_IndexToy = 0; } if (Input.GetKeyDown(KeyCode.Alpha2)) { m_IndexToy = 1; } if (Input.GetKeyDown(KeyCode.Alpha3)) { m_IndexToy = 2; } if (Input.GetKeyDown(KeyCode.Alpha4)) { m_IndexToy = 3; } if (Input.GetKeyDown(KeyCode.Alpha5)) { m_IndexToy = 4; } if (Input.GetKeyDown(KeyCode.R)) { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } if (Input.GetAxis("Mouse ScrollWheel") != 0) { int updateIndex = (int)(Input.GetAxis("Mouse ScrollWheel") * 10 % 3); m_IndexToy += updateIndex; if (m_IndexToy < 0) { m_IndexToy = m_ToysPrefab.Length - 1; } else if (m_IndexToy > m_ToysPrefab.Length - 1) { m_IndexToy = 0; } } if (m_UIBag != null) { m_UIBag.ChangedToy(m_IndexToy, m_UsedToys[m_IndexToy]); } } }
void Awake() { player = GameObject.Find("Player").GetComponent <PlayerBehaviour>(); playerHand = GameObject.Find("PlayerHand").GetComponent <HandBehaviour>(); handBoard = playerHand.GetComponent <HandInput>(); }
void FixedUpdate() { int currentStage = m_network.GetComponent <Network>().m_stage; switch (currentStage) { case 0: m_trade_button.gameObject.SetActive(true); m_transmit_button.gameObject.SetActive(false); break; case 2: m_trade_button.gameObject.SetActive(false); m_transmit_button.gameObject.SetActive(true); break; case 1: case 3: default: m_trade_button.gameObject.SetActive(false); m_transmit_button.gameObject.SetActive(false); break; } if (!m_game_running) { return; } for (int i = 0; i < m_players.Length; ++i) { Bot bot = m_players[i].bot.GetComponent <Bot>(); if (bot.GetStatus() == Bot.Status.Dead) { m_game_running = false; Invoke("RestartGame", 3.0f); m_network.GetComponent <Network>().leaveGame(); return; } } if (m_action_sequence.Count > 0) { Bot bot = m_players[m_action_player].bot.GetComponent <Bot>(); if (bot.GetStatus() == Bot.Status.Idle) { Action action = m_actions.GetAction(m_action_sequence.Pop()); if (action.passive.actions != null) { for (int i = action.passive.actions.Length - 1; i >= 0; --i) { m_action_sequence.Push(action.passive.actions[i]); } } if (action.passive.player_move != 0) { bot.Move(action.passive.player_move); } else if (action.passive.turn_body > 0) { bot.TurnRight(); } else if (action.passive.turn_body < 0) { bot.TurnLeft(); } else if (action.passive.turn_turret > 0) { bot.TurnTurretRight(); } else if (action.passive.turn_turret < 0) { bot.TurnTurretLeft(); } else if (action.passive.align_turret_to_body) { bot.AlignTurret(); } else if (action.passive.target_modifier != 0) { m_target_bot.Modifier(action.passive.target_modifier); } else if (action.passive.player_modifier != 0) { bot.Modifier(action.passive.player_modifier); } else if (action.passive.target_move != 0) { m_target_bot.ForcedMove(m_target_dir); } else if (action.name == "fire" || action.name == "vampiric_shot") { Arena.HitInfo hitinfo = bot.Fire(); if (hitinfo.hit) { m_target_bot = hitinfo.bot; if (action.on_hit.actions != null) { for (int i = action.on_hit.actions.Length - 1; i >= 0; --i) { m_action_sequence.Push(action.on_hit.actions[i]); } } } } } } else if (!m_arena_acted) { Bot bot = m_players[m_action_player].bot.GetComponent <Bot>(); if (bot.GetStatus() == Bot.Status.Idle) { m_arena_acted = true; Tiles.Tile tile = bot.GetTile(); if (tile.actions != null) { for (int i = tile.actions.Length - 1; i >= 0; --i) { m_action_sequence.Push(tile.actions[i]); } m_target_bot = bot; m_target_dir = bot.GetTileDir(); } } } else { Bot bot = m_players[m_action_player].bot.GetComponent <Bot>(); if (m_card_sequence.Count > 0 && bot.GetStatus() == Bot.Status.Idle) { Card card = m_cards.GetCard(m_card_sequence.Pop()); HandBehaviour player_hand = m_player_hand.GetComponent <HandBehaviour> (); HandBehaviour opponent_hand = m_opponent_hand.GetComponent <HandBehaviour> (); player_hand.SelectCard(card); opponent_hand.SelectCard(card); ActionSequence(m_player_sequence.Pop(), card.actions); } } }