private void CheckWinCondition(PlayerData arg1, PlayerData arg2)
    {
        int count = 0;

        for (int i = 0; i < playerList.Count; i++)
        {
            count += playerList[i].alive ? 1 : 0;
            if (count > 1)
            {
                return;
            }
        }

        // give score
        for (int i = 0; i < playerList.Count; i++)
        {
            if (playerList[i].alive)
            {
                lastWinnerId = playerList[i].playerId;
                playerList[i].matchScore++;
                if (playerList[i].matchScore >= 3)
                {
                    lastRound = true;
                }
                break;
            }
        }

        StartCoroutine(_EndGame());
    }
Exemple #2
0
 public PlayerData GetPlayerData(PlayerData.PlayerId id)
 {
     if (id == PlayerData.PlayerId.UNASSIGNED || id == PlayerData.PlayerId.MAX_PLAYERS)
     {
         return(null);
     }
     return(m_playerDatas[(int)id]);
 }
Exemple #3
0
    public void Claim(PlayerData.PlayerId owner)
    {
        Color ownerColor = Main.Instance.GetPlayerData(owner).m_color;
        //SetColor(ownerColor);
        int scoreLost   = 0;
        int scoreGained = 0;
        int totalValue  = 0;

        bool roofed = GetTopPart().m_type == BaseBuildingPart.BuildingPartType.Roof;

        if (roofed)
        {
            ownerColor.r += 0.5f;
            ownerColor.g += 0.5f;
            ownerColor.b += 0.5f;
        }

        for (int i = 0; i < m_buildingParts.Count; ++i)
        {
            BaseBuildingPart part = m_buildingParts[i];
            part.SetColor(ownerColor);

            if (roofed)
            {
                part.RoofUpgrade();
            }

            int scoreValue = i + 1;
            if (part.m_owner != owner)
            {
                if (i < m_buildingParts.Count - 1)
                {
                    scoreLost   -= scoreValue;
                    scoreGained += scoreValue;
                }
                else
                {
                    scoreGained += scoreValue;
                }
            }

            totalValue  += scoreValue;
            part.m_owner = owner;
        }

        if (roofed)
        {
            scoreGained += totalValue;
        }

        Vector3 pos = m_buildingParts[m_buildingParts.Count - 1].transform.position;

        Main.Instance.ModifyScore(m_owner, scoreLost);
        m_owner = owner;
        Main.Instance.ModifyScore(m_owner, scoreGained);

        VFXManager.Instance.ThrowScoreDoober(pos, m_owner, scoreGained, roofed);
    }
Exemple #4
0
    public void ThrowScoreDoober(Vector3 pos, PlayerData.PlayerId target, int scoreDelta, bool roofed)
    {
        if (target == PlayerData.PlayerId.UNASSIGNED || scoreDelta <= 0)
        {
            return;
        }

        pos.y += 0.5f;
        ThrowDoober(pos, string.Format("{0}+{1}", (roofed)?"Roofed!\n":string.Empty, scoreDelta), Color.white);
    }
Exemple #5
0
    public void Place(BaseTile placementTile, PlayerData.PlayerId owner)
    {
        m_isBeingCarried = false;
        transform.parent = null;
        RestoreRigidbody();
        DOTween.Kill(transform);

        placementTile.AddBuildingPart(this);
        placementTile.Claim(owner);

        VFXManager.Instance.DoPlacePuffVFX(transform.position);
    }
Exemple #6
0
    public void ModifyScore(PlayerData.PlayerId playerId, int scoreDelta)
    {
        if (scoreDelta == 0)
        {
            return;
        }
        //Debug.LogFormat("Score Change {0}: {1}", playerId, scoreDelta);

        PlayerData player = GetPlayerData(playerId);

        if (player != null)
        {
            player.m_score += scoreDelta;
            m_scoreDirty    = true;
        }
    }
Exemple #7
0
        public PlayerSpawner GetSpawnerByPlayerId(PlayerData.PlayerId playerId)
        {
            // Same using Linq.
            // return _playerSpawners.FirstOrDefault( s => s.PlayerId == playerId );

            PlayerSpawner spawner = null;

            foreach (var playerSpawner in _playerSpawners)
            {
                if (playerSpawner.PlayerId == playerId)
                {
                    spawner = playerSpawner;
                }
            }
            return(spawner);
        }
        public void Init(PlayerData.PlayerId playerId)
        {
            PlayerId = playerId;

            _dropdown = GetComponentInChildren <Dropdown>(true);
            _dropdown.ClearOptions();
            var optionDataList = new List <Dropdown.OptionData>();

            foreach (var value in Enum.GetValues(typeof(PlayerUnit.UnitType)))
            {
                if ((PlayerUnit.UnitType)value != PlayerUnit.UnitType.None)
                {
                    optionDataList.Add(new Dropdown.OptionData(value.ToString()));
                }
            }
            _dropdown.AddOptions(optionDataList);
            _dropdown.onValueChanged.AddListener(OnValueChanged);

            _dropdown.value = 0;
            OnValueChanged(0);
        }
        public void Init(PlayerData.PlayerId id,
                         InputManager.ControllerType defaultControllerType)
        {
            _dropdown = GetComponentInChildren <Dropdown>(true);
            _dropdown.ClearOptions();
            List <Dropdown.OptionData> optionDataList =
                new List <Dropdown.OptionData>();

            foreach (var value in
                     Enum.GetValues(typeof(InputManager.ControllerType)))
            {
                if ((InputManager.ControllerType)value !=
                    InputManager.ControllerType.None)
                {
                    string controllerName =
                        InputManager.GetControllerName(
                            (InputManager.ControllerType)value);
                    optionDataList.Add(new Dropdown.OptionData(controllerName));
                }
            }

            _dropdown.AddOptions(optionDataList);
            _dropdown.onValueChanged.AddListener(OnValueChanged);

            Id         = id;
            Controller = defaultControllerType;

            int defaultIndex =
                GetItemIndex(InputManager.
                             GetControllerName(defaultControllerType));

            if (defaultIndex > 0)
            {
                _dropdown.value = defaultIndex;
            }
        }
 public void SetId(int id)
 {
     this.ID = (PlayerData.PlayerId)id;
 }
Exemple #11
0
 public PlayerUnit GetPlayerUnit(PlayerData.PlayerId playerId)
 {
     return(_players.ContainsKey(playerId)
                         ? _players[playerId]
                         : null);
 }