private void OnTriggerEnter(Collider other)
 {
     if (other.GetComponent <Avatar>() != null)
     {
         LevelsController.GetInstance().currenLevel.AvatarReachesTheGoal();
     }
 }
    void InitCards()
    {
        LevelsController levels = LevelsController.GetInstance();

        if (levels == null)
        {
            return;
        }

        for (int i = 0; i < levels.levels.Count; i++)
        {
            int         id    = i;
            CustomLevel level = levels.levels[id];

            GameObject instance = Instantiate(selectorCardTemplate, parent);
            LevelCard  card     = instance.GetComponent <LevelCard>();
            card.SetCardData(level);

            CustomButton cb = instance.GetComponent <CustomButton>();

            cb.onPointerEnter.AddListener(() =>
            {
                levelCardHovered?.Invoke(level);
            });

            cb.onClick.AddListener(() =>
            {
                levels.SelectLevelById(id);
                pages.OpenPage(1);
            });

            selectorCards.Add(instance);
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        weaponComp = GetComponent <EnemyWeapon>();
        animator   = GetComponent <Animator>();

        if (LevelsController.GetInstance() != null && LevelsController.GetInstance().currenLevel != null)
        {
            LevelsController.GetInstance().currenLevel.EnemySpawned(this);
        }
    }
Exemple #4
0
    public void ChangeState(dynamic dynamic)
    {
        if (LevelsController.GetInstance()?.CurrentLevel != null && CarsController.GetInstance()?.CurrentCar != null)
        {
            ready = true;
        }
        else
        {
            ready = false;
        }

        onChangeState.Invoke(ready);
    }
    // Start is called before the first frame update
    void Start()
    {
        rigid          = GetComponent <Rigidbody>();
        rigid.velocity = CalculateInitialForce();

        if (LevelsController.GetInstance().currenLevel != null && LevelsController.GetInstance().currenLevel.enemies.Count == 0)
        {
            AllEnemiesDead();
        }
        else
        {
            EventDispatcher.AllEnemiesDead += AllEnemiesDead;
        }
    }
Exemple #6
0
    public void LoadLevel()
    {
        if (ready)
        {
            CustomLevel level = LevelsController.GetInstance()?.CurrentLevel;
            CarData     car   = CarsController.GetInstance()?.CurrentCar;

            LevelManager.GetInstance()?.Load(level, car);
        }
        else
        {
            throw new NullReferenceException("Level or Car data is not set!");
        }
    }
    public void Die()
    {
        animator.SetTrigger("Dead");
        Destroy(gameObject, 1f);

        GetComponent <AvatarWeaponTarget>().enabled = false;
        GetComponent <Collider>().enabled           = false;
        weaponComp.enabled = false;

        if (LevelsController.GetInstance() != null && LevelsController.GetInstance().currenLevel != null)
        {
            LevelsController.GetInstance().currenLevel.EnemyDead(this);
        }
    }
Exemple #8
0
    private void OnEnable()
    {
        if (levelsController == null)
        {
            levelsController = LevelsController.GetInstance();
            if (levelsController == null)
            {
                return;
            }
        }

        replay.onClick.AddListener(Replay);

        if (levelsController.IsLast)
        {
            next.interactable = false;
        }
        else
        {
            next.onClick.AddListener(LoadNextLevel);
        }

        mainMenu?.onClick.AddListener(BackToMainMenu);
    }
 public void AvatarReachesTheGoal()
 {
     LevelsController.GetInstance().LevelCompleted();
 }