コード例 #1
0
    IEnumerator RestartEverything()
    {
        SceneManager.LoadScene("Floor 1");

        yield return(new WaitForFixedUpdate());

        player               = Player_S.self.gameObject;
        AudioManager         = AudioManager_S.self;
        canvas               = Canvas_S.self;
        canvasAsset          = Canvas_S.self.GetComponent <Canvas>();
        judgingSystem        = JudgingSystem_S.self;
        secondCamera         = SecondCamera_S.self.GetComponent <Camera>();
        secondCamera.enabled = false;
        mainCamera           = Camera_S.self.GetComponent <Camera>();


        level = 1;
        canvas.getLevelUIText().text = "level " + level;


        QnA_S[] array = Resources.LoadAll <QnA_S>("Questions"); // takes all the QnA_S files from Resources
        for (int i = 0; i < array.Length; i++)
        {
            qnaArray.Add(array[i]);
        }


        BuildLevel();
    }
コード例 #2
0
    private int currentWaypoint = 0; // Current waypoint AI is seeking


    // Start is called before the first frame update
    void Start()
    {
        foundTarget = false;

        audioManager            = GameObject.Find("Audio Manager").GetComponent <AudioManager_S>();
        enemySprite             = transform.GetChild(0).gameObject;
        spriteRigid             = transform.GetChild(0).GetComponent <Rigidbody>();
        animator                = transform.GetChild(0).GetComponent <Animator>();
        invincibilityFlashTicks = (int)((invincibilitySeconds - 0.28f) / 0.16f);

        // ****************************************************************

        seeker = GetComponent <Seeker>();
        rigid  = GetComponent <Rigidbody2D>();

        if (target == null)
        {
            target = transform;
        }

        seeker.StartPath(transform.position, target.position, OnPathComplete); // starts a new path to the target, returns the result to method On Path Complete
        StartCoroutine(UpdatePath());
    }
コード例 #3
0
    // Start is called before the first frame update
    void Awake()
    {
        if (self == null)
        {
            self = this;

            DontDestroyOnLoad(gameObject); // Basic method to remain even after scene load
            GameController_S.maintainedScripts.Add(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }


        foreach (Sound_S sound in sounds) // Creates audio sources for all sounds in the array
        {
            sound.source        = gameObject.AddComponent <AudioSource>();
            sound.source.clip   = sound.clip;
            sound.source.volume = sound.volume;
            sound.source.pitch  = sound.pitch;
            sound.source.loop   = sound.loop;
        }
    }