Beispiel #1
0
 private void switchFlagOnOff(object sender, GameController.SelectedAObjectArgs e)
 {
     if (e.SelectedGameObject == this.gameObject && _isSpawnTargetActive)
     {
         flagInstance.SetActive(true);
     }
     else
     {
         flagInstance.SetActive(false);
     }
 }
        private void RefreshBuildingInfo(object sender, GameController.SelectedAObjectArgs e)// sets info panels sprite and buttons for selected unit
        {
            if (e.SelectedGameObject == null)
            {
                //  _selectedGo = null;

                if (_activeButtonList.Count > 0)
                {
                    foreach (var button in _activeButtonList)
                    {
                        Destroy(button?.gameObject);
                    }
                    _activeButtonList.Clear();
                }
            }
            else if (e.SelectedGameObject.GetComponent <PlayableObject>())
            {
                // _selectedGo = e.SelectedGameObject;

                if (_activeButtonList.Count > 0)
                {
                    foreach (var button in _activeButtonList)
                    {
                        Destroy(button?.gameObject);
                    }
                    _activeButtonList.Clear();
                }

                Unit selectedUnit = e.SelectedGameObject.GetComponent <Unit>();
                selectedUnitImage.sprite = selectedUnit.sprite;
                selectedUnitName.text    = selectedUnit.name;
                if (selectedUnit.GetComponent <Building>() && selectedUnit.GetComponent <Building>().products.Count > 0)
                {
                    foreach (var t in selectedUnit.GetComponent <Building>().products)
                    {
                        ProductionButton productButton = Instantiate(t, productionList.transform, true);
                        _activeButtonList.Add(productButton);
                        productButton.spawnBuilding = e.SelectedGameObject;
                    }
                }
            }
            else
            {
                if (_activeButtonList.Count > 0)
                {
                    foreach (var button in _activeButtonList)
                    {
                        Destroy(button?.gameObject);
                    }
                    _activeButtonList.Clear();
                }
            }
        }
 private void SwitchPanel(object sender, GameController.SelectedAObjectArgs e)//switches between panels when a cell clicked
 {
     if (e.SelectedGameObject == null)
     {
         gameInfoPanel.gameObject.SetActive(true);
         productionInfoPanel.gameObject.SetActive(false);
     }
     else
     {
         gameInfoPanel.gameObject.SetActive(false);
         productionInfoPanel.gameObject.SetActive(true);
     }
 }