コード例 #1
0
ファイル: Level.cs プロジェクト: Fenrircheg/gameford
    public void Play()
    {
        var g = new e.BallGenerator(balls, 2, -1);

        game.AddObject(g);

        for (var i = 0; i < 350; i++)
        {
            game.Step();
        }

        foreach (var obj in game.GetCurrentWorld())
        {
            if (obj is e.ColorSwitch)
            {
                var clone = Instantiate(this.ColorSwitchPrefab);
                clone.GetComponent <ColorSwitch>().ColorSwitcher = obj as e.ColorSwitch;
                clone.GetComponent <ColorSwitch>().active        = true;
            }
        }

        for (var i = 0; i < ballHistory.GetList().Count; i++)
        {
            var ball  = ballHistory.GetList()[i];
            var clone = Instantiate(this.BallPrefab, GeneratorPrefab.transform.position, GeneratorPrefab.transform.rotation);
            clone.GetComponent <Ball>().eBall = ball;
            e.Color originColor = ball.GetActions()[0].Color;
            clone.GetComponent <SpriteRenderer>().sprite = clone.GetComponent <Ball>().GetSpriteByColor(originColor);
        }

        var grid   = GameObject.Find("Grid").GetComponent <GridInit>();
        int height = grid.height;
        int width  = grid.width;

        for (int i = 0; i < height; i++)
        {
            for (int j = 0; j < width; j++)
            {
                grid.cellsArray[i, j].GetComponent <SpriteRenderer>().enabled = false;
            }
        }
    }