Пример #1
0
    protected override void instantiate <T>()
    {
        base.instantiate <KarapanGameControl>();
        base.name        = Name;
        userInputControl = gameObject.GetComponent <UserInputControl>();
        playerControl    = GameObject.Find("Player").GetComponent <KarapanPlayerControl>();

        lifeControl     = gameObject.GetComponent <KarapanLifeControl>();
        speedControl    = gameObject.GetComponent <KarapanSpeedControl>();
        progressControl = gameObject.GetComponent <ProgressControl>();
        playerControl   = GameObject.Find("Player").GetComponent <KarapanPlayerControl>();
        addSubController("LifeControl", lifeControl);
        addSubController("SpeedControl", speedControl);
        addSubController("PlayerControl", playerControl);
        addSubController("ProgressControl", progressControl);
        addSubController("UserInputControl", userInputControl);

        UnityEngine.Debug.Log(userInputControl);
        userInputControl.addKeyMap(new KeyMap(new KeyCode[] { KeyCode.Space }, "TogglePause", delegate() { togglePause(); }, Input.GetKeyDown, 0.75F));
        userInputControl.addKeyMap(new KeyMap(new KeyCode[] { KeyCode.Slash }, "DEBUG", delegate() { toggleDebug(); }, Input.GetKeyDown, UserInputControl.SeldomtimePress));
        userInputControl.addKeyMap(new KeyMap(new KeyCode[] { KeyCode.Equals }, "reset", delegate() { gameOver(); resetGame(); }, Input.GetKeyDown, UserInputControl.SometimePress));
    }
    protected override void start()
    {
        base.start();
        for (int i = 0; i < PrefabEnem.Length; i++)
        {
            PrefabEnem[i] = GameObject.Find("Enemy" + (i + 1));
        }
        lastSpawn = Time.time;
        gameControl.addEvent("Reset", reset);
        gameControl.addEvent("StarSpawn", spawnStar);
        UserInputControl input = basicGameControl.SubController <UserInputControl>("UserInputControl");

        input.addKeyMap(new KeyMap(new KeyCode[] { KeyCode.M }, "SpawnStar", () => { spawnStar(); }, Input.GetKeyDown, UserInputControl.SeldomtimePress));
    }