Exemplo n.º 1
0
    private void SelectUnit(Unit unit, City city)
    {
        selectedUnit = unit;
        moveZone.Clear();
        fireZone.Clear();

        fireTargetCoord = Empty;
        moveTargetCoord = Empty;
        turnTargetCoord = Empty;

        moveMarkersView.Hide();
        fireMarkersView.Hide();
        moveZoneMarkersView.Hide();
        selectedMarkersView.Hide();

        moveSelector.Hide();
        fireSelector.Hide();
        if (unit == null)
        {
            gameUI.ShowUnit(null);
            if (city != null && city.Faction == currentFaction)
            {
                CityUI.ShowCityUI(city, game);
            }
            return;
        }
        if (unit.Faction != currentFaction)
        {
            selectedUnit = null;
            gameUI.ShowUnit(null);
            return;
        }
        gameUI.ShowUnit(unit);
        selectedCoord = unit.Coordinate;
        selectedMarkersView.Show(mapView.CellCoordToPosition(selectedCoord));
        if (selectedUnit.ActionPoints > 0)
        {
            moveZone = game.Map.GetMoveZone(unit);
            var moveCoords = moveZone.GetCoordList();
            fireZone = game.Map.GetFireZoneForMoveZone(unit, moveZone);
            var fireCoords = fireZone.GetCoordList();
            moveZoneMarkersView.Show(CoordToPositions(moveCoords));
            fireMarkersView.Show(CoordToPositions(fireCoords));
        }
        if (unitTargetPoints.ContainsKey(selectedUnit))
        {
            ShowCurrentPath(selectedUnit, unitTargetPoints[selectedUnit]);
        }
    }
Exemplo n.º 2
0
    private CityView CreateCityView(Transform parent, MapView mapView, City city, string prefabName)
    {
        var unitPrefab = Resources.Load <CityView>(prefabName);

        if (unitPrefab == null)
        {
            Debug.LogError("Can't load unit " + prefabName);
            return(null);
        }
        CityView cityView = Instantiate(unitPrefab);

        cityView.gameObject.SetActive(true);
        cityView.transform.parent = parent;
        cityView.Init(city, mapView.CellCoordToPosition(city.Coordinate));
        return(cityView);
    }
Exemplo n.º 3
0
    public static UnitView CreateUnitView(Transform parent, MapView mapView, Unit unit, string prefabName)
    {
        var unitPrefab = Resources.Load <UnitView>("Units/" + prefabName);

        if (unitPrefab == null)
        {
            Debug.LogError("Can't load unit " + prefabName);
            return(null);
        }
        UnitView unitView = Instantiate(unitPrefab);

        unitView.gameObject.SetActive(true);
        unitView.transform.parent = parent;
        unitView.Init(unit, mapView.CellCoordToPosition(unit.Coordinate));
        return(unitView);
    }
Exemplo n.º 4
0
    private void SetCameraTo(City city)
    {
        var startPosition = mapView.CellCoordToPosition(city.Coordinate);

        CameraController.SetPosition(startPosition);
    }