コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        // Find references to required components
        characterController = GetComponent <CharacterController>();
        if (cameraTransform == null)
        {
            cameraTransform = GetComponentInChildren <Camera>().transform;
        }

        // Set health bar UI element for health script
        healthScript = GetComponent <HealthScript>();
        HealthBarScript healthBar = GameObject.FindWithTag("PlayerScreen").GetComponentInChildren <HealthBarScript>();

        healthScript.SetHealthBar(healthBar);
        healthScript.ResetHealth();

        // Set default text for player info
        PlayerScore = 0;
        if (infoDisplay == null)
        {
            infoDisplay = GameObject.FindWithTag("PlayerScreen").GetComponentInChildren <InfoDisplayScript>();
            infoDisplay.ResetWave();
            infoDisplay.ResetScore();
        }
        if (announcement == null)
        {
            announcement = GameObject.FindWithTag("PlayerScreen").GetComponentInChildren <AnnouncementScript>();
        }

        // Setup switch timer and weapon player will be spawned with
        switchTimeLeft = timeToSwitch;
        if (timeDisplay == null)
        {
            timeDisplay = GameObject.FindWithTag("PlayerScreen").GetComponentInChildren <TimeDisplayScript>();
            timeDisplay.SetMaxTime(timeToSwitch);
            timeDisplay.ResetTime();
        }
        if (weaponDisplay == null)
        {
            weaponDisplay = GameObject.FindWithTag("PlayerScreen").GetComponentInChildren <WeaponDisplayScript>();
        }
        SwitchWeapon();
    }
コード例 #2
0
    public void ResetPlayerScreen()
    {
        DebugLogScript      debugLog      = GetComponentInChildren <DebugLogScript>();
        TimeDisplayScript   timeDisplay   = GetComponentInChildren <TimeDisplayScript>();
        WeaponDisplayScript weaponDisplay = GetComponentInChildren <WeaponDisplayScript>();

        if (debugLog != null)
        {
            debugLog.ClearLog();
        }
        if (debugLog != null)
        {
            timeDisplay.ResetTime();
        }
        if (debugLog != null)
        {
            weaponDisplay.DisplayWeapon("");
        }
    }