Пример #1
0
    public void HidePanelPlayerPanel(UnitCombatSystem.Team activeTeam, GameModeEnum gameMode)
    {
        if (activeTeam == UnitCombatSystem.Team.Left)
        {
            if (gameMode == GameModeEnum.Game)
            {
                _rightPanelGameMode.SetActive(false);
                _leftPanelGameMode.SetActive(true);
                return;
            }

            if (gameMode == GameModeEnum.DraftPick)
            {
                _rightPanelDraftPick.SetActive(false);
                _leftPanelDraftPick.SetActive(true);
            }
        }
        else
        {
            if (gameMode == GameModeEnum.Game)
            {
                _rightPanelGameMode.SetActive(true);
                _leftPanelGameMode.SetActive(false);
                return;
            }

            if (gameMode == GameModeEnum.DraftPick)
            {
                _rightPanelDraftPick.SetActive(true);
                _leftPanelDraftPick.SetActive(false);
            }
        }
    }
Пример #2
0
    private UnitCombatSystem GetNextActiveUnit(UnitCombatSystem.Team team)
    {
        if (team == UnitCombatSystem.Team.Left)
        {
            _lefTeamActiveUnitIndex = (_lefTeamActiveUnitIndex + 1) % leftTeam.Count;
            _unitStatsControllerUI.HidePanelPlayerPanel(UnitCombatSystem.Team.Left, GameModeEnum.Game);
            _unitStatsControllerUI.ViewActiveUnitInGame(leftTeam[_lefTeamActiveUnitIndex].GetUnitStats(),
                                                        UnitCombatSystem.Team.Left);

            if (leftTeam.Count(x => x != null) == 0)
            {
                WinController.Win(false);
            }

            if (leftTeam[_lefTeamActiveUnitIndex] == null || leftTeam[_lefTeamActiveUnitIndex].IsDead())
            {
                return(GetNextActiveUnit(team));
            }

            if (leftTeam[_lefTeamActiveUnitIndex] == null)
            {
                return(GetNextActiveUnit(team));
            }
            return(leftTeam[_lefTeamActiveUnitIndex]);
        }

        if (rightTeam.Count(x => x != null) == 0)
        {
            WinController.Win(true);
        }

        _rightTeamActiveUnitIndex = (_rightTeamActiveUnitIndex + 1) % rightTeam.Count;
        _unitStatsControllerUI.HidePanelPlayerPanel(UnitCombatSystem.Team.Right, GameModeEnum.Game);
        _unitStatsControllerUI.ViewActiveUnitInGame(rightTeam[_rightTeamActiveUnitIndex].GetUnitStats(),
                                                    UnitCombatSystem.Team.Right);

        if (rightTeam[_rightTeamActiveUnitIndex] == null || rightTeam[_rightTeamActiveUnitIndex].IsDead())
        {
            return(GetNextActiveUnit(team));
        }
        return(rightTeam[_rightTeamActiveUnitIndex]);
    }
Пример #3
0
 public void ViewActiveUnitInGame(
     UnitStatsSO unitStats,
     UnitCombatSystem.Team team
     )
 {
     if (team == UnitCombatSystem.Team.Left)
     {
         unitNameLeftGame.text      = unitStats.unitName;
         hpLeftGameGame.text        = $"{unitStats.maxHealth}";
         attackLeftGame.text        = $"{unitStats.damage}";
         attackRangeLeftGame.text   = $"{unitStats.attackRange}";
         movementRangeLeftGame.text = $"{unitStats.movementRange}";
     }
     else
     {
         unitNameRightGame.text      = unitStats.unitName;
         hpRightGame.text            = $"{unitStats.maxHealth}";
         attackRightGame.text        = $"{unitStats.damage}";
         attackRangeRightGame.text   = $"{unitStats.attackRange}";
         movementRangeRightGame.text = $"{unitStats.movementRange}";
     }
 }
Пример #4
0
 public void ViewClickedUnitStatsDraftPick(
     UnitStatsSO unitStats,
     UnitCombatSystem.Team team
     )
 {
     if (team == UnitCombatSystem.Team.Left)
     {
         unitNameLeftDraft.text      = unitStats.unitName;
         hpLeftDraft.text            = $"{unitStats.maxHealth}";
         attackLeftDraft.text        = $"{unitStats.damage}";
         attackRangeLeftDraft.text   = $"{unitStats.attackRange}";
         movementRangeLeftDraft.text = $"{unitStats.movementRange}";
     }
     else
     {
         unitNameRightDraft.text      = unitStats.unitName;
         hpRightDraft.text            = $"{unitStats.maxHealth}";
         attackRightDraft.text        = $"{unitStats.damage}";
         attackRangeRightDraft.text   = $"{unitStats.attackRange}";
         movementRangeRightDraft.text = $"{unitStats.movementRange}";
     }
 }
Пример #5
0
    private void Start()
    {
        _grid                     = GameController_GridCombatSystem.Instance.GetGrid();
        _pickedUnit               = null;
        _numberOfUnitsInTeam      = 5;
        _draftPickPoint           = 0;
        _unitScale                = new Vector3(5, 5, 1);
        _teamsState.areTeamsReady = false;

        _rightTeamRespawn.SetActive(false);

        _teamsState.leftTeam.Clear();
        _teamsState.rightTeam.Clear();
        _teamsState.allUnitsInBothTeams.Clear();

        _unitStatsControllerUI.HideGamePanels();
        _teamPicking = UnitCombatSystem.Team.Left;
        _unitStatsControllerUI.HidePanelPlayerPanel(_teamPicking, GameModeEnum.DraftPick);
        Debug.LogWarning($"START INIT: TEAM PICKING : {_teamPicking}");
        if (_debug)
        {
            _numberOfUnitsInTeam = 1;
        }
    }
Пример #6
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit))
            {
                Debug.Log($"RAYCAST HIT: {hit.transform.name}");
            }
        }

        if (!Input.GetMouseButtonDown(0) || _pickedUnit == null)
        {
            return;
        }
        var gridObject = _grid.GetGridObject(CursorUtils.GetMouseWorldPosition());

        if (_pickedUnit == null || gridObject == null || gridObject.GetRespawn() == null)
        {
            return;
        }

        // TODO nice to have removed duplicates
        if (_teamPicking == UnitCombatSystem.Team.Left)
        {
            if (gridObject.GetRespawn().CompareTag("RightRespawn"))
            {
                return;
            }
            var pickedUnit = Instantiate(_pickedUnit, CursorUtils.GetMouseWorldPosition(), Quaternion.identity);
            pickedUnit.transform.localScale = _unitScale;
            pickedUnit.transform.position   = GridUtils.SetUnitOnTileCenter(pickedUnit.gameObject);
            _unitStatsControllerUI.HidePanelPlayerPanel(_teamPicking, GameModeEnum.DraftPick);

            _teamsState.leftTeam.Add(pickedUnit);
            _teamsState.allUnitsInBothTeams.Add(pickedUnit);

            _pickButtonSelected.SetActive(false);
            _pickedUnit = null;
            _draftPickPoint++;

            if (
                _draftPickPoint == 1 ||
                _draftPickPoint == 5 ||
                _draftPickPoint == 9
                )
            {
                HideRespawn();
                _teamPicking = UnitCombatSystem.Team.Right;
                _unitStatsControllerUI.HidePanelPlayerPanel(_teamPicking, GameModeEnum.DraftPick);
                Debug.Log($"DRAFT PICK POINT: {_draftPickPoint} NEXT PICK: {_teamPicking}");
                return;
            }
        }

        if (_teamPicking == UnitCombatSystem.Team.Right)
        {
            if (gridObject.GetRespawn().CompareTag("LeftRespawn"))
            {
                return;
            }
            var pickedUnit = Instantiate(_pickedUnit, CursorUtils.GetMouseWorldPosition(), Quaternion.identity);
            pickedUnit.transform.localScale = _unitScale;
            pickedUnit.transform.position   = GridUtils.SetUnitOnTileCenter(pickedUnit.gameObject);

            _teamsState.rightTeam.Add(pickedUnit);
            _teamsState.allUnitsInBothTeams.Add(pickedUnit);

            _pickedUnit = null;
            _pickButtonSelected.SetActive(false);

            if (_teamsState.rightTeam.Count == _numberOfUnitsInTeam)
            {
                Debug.Log($"{_teamsState.rightTeam} is FULL");

                _leftTeamRespawn.SetActive(false);
                _rightTeamRespawn.SetActive(false);
                _gridCombatSystem._teamsState = _teamsState;
                _gridCombatSystem.SetupGame();
                return;
            }

            _draftPickPoint++;
            if (_draftPickPoint == 3 || _draftPickPoint == 7)
            {
                HideRespawn();
                _teamPicking = UnitCombatSystem.Team.Left;
                _unitStatsControllerUI.HidePanelPlayerPanel(_teamPicking, GameModeEnum.DraftPick);
                Debug.Log($"DRAFT PICK POINT: {_draftPickPoint} NEXT PICK: {_teamPicking}");
            }
        }
    }