コード例 #1
0
    private void UpdateSelect()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            if (facilityPalletePanel.isSelecting)
            {
                if (hit.collider.GetComponent <HexCell>() != null &&
                    hexMap.GetTeleporterBuildableCells(gameManager.hexMap.selectedCell,
                                                       Teleporter.GetMaxDistance(facilityPalletePanel.currentLevel)).Contains(hit.collider.GetComponent <HexCell>()))
                {
                    facilityPalletePanel.currentDestination = hit.collider.GetComponent <HexCell>();
                }
                facilityPalletePanel.facilityBuildPanel.SetIsSelecting(false);
                facilityPalletePanel.facilityBuildPanel.UpdateBuildPanel();
                return;
            }
            DisableAllPanels();
            DisableIndicators();
            if ((hit.collider.GetComponent <HexCell>()) != null)
            {
                hexMap.SelectHex(hit.point);
                HexCell hitCell = hexMap.GetCellFromPosition(hit.point);
                if (hitCell.buildable)
                {
                    EnableHexCellActionPanel();
                    ShowBuildableHex();
                    hexCellActionPanel.UpdateHexCellPanel(hitCell);
                    hitCell.indicator.SetColor(Indicator.StartColor);
                }
                else
                {
                    EnableHexStatusPanel();
                    hexCellStatusPanel.UpdateHexStatusPanel(hitCell);
                    hitCell.indicator.SetColor(Indicator.StartColor);
                    if (hitCell.building != null)
                    {
                        EnableBuildingActionPanel();
                        buildingActionPanel.UpdateBuildingActionPanel(hitCell);
                        if ((hitCell.building as Teleporter) != null)
                        {
                            ((Teleporter)hitCell.building).another.currentCell.indicator.gameObject.SetActive(true);
                            ((Teleporter)hitCell.building).another.currentCell.indicator.SetColor(Indicator.StartColor);
                        }
                    }
                }
            }
            else if ((selectedPawn = hit.collider.GetComponent <Pawn>()) != null)
            {
                gameManager.buildingManager.UpdateBuildMode(false);
                if (selectedPawn.pawnType == PawnType.Enemy)
                {
                    pawnStatusPanel.UpdatePawnStatusPanel(selectedPawn);
                    EnablePawnStatusPanel();
                }
                else if (selectedPawn.pawnType == PawnType.Monster)
                {
                    pawnActionPanel.SetPawn(selectedPawn);
                    pawnStatusPanel.UpdatePawnStatusPanel(selectedPawn);
                    EnableAllPawnPanels();
                    hexMap.UnselectHex();
                }
            }
        }
        else
        {
            gameManager.buildingManager.UpdateBuildMode(false);
            Clear();
            playerStatusPanel.gameObject.SetActive(true);
        }
    }