public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        VisibleGrid script = (VisibleGrid)target;

        if (GUILayout.Button("Build Grid"))
        {
            script.CreateGrid();
        }

        if (GUILayout.Button("Destroy Grid"))
        {
            script.DestroyGridInEditor();
        }
    }
예제 #2
0
    public override void DTRMUpdate()
    {
        List <Visible> myNewCell = VisibleGrid.GetCell(myPosition.position);

        if (myCell == myNewCell)
        {
            return;
        }

        if (myCell != null)
        {
            myCell.Remove(this);
        }

        myNewCell.Add(this);
        myCell = myNewCell;
    }
예제 #3
0
 public override void DTRMStart()
 {
     visible = visibleOnStart;
     myCell  = VisibleGrid.GetCell(myPosition.position);
     myCell.Add(this);
 }
예제 #4
0
    public override void DTRMUpdate()
    {
        List <Visible> neighbors = VisibleGrid.GetNeighbors(myPosition.position);

        // checking visibles in sight
        for (int i = 0; i < VISION_LIMIT; i++)
        {
            Visible visible = visiblesInSight[i];

            if (visible == null)
            {
                continue;
            }

            if (myPosition.SqrDistance(visible.myPosition) > sqrVisionDistance)
            {
                visiblesInSight[i] = null;
                visible.inRangeOfVisions.Remove(this);
                if (visible.visible)
                {
                    SendLostMessage(visible);
                }
            }

            if (neighbors.Contains(visible))
            {
                neighbors.Remove(visible);
            }
        }

        // checking invisibles in sight
        for (int i = 0; i < VISION_LIMIT; i++)
        {
            Visible visible = invisiblesInSight[i];

            if (visible == null)
            {
                continue;
            }

            if (myPosition.SqrDistance(visible.myPosition) > sqrVisionDistance)
            {
                visible.inRangeOfVisions.Remove(this);
                invisiblesInSight[i] = null;
            }

            if (neighbors.Contains(visible))
            {
                neighbors.Remove(visible);
            }
        }

        // checking the rest of the neighbours
        foreach (Visible visible in neighbors)
        {
            if (myPosition.SqrDistance(visible.myPosition) > sqrVisionDistance)
            {
                continue;
            }

            visible.inRangeOfVisions.Add(this);

            if (visible.visible)
            {
                AddVisible(visible);
                SendNoticedMessage(visible);
            }
            else
            {
                AddInvisible(visible);
            }
        }
    }