Exemplo n.º 1
0
        public void CreateTarget(TargetData data)
        {
            Target target;

            if (_targetPool.Exists(inactiveTarget => inactiveTarget.Type == data.TargetType))
            {
                target = _targetPool.Find(inactiveTarget => inactiveTarget.Type == data.TargetType);
                _targetPool.Remove(target);
                target.transform.position = _randomSpawnPosition;
                target.gameObject.SetActive(true);
            }
            else
            {
                target = Instantiate(Resources.GameData.Instance.GetPrefab(data.TargetType),
                                     _randomSpawnPosition,
                                     _targetStartPosition.rotation,
                                     transform);
                target.onClick += OnTargetClicked;
                target.onHide  += OnTargetHide;
            }

            target.Color = Resources.GameData.Instance.GetColor(data.TargetColor);

            target.Reward = data.TargetReward;

            _activeTargets.Add(target);
        }
Exemplo n.º 2
0
 private void CreateTarget(TargetData data)
 {
     _targets.CreateTarget(data);
 }