protected virtual void Init() { var gameplayManagersGO = new GameObject("GameplayManagers"); _minionManager = gameplayManagersGO.AddComponent <MinionManager>(); _towerManager = gameplayManagersGO.AddComponent <TowerManager>(); //_lvlSkillManager = gameplayManagersGO.AddComponent<LevelSkillManager>(); _minionSkillManager = gameplayManagersGO.AddComponent <MinionsSkillManager>(); _goSelector = FindObjectOfType <GameObjectSelector>(); _floorEffect = FindObjectOfType <FloorEffect>(); //_lvlSkillManager.level = this; _towerManager.level = _minionManager.level = this; SetGameManagerData(); InitLevelCanvas(); ConfigureLevelEvents(); _gameManager.LevelInitFinished(this); _minionSkillManager.Init(this); ExecuteTutorialStep(null); }
public void BuildMinionSlots(List <Minion> availableMinions, int lvlId, MinionsSkillManager minionSkillsManager, bool stayNotInteractuable = false) { var slots = 0; foreach (var m in availableMinions) //need to get json data to show correct point value on spawn button { if (m == null) { Debug.LogError("minion item in AvailableMinions List is null "); continue; } slots++; var minionStats = level.GameManager.MinionsJsonLoader.GetStatByLevel(m.minionType, lvlId); m.pointsValue = minionStats.pointsValue; var btn = Instantiate <Button>(minionSaleButtonPrefab, _availablesPanel.transform); btn.GetComponentInChildren <Text>().text = m.minionType + " x" + m.pointsValue; minionSaleButtons.Add(btn.GetComponent <MinionSaleButton> ()); minionSaleButtons[minionSaleButtons.Count - 1].minionType = m.minionType; minionSaleButtons[minionSaleButtons.Count - 1].minionSkill = m.skillType; var t = m.minionType; var newBtn = btn; var cooldown = m.spawnCooldown; var fillImg = btn.GetComponentsInChildren <Image>(); //Returns btn.image and its child.image(DONT KNOW WHY) btn.onClick.AddListener(() => OnBuyMinion(newBtn, fillImg[1], t, cooldown, stayNotInteractuable)); SetMinionSkillButton(btn, m.skillType, !stayNotInteractuable, minionSkillsManager); } if (slots < minionSlots) { var lefts = minionSlots - slots; BuildEmptySlots(lefts, _availablesPanel.transform); } }
public void SetMinionSkillButton(Button baseBtn, BaseMinionSkill.SkillType skill, bool interactable, MinionsSkillManager minionSkillsManager) { var skillBtn = baseBtn.GetComponentInChildren <MinionSkillMouseDown> (); if (interactable) { skillBtn.InitButton(skill, minionSkillsManager.SkillButtonPressed, baseBtn.name, level.GameManager); //skillBtn.GetComponentInChildren<Text>().text = skill.ToString(); } else { skillBtn.SetDisabled(); } /*var fillImg = skillBtn.GetComponentsInChildren<Image>()[1];//Returns btn.image and its child.image(DONT KNOW WHY) * fillImg.fillAmount = interactable ? 0 : 1;*/ skillBtn.GetComponent <Button> ().interactable = interactable; skillBtn.SetOnPointerDown(interactable); }