private void Update() { bool isComplete = turns[turnIndex].forceExit; if (isComplete) { turns[turnIndex].forceExit = false; //Debug.Log("Turn is complete"); //Settings.RegisterEvent(turns[turnIndex].name + " finished", currentPlayer.playerColor); turnIndex++; if (turnIndex > turns.Length - 1) { turnIndex = 0; } currentPlayer = turns[turnIndex].player; turns[turnIndex].OnTurnStart(); turns[turnIndex].player.cardsPlayedThisTurn = 0; turnText.value = turns[turnIndex].player.username; onTurnChanged.Raise(); } if (currentState != null) { currentState.Tick(Time.deltaTime); } }
public void LoadPlayer(PlayerHolder p, PlayerStatsUI statsUI) { if (p == null) { return; } playerHolder = p; foreach (CardInstance c in p.downCards) { if (c == null) { continue; } Settings.SetParentForCard(c.viz.gameObject.transform, downGrid.value.transform); } foreach (CardInstance c in p.handCards) { if (c.viz != null) { Settings.SetParentForCard(c.viz.gameObject.transform, handGrid.value.transform); } } p.statsUI = statsUI; p.LoadPlayerOnStatsUI(); }
public void LoadPlayerOnActive(PlayerHolder p) { if (playerOneHolder.playerHolder != p) { PlayerHolder prevPlayer = playerOneHolder.playerHolder; LoadPlayerOnHolder(prevPlayer, otherPlayersHolder, statsUI[1]); LoadPlayerOnHolder(p, playerOneHolder, statsUI[0]); } }
private void Awake() { singleton = this; all_players = new PlayerHolder[turns.Length]; for (int i = 0; i < turns.Length; i++) { all_players[i] = turns[i].player; } currentPlayer = turns[0].player; currentState = turns[0].myTurnState; }
public PlayerHolder GetEnemyOf(PlayerHolder p) { if (p == all_players[0]) { return(all_players[1]); } else if (p == all_players[1]) { return(all_players[0]); } else { return(null); } }
public override void Execute(float d) { if (Input.GetMouseButtonDown(0)) { List <RaycastResult> results = Settings.GetUIObjs(); GameManager gm = GameManager.singleton; PlayerHolder currentPlayer = gm.currentPlayer; PlayerHolder[] all_players = gm.all_players; PlayerHolder otherPlayer = gm.GetEnemyOf(currentPlayer); foreach (RaycastResult r in results) { Damageable target = r.gameObject.GetComponentInParent(typeof(Damageable)) as Damageable; PlayerStatsUI target2 = r.gameObject.GetComponentInParent(typeof(PlayerStatsUI)) as PlayerStatsUI; if (target == null) { continue; } if (target is Player && target2.player == otherPlayer) { if (attacker != null) { attacker.viz.outline.SetActive(false); attacker.state = CardInstance.State.Tired; //resolveCombat.Battle(attacker,(Player)target); otherPlayer.Damage(attacker.GetAttack()); Debug.Log(attacker); Debug.Log(target); attacker = null; } } else if (target is CardInstance) { CardInstance card = (CardInstance)target; if (currentPlayer.downCards.Contains(card)) { if (card.CanAttack()) { if (attacker != null) //if we already have an attacker disable it { attacker.state = CardInstance.State.Idle; attacker.viz.outline.SetActive(false); if (attacker == card) { attacker = null; continue; } } attacker = card; attacker.state = CardInstance.State.Attacking; attacker.viz.outline.SetActive(true); } } else if (otherPlayer.downCards.Contains(card)) { if (attacker != null) { attacker.viz.outline.SetActive(false); attacker.state = CardInstance.State.Attacking; resolveCombat.Battle(attacker, card); attacker = null; } } } } } }
public void LoadPlayerOnHolder(PlayerHolder p, CardHolders h, PlayerStatsUI ui) { h.LoadPlayer(p, ui); }