void Start()
        {
            _battleController = GameObject.FindWithTag("Player").GetComponent <PlayerBattleBehavior>().BattleController;
            var weapons = _battleController.BattleStats.Weapons;

            transform.Find("ButtonShoot").GetComponent <Button>().onClick.AddListener(() => _battleController.TryShoot());

            //TODO Обобщить и не писать как здесь всё в одну строку
            transform.Find("WeaponsPanel/BlasterButton").GetComponent <Button>().onClick.AddListener(() => _battleController.BattleStats.CurrentWeaponId = 1);
            transform.Find("WeaponsPanel/BulletButton").GetComponent <Button>().onClick.AddListener(() => _battleController.BattleStats.CurrentWeaponId  = 0);
        }
        void Start()
        {
            _buttonPrefab     = Resources.Load(ButtonPrefabPath) as GameObject;
            _battleController = GameObject.FindWithTag("Player").GetComponent <PlayerBattleBehavior>().BattleController;
            var weapons = _battleController.BattleStats.Weapons;

            for (int i = 0; i < weapons.Length; i++)
            {
                var button = Instantiate(_buttonPrefab);
                button.GetComponentInChildren <Text>().text = i.ToString();
                button.transform.SetParent(transform);
                var tmp = i;
                button.GetComponent <Button>()
                .onClick.AddListener(() => _battleController.BattleStats.CurrentWeaponId = (uint)tmp);
            }
        }
Beispiel #3
0
        void Awake()
        {
            var solidity = new Solidity(100, 0);
            var weapons  = new WeaponInfo[WeaponIDs.Length];

            _blockedWeapons = new Dictionary <string, bool>();
            for (var i = 0; i < WeaponIDs.Length; i++)
            {
                weapons[i] = WeaponLoader.LoadWeapon(WeaponIDs[i]);
                _blockedWeapons.Add(weapons[i].Id, false);
            }

            _shellFactory = new ShellFactory();
            var battleStats = new PlayerBattleStats(solidity, 100, 1, weapons);

            BattleController = new PlayerBattleController(battleStats, this, this);

            StartCoroutine(Regenerate());
            StartCoroutine(Oscillate());
        }