コード例 #1
0
    // ============================================= Methods
    /// <summary>
    /// On game start, set this object's properties.
    /// </summary>
    void Start()
    {
        // Set the game manager, if not set
        if (gameManager == null)
        {
            gameManager = FindObjectOfType <GameManager>();
        }

        // Set the animator and character controller
        controller = GetComponent <CharacterController>();
        animator   = GetComponent <Animator>();

        // Set the aimer and disable it
        aimer         = GetComponentInChildren <AimIKBehaviour>();
        aimer.enabled = false;
        aimerMovement = GetComponentInChildren <AimerMovement>();

        // Set the main camera
        mainCamera = Camera.main;

        // Set the overhead camera
        overheadCamera = GameObject.FindGameObjectWithTag("OverheadCamera").GetComponent <Camera>();

        // Set the reticle
        reticle         = mainCamera.GetComponentInChildren <Canvas>();
        reticle.enabled = false;

        // Adjust health bar
        gameManager.healthBar.GetComponent <RectTransform>().sizeDelta = new Vector2(Mathf.Max(health * 3.0f, 0), 15.0f);
    }
コード例 #2
0
    // ============================================= Methods
    /// <summary>
    /// On game start, set this object's properties.
    /// </summary>
    void Start()
    {
        // Set the game manager, if not set
        if (gameManager == null)
        {
            gameManager = FindObjectOfType <GameManager>();
        }

        // Set the animator and nav mesh agent
        navMeshAgent = GetComponent <NavMeshAgent>();
        animator     = GetComponent <Animator>();

        // Set the aimer and disable it
        aimer         = GetComponentInChildren <AimIKBehaviour>();
        aimer.enabled = false;

        // Get the player transform
        //player = FindObjectOfType<PlayerController>().gameObject.transform;

        // Set the default state and target
        currentState = EnemyState.WalkingTowardsMiddle;
        SetTarget();

        // Add to previous call stack
        //previousStateStack = new Stack<KeyValuePair<Transform, EnemyState>>();
        //previousStateStack.Push(
        //    new KeyValuePair<Transform, EnemyState>(navMeshTarget, currentState));

        // Update the behavior
        behavior = Random.Range(0, 2);

        // Add flags
        otherTeamFlag = gameManager.playerFlag.GetComponent <FlagScript>();
        myTeamFlag    = gameManager.enemyFlag.GetComponent <FlagScript>();

        // Set movement speed
        navMeshAgent.speed = difficulty + 1.5f;

        // Set shooting distance
        playerShootDistance = 10.0f + ((difficulty - 1.0f) * 5.0f);

        // Set gun clip size
        gun.clipSize        *= Mathf.CeilToInt(difficulty / 2.0f);
        gun.remainingBullets = gun.clipSize;
        gun.damage          *= Mathf.Max(1.0f, difficulty / 3.0f);
    }
コード例 #3
0
 /// <summary>
 /// The Awake function called first of all
 /// </summary>
 private void Awake()
 {
     // Set the aimIKBehaviour
     aimIKBehaviour = this.GetComponent <AimIKBehaviour>();
 }