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

        lastTargetPosition = transform.position;

        HandleAnimate();
    }
Ejemplo n.º 3
0
    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;
    }
Ejemplo n.º 4
0
    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);
        }
    }
Ejemplo n.º 5
0
    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();
        }
    }
Ejemplo n.º 6
0
    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);
    }
Ejemplo n.º 7
0
 private void Start()
 {
     itemBasic     = GetComponent <ItemBasic>();
     userBehave    = FindObjectOfType <ControllableBehave>();
     userTransform = userBehave.gameObject.transform;
 }
Ejemplo n.º 8
0
 private void Start()
 {
     userBehave = FindObjectOfType <ControllableBehave>();
     itemBasic  = GetComponent <ItemBasic>();
 }