Exemple #1
0
        public Task <GetAllUnitResponse> getAllUnit()
        {
            GetAllUnitResponse response = new GetAllUnitResponse();

            try
            {
                response.Data    = _service.All();
                response.Message = "";
                response.Success = true;
                if (response.Data != null)
                {
                    response.Total = response.Data.Count();
                }
            }
            catch (Exception e)
            {
                response.Message = e.ToString();
                response.Success = false;
            }
            return(Task.FromResult(response));
        }
Exemple #2
0
        private void CategorySelected(UnitCategory cat)
        {
            var allUnitCards = _unitCardsPanel.GetComponentsInChildren <Button>();

            foreach (var c in allUnitCards)
            {
                Destroy(c.gameObject);
            }

            // TODO Get units from Deck not just all units.
            var allUnitsOfCat = _unitService.All().Where(u => u.Category.Name == cat.Name).ToList();

            foreach (var unit in allUnitsOfCat)
            {
                var card = Instantiate(UnitCardDeploymentPrefab, _unitCardsPanel.transform);
                card.GetComponentInChildren <Text>().text = unit.Name;

                // this is very hacky and WIP just to keep the current spawning system working
                var session = GameObject.Find("GameSession");

                // See above, we need to either make this fully dynamic or put the cat names in the type system:
                switch (cat.Name)
                {
                case "TNK":
                    card.GetComponentInChildren <Button>().onClick.AddListener(session.GetComponent <InputManager>().TankButtonCallback);
                    break;

                case "SUP":
                    card.GetComponentInChildren <Button>().onClick.AddListener(session.GetComponent <InputManager>().ArtyButtonCallback);
                    break;

                default:
                    break;
                }

                // TODO Set picture too
                // TODO Transports?
            }
        }