Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        LevelSetter myScript = (LevelSetter)target;

        GUILayout.Label(myScript.coord.ToString());
        if (GUILayout.Button("Move Up"))
        {
            myScript.MoveUp();
        }
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Move Left"))
        {
            myScript.MoveLeft();
        }
        if (GUILayout.Button("Move Right"))
        {
            myScript.MoveRight();
        }
        GUILayout.EndHorizontal();
        if (GUILayout.Button("Move Down"))
        {
            myScript.MoveDown();
        }
    }
Exemplo n.º 2
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 3
0
    private void SetDependencies()
    {
        var viewController         = Instantiate(_viewControllerPrefab).GetComponent <ViewController>();
        var levelViewController    = Instantiate(_levelViewControllerPrefab).GetComponent <LevelViewController>();
        var healthViewController   = Instantiate(_healthViewControllerPrefab).GetComponent <HealthViewController>();
        var goldViewController     = Instantiate(_goldViewControllerPrefab).GetComponent <GoldViewController>();
        var gameOverViewController = Instantiate(_gameOverViewControllerPrefab).GetComponent <GameOverViewController>();
        var enemyViewController    = new GameObject("EnemyVewController", typeof(EnemyViewController)).GetComponent <EnemyViewController>();
        var towerViewController    = new GameObject("TowerVewController", typeof(TowerViewController)).GetComponent <TowerViewController>();

        levelViewController.Init(viewController.CanvasBackground);
        healthViewController.Init(viewController.CanvasUI);
        goldViewController.Init(viewController.CanvasUI);
        gameOverViewController.Init(viewController.CanvasUI);

        var assetLoader      = new AddressableAssetLoader <LevelData>();
        var levelSetter      = new LevelSetter(assetLoader);
        var objectPooler     = Instantiate(_objectPoolerPrefab).GetComponent <ObjectPooler>();
        var healthController = new HealthController(objectPooler);
        var goldController   = new GoldController(objectPooler);
        var enemyController  = new EnemyController(objectPooler, enemyViewController);
        var towerController  = new TowerController(objectPooler, goldController);

        objectPooler.Init();

        _gameplayController = new GameplayController(levelSetter, enemyController, healthController, goldController, towerController, objectPooler);

        levelViewController.SetCallbacks(levelSetter);
        enemyViewController.SetCallbacks(levelSetter, enemyController, _gameplayController);
        healthViewController.SetCallbacks(healthController);
        goldViewController.SetCallbacks(goldController);
        gameOverViewController.SetCallbacks(_gameplayController);
        towerViewController.SetCallbacks(towerController);

        #if UNITY_ANDROID
        _inputController = new TouchInputController();
        #else
        _inputController = new MouseInputController();
        #endif
    }