예제 #1
0
    // Does the particle animation
    private IEnumerator particleAnimation(float time, PlayerAbilityBase ability)
    {
        this.particleS.Play();
        yield return(new WaitForSeconds(timeBeforeChange));

        this.GetComponent <SpriteRenderer>().color = Color.blue;
        this.ChangeParticle(ability);

        yield return(new WaitForSeconds(animationDuration));

        this.particleS.Stop();
    }
예제 #2
0
    // Change the particle - Destroy the previous ability, and then create the new one.
    private void ChangeParticle(PlayerAbilityBase ability)
    {
        if (this.ability != null)
        {
            Destroy(this.ability.gameObject);
        }

        PlayerAbilityBase newAbility = Instantiate <PlayerAbilityBase>(ability, this.transform);

        newAbility.transform.SetParent(this.transform);
        this.ability = newAbility;
        GameStateManager.Instance.game.ui.setAbilityAvailable(newAbility.useableAbility);
        GameStateManager.Instance.game.ui.setAbilityCooldownIcon(newAbility.cooldownVisualsPrefab);
    }
예제 #3
0
    // Transforms into a random particle
    public PlayerAbilityBase TransformParticle(bool anim = false)
    {
        PlayerAbilityBase abilityInfo = Dictionaries.Instance.getRandAbilityPrefab();

        if (anim)
        {
            this.PlayParticleTransformationAnimation(abilityInfo);
        }
        else
        {
            this.ChangeParticle(abilityInfo);
        }
        return(abilityInfo);
    }
예제 #4
0
    public PlayerAbilityBase getRandAbilityPrefab()
    {
        int randIndex = Random.Range(0, this.abilityPrefabs.Count);
        PlayerAbilityBase abilityInfo = abilityPrefabs[randIndex];

        if (GameStateManager.Instance != null && GameStateManager.Instance.game.player.playerAbility.ability != null &&
            GameStateManager.Instance.game.player.playerAbility.ability.type == abilityInfo.type)
        {
            randIndex   = (randIndex + 1) % this.abilityPrefabs.Count;
            abilityInfo = abilityPrefabs[randIndex];
        }

        return(abilityInfo);
    }
예제 #5
0
    public void TransformParticle()
    {
        if (this.isTransforming)
        {
            return;
        }

        PlayerAbilityController abilityController = GameStateManager.Instance.game.player.playerAbility;
        // Transform the particle, and extract the image information to the particleImageContainer
        PlayerAbilityBase info          = GameStateManager.Instance.game.player.playerAbility.TransformParticle(true);
        GameObject        particleImage = Instantiate(info.canvasVisualsPrefab, this.particleImageContainer.transform);

        particleImage.transform.SetParent(this.particleImageContainer.transform);
        this.curTransformObject = particleImage;

        this.commonNameText.text  = info.commonName;
        this.formulaText.text     = info.chemicalName;
        this.descriptionText.text = info.description;
        GameStateManager.Instance.game.backgroundHandler.ChangeColor(true);

        // Animation effect
        StartCoroutine(this.transformCor());
    }
예제 #6
0
 // Play particle transformation animation
 private void PlayParticleTransformationAnimation(PlayerAbilityBase ability)
 {
     StartCoroutine(particleAnimation(this.animationDuration, ability));
 }