Beispiel #1
0
    // Use this for initialization
    void Awake()
    {
        doingSetup = true;
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        LevelLoadCalled = false;
        enemies         = new List <EnemyController> ();
        enemiesNext     = new List <EnemyController> ();
        boardScript     = GetComponent <BoardCycleManager> ();


        GameObject battery = GameObject.Find("Battery");

        batteryLevel = battery.GetComponent <Image> ();
        anim         = battery.GetComponent <Animator> ();


        dialogObject = GameObject.Find("NewDialog");
        InitGame();
    }
    private void Restart()
    {
        BoardCycleManager m = GameplayManager.instance.boardScript;

        if (m.stackOfTemplates.Count > 0)
        {
            GameplayManager.instance.Level += 1;
            m.SwitchLevel(GameplayManager.instance.Level, this.transform.position);
            float x       = this.transform.position.x + 1;       //9,5
            float y       = this.transform.position.y + 1;       //3
            int   rows    = GameplayManager.instance.boardScript.rows;
            int   columns = GameplayManager.instance.boardScript.columns;
            if (x < (int)(columns / 2) + 1.5 && x > (int)(columns / 2) - 1.5 && y > rows)
            {
                this.transform.position = new Vector3((int)(columns / 2), 0, 0);
            }
            else if (x < (int)(columns / 2) + 1.5 && x > (int)(columns / 2) - 1.5 && y < 1)
            {
                this.transform.position = new Vector3((int)(columns / 2), rows - 1, 0);
            }
            else if (y < (int)(rows / 2) + 1.5 && y > (int)(rows / 2) - 1.5 && x > columns)
            {
                this.transform.position = new Vector3(0, (int)(rows / 2), 0);
            }
            else if (y < (int)(rows / 2) + 1.5 && y > (int)(rows / 2) - 1.5 && x < 1)
            {
                this.transform.position = new Vector3(columns - 1, (int)(rows / 2), 0);
            }

            enabled = true;
            gridManager.CreateGrid();
        }
        else
        {
            batteryImage.SetActive(false);
            DemoOver();
        }
    }