示例#1
0
    // Use this for initialization
    void OnEnable()
    {
        wallCellModel = GameObject.FindGameObjectsWithTag("Cell");
        wallCellGroup = new WallGroup[wallCellModel.Length];
        coordinates   = new int[wallCellModel.Length, 2];
        for (int i = 0; i < wallCellModel.Length; i++)
        {
            string[] nums = wallCellModel[i].name.Split(' ');
            coordinates[i, 0] = int.Parse(nums[0]);
            coordinates[i, 1] = int.Parse(nums[1]);
            wallCellGroup[i]  = new WallGroup(coordinates[i, 0], coordinates[i, 1]);
        }

        ExploreCell(0, 0);


        GridPlacer placer = new GridPlacer(coordinates);
        Pathfinder finder = new Pathfinder(wallCellGroup);

        for (int i = 0; i < 5; i++)
        {
            placer.PlaceDistanceAway(finder, new int[] { 0, 0 }, relic, 3);
        }

        placer.PlaceDistanceAway(finder, new int[] { 0, 0 }, pumpkin, 5);


        GameObject.FindGameObjectWithTag("MainCamera").GetComponent <ScoreTracker>().enabled = true;
        GameObject.Find("HUDCanvas").GetComponent <Animator>().SetTrigger("DisplayScore");
    }
    public void Dissapear()
    {
        if (killer)
        {
            return;
        }
        gameObject.name = "pumpkin";
        GridPlacer placer = new GridPlacer(GenerateWalls.coordinates);

        placer.PlaceDistanceAway(finder, ConvertVector3(player), transform, 5);
        GameObject.Instantiate(smoke, transform.position, transform.rotation);
        GameObject.Destroy(gameObject);
    }