コード例 #1
0
    // Handles a character being clicked
    public void CharacterClicked(MamiPoserCharacter clickedCharacter)
    {
        // Play the smoke effect
        GameObject smoke = Instantiate(smokePrefab, Vector2.zero, Quaternion.identity);

        smoke.GetComponent <Transform>().SetParent(characterSlots[mamizouIndex], false);
        // Play the poof sound - panned to the smoke's location
        MicrogameController.instance.playSFX(
            smokeSound,
            volume: 1f,
            panStereo: AudioHelper.getAudioPan(smoke.transform.position.x)
            );
        // Spawn the real Mamizou - hidden for now
        mamizou = Instantiate(mamizouPrefab, Vector2.zero, Quaternion.identity);
        mamizou.GetComponent <Transform>().SetParent(characterSlots[mamizouIndex], false);
        mamizou.gameObject.SetActive(false);
        // Delay the sprite switch so it happens when the sprite is covered in smoke
        mamizouAppearTimer = TimerManager.NewTimer(mamizouAppearDelay, SwitchSpriteToMamizou, 0);

        // Determine if the player chose correctly
        GameObject signPrefab;
        AudioClip  resultSound;

        if (clickedCharacter.isDisguised)
        {
            // Win
            MicrogameController.instance.setVictory(victory: true, final: true);
            mamizou.ChoseRight();
            signPrefab  = correctSignPrefab;
            resultSound = winSound;
        }
        else
        {
            // Loss
            MicrogameController.instance.setVictory(victory: false, final: true);
            mamizou.ChoseWrong();
            clickedCharacter.ChoseWrong();
            signPrefab  = incorrectSignPrefab;
            resultSound = lossSound;
        }

        // Delay the victory/loss effects
        resultTimer = TimerManager.NewTimer(
            resultEffectsDelay,
            () => VictoryLossEffects(signPrefab, resultSound),
            0
            );
    }
コード例 #2
0
    // Setup the microgame
    void Start()
    {
        // Calculate how many characters to spawn by adding numbers from spawners
        // and create slots to spawn them in
        characterSlots = new List <Transform>();
        foreach (MamiPoserSpawner spawner in spawners)
        {
            characterSpawnNumber += spawner.characterSpawnNumber;
            characterSlots.AddRange(spawner.CreateSlots());
        }

        // Determine which character to use and which of the copies is Mamizou
        chosenCharacterPrefab = characterPrefabs[Random.Range(0, characterPrefabs.Length)];
        print("Chosen character prefab: " + chosenCharacterPrefab);
        mamizouIndex = Random.Range(0, characterSpawnNumber);
        print("Mamizou index: " + mamizouIndex);

        // Spawn the characters
        createdCharacters = new List <MamiPoserCharacter>();
        for (int i = 0; i < characterSpawnNumber; i++)
        {
            MamiPoserCharacter newCharacter = Instantiate(chosenCharacterPrefab, Vector2.zero, Quaternion.identity);
            newCharacter.GetComponent <Transform>().SetParent(characterSlots[i], false);
            createdCharacters.Add(newCharacter);
            newCharacter.controller = this;
            if (i == mamizouIndex)
            {
                // This one is disguised Mamizou
                newCharacter.SetDisguised();
            }
            else
            {
                // This one is not Mamizou
                newCharacter.SetRegular();
            }
        }
    }