public bool CheckIfPlayerHasLost(int playerIndex) { Agent current = GetPlayer(playerIndex); if (!current.Data.HasLost) { var targets = MovementHelper.GetTargets(current); if (targets.Count == 0) { current.Data.HasLost = true; } // check if the current player has captured MisterX if (current.Data.PlayerType != EPlayerType.MISTERX) { Agent misterX = GetMisterX(); if (misterX != null) { misterX.Data.HasLost = string.Equals(current.Position.GetComponent <StreetPoint>()?.name, misterX.Position.GetComponent <StreetPoint>()?.name); } } } return(current.Data.HasLost); }
protected void MoveRandomly() { // determine street StreetPoint currentPoint = Position.GetComponent <StreetPoint>(); List <GameObject> targets = MovementHelper.GetTargets(this); if (targets.Count > 0) { int index = System.Convert.ToInt32(Random.Range(0, targets.Count)); // pay ticket IStreet street = currentPoint.GetPathByPosition(Position, targets[index]); var cost = street.ReturnTicketCost().Where(c => HasTicket(c)).ToArray(); RemoveTicket(cost[System.Convert.ToInt32(Random.Range(0, cost.Length))]); // move StartCoroutine(nameof(Move), street); } else { Data.HasLost = true; GameEvents.Current.PlayerMoveFinished(this, new PlayerEventArgs(this.Data)); } }