Пример #1
0
    public string BaseText = "Influence Map Mode: ";            // Base string for this text component

    public void ModeChange(InfluenceMode mode)
    {
        if (!textRenderer)
        {
            textRenderer = GetComponent <Text>();
        }
        textRenderer.text = BaseText + InfluenceModeStrings[(int)mode];
    }
    // Update is called once per frame
    void Update()
    {
        CurrentTime += Time.deltaTime;
        if (CurrentTime >= StepTime)
        {
            switch (Mode)
            {
            case InfluenceMode.Propagation:
            {
                CellList.PropagateCells();
                break;
            }

            case InfluenceMode.NormalizedPropagation:
            {
                CellList.PropagateCells();
                CellList.NormalizePropogateCells();
                break;
            }

            case InfluenceMode.FieldOfView:
            {
                CellList.FadeInfluenceOnCells(StepTime);
                break;
            }
            }

            CurrentTime = 0.0f;
        }


        if (Input.GetKeyUp(KeyCode.LeftBracket))
        {
            CellList.ResetInfluences();
            Mode = --Mode >= 0 ? Mode : InfluenceMode.NumValues - 1;
            InfluenceMapModeText.GetComponent <ModeUI>().ModeChange(Mode);

            if (Mode == InfluenceMode.OpennessClosestWall)
            {
                CellList.ApplyWallInfluences();
            }
            else if (Mode == InfluenceMode.VisibleToSpot)
            {
                CellList.ApplyVisibilityInfluences();
            }
        }
        if (Input.GetKeyUp(KeyCode.RightBracket))
        {
            CellList.ResetInfluences();
            Mode = ++Mode < InfluenceMode.NumValues ? Mode : 0;
            InfluenceMapModeText.GetComponent <ModeUI>().ModeChange(Mode);

            if (Mode == InfluenceMode.OpennessClosestWall)
            {
                CellList.ApplyWallInfluences();
            }
            else if (Mode == InfluenceMode.VisibleToSpot)
            {
                CellList.ApplyVisibilityInfluences();
            }
        }
        if (Input.GetKeyUp(KeyCode.N))
        {
            ShouldRenderNeighborLines = !ShouldRenderNeighborLines;
            ToggleVoronoiNeighborLines();
        }
    }