// Start() is called after Awake(), this ensures that the matrix has alrady been built
    void Start()
    {
        /* Set the entry that corresonds to the obstacle's position as
         * '1' brick
         * '2' reinforcedBrick
         * 'X' steel */

        if (name.Contains("Reinforced"))
        {
            ForbiddenTilesVores.RegisterSquare(transform.position, '2');
        }
        else if (name.Contains("Brick"))
        {
            ForbiddenTilesVores.RegisterSquare(transform.position, '1');
        }
        else if (name.Contains("Steel"))
        {
            ForbiddenTilesVores.RegisterSquare(transform.position, 'x');
        }
    }
示例#2
0
    /** Kigger på hvad flammen rammer. */
    void OnTriggerEnter(Collider other)
    {
        if (other.name.Contains("BrickBlock"))
        {
            //Spawn pickUp, 1 ud af 3 gange.
            if (Random.Range(0, 3) == 1)
            {
                GameObject pickup = other.GetComponent <Spawner> ().SpawnElement(
                    other.transform.position, new Vector3(270, 0, 0), Random.Range(0, 3));

                // Hvis det er en sygdom ændrer vi navnet så det kan bruges.
                if (pickup.name.Contains("Sickness"))
                {
                    SicknessSpawn(pickup);
                }
            }

            //Updater Grid
            DestroyObject(other.gameObject);
            ForbiddenTilesVores.RegisterSquare(other.transform.position, '0');
        }
        else if (other.name.Contains("Player"))
        {
            SaveData(other);

            // Stopper den ramte spiller, så denne ikke længere kan bevæge sig.
            MovePlayer mover = other.GetComponent <MovePlayer> ();
            mover.doMove    = false;
            mover.allowMove = false;

            // Sætter den ramte spillers animation til at denne har tabt.
            Animator playerAni = other.GetComponent <Animator> ();
            playerAni.SetBool("Run", false);
            playerAni.SetBool("Win", false);
            playerAni.SetTrigger("GameEnd");
        }
    }