Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        playerController = GetComponent <FP_Controller>();
        footSteps        = GetComponent <FP_FootSteps>();
        playerInput      = GetComponent <FP_Input>();

        originalLocalPos = headBob.MainCamera.localPosition;

        if (GetComponent <AudioSource>() == null)
        {
            // we automatically add an audiosource, if one has not been manually added.
            // (if you want to control the rolloff or other audio settings, add an audiosource manually)
            gameObject.AddComponent <AudioSource>();
        }

        prevPosition = transform.position;
        audioSource  = GetComponent <AudioSource>();
    }
    private void InitializeAndLoadPlayer()
    {
        tempGO   = Resources.Load("Pawn/Player") as GameObject;
        playerGO = Instantiate(tempGO, new Vector3(lengthTerrain / 2, maxHeight, widthTerrain / 2), Quaternion.identity);

        playerCharacterController = playerGO.GetComponentInChildren <CharacterController>();
        playerFP_Controller       = playerGO.GetComponentInChildren <FP_Controller>();
        playerPawn = playerGO.GetComponentInChildren <Pawn>();
        playerTR   = playerPawn.gameObject.GetComponent <Transform>();
        playerFP_Controller.walkSpeed = playerPawn.m_PawnSO.Speed;
        playerFP_Controller.runSpeed  = playerPawn.m_PawnSO.Speed * 2.0f;

        playerTR.position = new Vector3(lengthTerrain / 2, maxHeight + playerCharacterController.height, widthTerrain / 2);

        m_GUI_Manager = FindObjectOfType <GUI_Manager>();
        m_Camera      = Camera.main;

        CurrentGameMode = GameMode.Game;
    }
Beispiel #3
0
    protected override void Awake()
    {
        base.Awake();

        bulletPoolParent = new GameObject("BulletPoolParent");

        tempGO = Resources.Load("Pawn/Bullet") as GameObject;

        for (int i = 0; i < maxBulletPool; i++)
        {
            bulletPoolGO.Add(Instantiate(tempGO, bulletPoolParent.transform));
            bulletPoolTR.Add(bulletPoolGO[bulletPoolGO.Count - 1].GetComponent <Transform>());
            bulletPool_AI.Add(bulletPoolGO[bulletPoolGO.Count - 1].GetComponent <BulletAI>());
            bulletPoolGO[bulletPoolGO.Count - 1].SetActive(false);
        }

        if (shootPointTR == null)
        {
            shootPointTR = gameObject.transform;
        }
        shootPointGO = shootPointTR.gameObject;

        m_FP_Controller = gameObject.GetComponent <FP_Controller>();
    }
Beispiel #4
0
 void OnEnable()
 {
     fP_Controller = (FP_Controller)target;
     cntrlr        = MonoScript.FromMonoBehaviour((FP_Controller)target);
 }
Beispiel #5
0
 void Start()
 {
     playerController = GetComponent <FP_Controller>();
 }