Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        IsAlive  = true;
        FishName = NewName();

        if (rigidBody == null)
        {
            rigidBody = this.GetComponent <Rigidbody>();
        }

        if (tankBoundary == null)
        {
            tankBoundary = GetComponent <TankBoundary>();
        }

        if (tankBoundary == null)
        {
            tankBoundary = GetComponentInParent <TankBoundary>();
        }

        if (target == null)
        {
            target = this.transform.Find("Target")?.gameObject;
        }

        if (target == null)
        {
            target = this.gameObject;
        }

        if (colliders == null)
        {
            colliders = this.GetComponentsInChildren <Collider>().Where(c => c.enabled).ToArray();
        }

        if (fishManager == null)
        {
            fishManager = FindObjectOfType <FishManager>();
        }

        if (fishManager != null)
        {
            fishManager.fish.Add(this);
        }

        if (feeder == null)
        {
            feeder = FindObjectOfType <FoodFeeder>();
        }

        if (position != null)
        {
            this.transform.position = position.Position;
            this.transform.rotation = position.Rotation;
        }
    }
Exemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        //Start the allowance countdown
        budget.allowanceCountdown = budget.allowanceTime;

        if (foodFeeder == null)
        {
            foodFeeder = FindObjectOfType <FoodFeeder>();
        }

        if (tankDirtiness == null)
        {
            tankDirtiness = FindObjectOfType <TankDirtiness>();
        }

        if (medApplicator == null)
        {
            medApplicator = FindObjectOfType <MedicineApplicator>();
        }

        if (savedTypeManager == null)
        {
            savedTypeManager = FindObjectOfType <SavedObjectTypeManager>();
        }

        SetMetrics();

        audioSources = FindObjectsOfType <AudioSource>();

        if (buttonClickAudio != null)
        {
            foreach (var button in Resources.FindObjectsOfTypeAll <Button>())
            {
                //If the button doesn't already have a clipplayer attached, set it to the default button click sound.
                if (button.GetComponent <AudioClipPlayer>() == null)
                {
                    button.onClick.AddListener(PlayButtonClick);
                }
            }
        }

        LoadGame(Preferences.LastTank);
        saveCountdown = saveInterval;

        //This makes sure that if we restart while paused, the timescale resets to 1.0f
        Time.timeScale = 1.0f;
    }