private void Initial()
 {
     if (!userBehave || !userTransform)
     {
         userBehave    = FindObjectOfType <ControllableBehave>();
         userTransform = userBehave.gameObject.transform;
     }
 }
Exemple #2
0
    private void Start()
    {
        targetTransform    = GameObject.FindGameObjectWithTag("Player").transform;
        gameController     = FindObjectOfType <GameController>();
        controllableBehave = FindObjectOfType <ControllableBehave>();
        enemyAnimator      = GetComponent <Animator>();

        lastTargetPosition = transform.position;

        HandleAnimate();
    }
    public void GameStart(GameDifficulty difficulty)
    {
        SceneManager.LoadScene(2, LoadSceneMode.Single);

        score              = 0u;
        Cursor.lockState   = CursorLockMode.Locked;
        gameDifficulty     = difficulty;
        controllableBehave = FindObjectOfType <ControllableBehave>();
        PlayBGM(bgmList.gameBGM);

        gameStatus = GameStatus.GameRunning;
    }
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            ControllableBehave playerBehave = collision.gameObject.GetComponent <ControllableBehave>();
            var item = playerBehave.GetItem(itemID);
            item.GetComponent <ItemBasic>().level = level;

#if UNITY_EDITOR
            Debug.Log($"GetItem: Item_{itemID}");
#endif
            Instantiate(Resources.Load($"Prefabs/Particles/Explosion_{Random.Range(0, 10)}"), transform.position, Quaternion.identity);
            Destroy(gameObject);
        }
    }
    private void SpawnEnemy()
    {
        Vector3 enemyPostion = transform.position +
                               Quaternion.AngleAxis(UnityEngine.Random.Range(0f, 360f), Vector3.up) * Vector3.forward * UnityEngine.Random.Range(0f, enemySpawnLimit);

        if (!controllableBehave)
        {
            controllableBehave = FindObjectOfType <ControllableBehave>();
        }

        if (Vector3.Distance(enemyPostion, controllableBehave.gameObject.transform.position) > spawnDistanceLimit)
        {
            Instantiate(enemy, enemyPostion, enemy.transform.rotation * Quaternion.AngleAxis(UnityEngine.Random.Range(0f, 360f), Vector3.up));
        }
        else
        {
            SpawnEnemy();
        }
    }
    public void GamePause(bool ifPause, bool ifShowPuaseGUI)
    {
        if (!controllableBehave)
        {
            controllableBehave = FindObjectOfType <ControllableBehave>();
        }
        controllableBehave.gameObject.GetComponent <Rigidbody>().useGravity = !ifPause;

        if (ifPause)
        {
            audioSource.Pause();
            gameStatus       = GameStatus.GamePaused;
            Cursor.lockState = CursorLockMode.Confined;
        }
        else
        {
            audioSource.Play();
            gameStatus       = GameStatus.GameRunning;
            Cursor.lockState = CursorLockMode.Locked;
        }

        ShowPauseGUI(ifShowPuaseGUI);
    }
 private void Start()
 {
     itemBasic     = GetComponent <ItemBasic>();
     userBehave    = FindObjectOfType <ControllableBehave>();
     userTransform = userBehave.gameObject.transform;
 }
Exemple #8
0
 private void Start()
 {
     userBehave = FindObjectOfType <ControllableBehave>();
     itemBasic  = GetComponent <ItemBasic>();
 }