// Update is called once per frame void Update() { // Used to have the UI component slide in when needed var step = speed * Time.deltaTime; selfTransform.anchoredPosition = Vector3.MoveTowards(selfTransform.anchoredPosition, targetPosition, step); //Don't do anything if we don't have a player toggled if (player == null) { return; } //Keep the labels updated playerName.GetComponent <Text>().text = player.AgentName; cardsLabel.GetComponent <Text>().text = "Cards Count: " + player.CardCount(); starsLabel.GetComponent <Text>().text = "Stars: " + player.stars.ToString(); // If the player got sucked into a match without closing the panel // we'll close it for them. if (isInView && localChallengeLobbyManager.clientPlayer.IsInMatch) { hidePanel(); } bool isInPosition = (selfTransform.anchoredPosition3D - targetPosition).sqrMagnitude < 0.01f; if (isInView && isInPosition && Input.GetMouseButtonUp(0) && !RectTransformUtility.RectangleContainsScreenPoint(selfTransform, Input.mousePosition)) { hidePanel(); } }
private void SetLabelText(GameObject label, RpsAgent player) { label.transform.FindChild("Name").GetComponent <Text>().text = player.AgentName; label.transform.FindChild("Stats").GetComponent <Text>().text = "Remaining Cards: " + player.CardCount() + "\n" + "Stars: " + player.stars; }
public void IncrementCurrentCard() { CurrentCard = (CurrentCard + 1) % player.CardCount(); if (CurrentCard >= player.CardCount()) { CurrentCard -= player.CardCount(); } UpdateHoverAnimation(); }
// Update is called once per frame void Update() { if (player.CardCount() == 0 && player.stars > 0) { render.sprite = winSprite; } else if (player.stars == 0) { render.sprite = lostSprite; } else if (player.IsInMatch) { render.sprite = inMatchSprite; } else if (!player.IsInMatch) { render.sprite = defaultSprite; } }
public virtual void LoadForMatch(RpsAgent player) { this.player = player; isInteractable = true; this.gameObject.SetActive(true); ClearHand(); CreateHand(); RepositionHand(); if (!isHidden) { cardVisuals[CurrentCard].Hover(); lastHoveredCard = 0; } else { CurrentCard = player.CardCount() / 2; lastHoveredCard = CurrentCard; } }
public static void StartMatchRequest(RpsAgent initiator, RpsAgent victim) { if (initiator.stars <= 0) { Debug.Log("You lost and can't request matches"); return; } if (initiator == victim) { Debug.LogWarning("Server: Player trying to request match with himself."); return; } if (victim.IsInMatch) { Debug.Log("Player is already in a match"); return; } if (instance.requests.Exists(r => (r.initiator == initiator))) { Debug.LogWarning("Server: Initiator Player has already requested a match."); return; } if (victim.CardCount() == 0 || victim.stars <= 0) { Debug.LogWarning("Server: Victim has no cards to play with."); return; } Debug.Log("Server creating a match request. Initiator: " + initiator.AgentName + " Victim: " + victim.AgentName); MatchRequest matchRequest = new MatchRequest(initiator, victim); instance.requests.Add(matchRequest); // Tell otherPlayer that they have a match request waiting. victim.NotifyMatchRequest(initiator, matchRequest.timeRemaining); }