Beispiel #1
0
    // Sets the node as blocked if highlighted and the space bar is pressed on
    // sets start with left click and end with right click
    void OnMouseOver()
    {
        if (myManager.autoGenerateGrid)
        {
            if (Input.GetKeyUp(KeyCode.Space))
            {
                myManager.SetBlocker(this);
            }
            else if (NodeStatus != NODE_STATUS.BLOCKED)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    myManager.SetStart(this);
                }
                else if (Input.GetMouseButtonDown(1))
                {
                    myManager.SetEnd(this);
                    diffusion           = goalDiffusion;
                    staticDiffusionBase = goalDiffusion;
                }
            }
        }
        // Sets the node as blocked if highlighted and the space bar is pressed on that frame
        else
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                myManager.SetBlocker(this);
                forceCloseParking = !forceCloseParking;
                openParking       = !forceCloseParking;
                GetComponent <NodeScript>().goal = !forceCloseParking;
                //GetComponent<NodeScript>().goalDiffusion = open ? 1000000 : 0;
                GetComponent <NodeScript>().NodeStatus = !forceCloseParking ? NodeScript.NODE_STATUS.END : NodeScript.NODE_STATUS.UNSEARCHED;
            }
        }

        highlighted = true;
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (grid && grid.autoGenerateGrid && grid.gridCreated && createdTestScenario == false)
        {
            createdTestScenario = true;
            //create scenario
            string       block;
            StreamReader reader = new StreamReader(blocksToBlockFile);
            while ((block = reader.ReadLine()) != null)
            {
                if (block.Contains("end="))
                {
                    block = block.Replace("end=", "");
                    int endarray = int.Parse(block);
                    grid.diffusionMode = true;
                    NodeScript nd = grid.SetEnd(endarray);
                    nd.diffusion = nd.goalDiffusion;
                }
                else if (block.Contains("start="))
                {
                    block = block.Replace("start=", "");
                    int startarr = int.Parse(block);
                    startBlock = grid.nodeGrid[startarr].GetComponent <NodeScript>();
                }
                else
                {
                    int blockArrNum = int.Parse(block);
                    grid.SetBlocker(blockArrNum);
                }
            }
            reader.Close();
        }

        //spawn avatars
        if (grid && grid.autoGenerateGrid && grid.gridCreated && spawnedAvatars == false && createdTestScenario == true)
        {
            spawnedAvatars = true;
            StartCoroutine(MySpawnCoroutine());
        }
    }