예제 #1
0
        protected override void DoAction()
        {
            if (offsetMatchesFlipX)
            {
                int sign = offsetMatchesFlipX ? -1 : 1;                 // set the sign of the X position based on whether the player
                // sprite is flipped or not
                anim.transform.localPosition = new Vector2(anim.transform.localPosition.x * sign, anim.transform.localPosition.y);
            }
            // Set the rotation for the effect
            Quaternion rot = GetRotation();

            // Initialize the effect properties
            TempObjectInfo info = new TempObjectInfo();

            info.targetColor = color;
            if (duration < 0)
            {
                duration = anim.anim.TimeLength;
            }
            info.lifeTime    = duration;
            info.fadeOutTime = 0.1f;

            // Initialize the effect and play it
            anim.GetComponent <TempObject>().Init(
                rot,
                anim.transform.position,
                anim.anim.frames[0],
                info);
            anim.Play();
        }
예제 #2
0
 public TempObjectInfo(TempObjectInfo info)
 {
     this.isSelfDeactivating = info.isSelfDeactivating;
     this.fadeInTime         = info.fadeInTime;
     this.lifeTime           = info.lifeTime;
     this.fadeOutTime        = info.fadeOutTime;
     this.targetColor        = info.targetColor;
 }
예제 #3
0
 /// <summary>
 /// Init the specified rotation, position and sprite, with <see cref="isSelfDeactivating/>, <see cref="fadeInTime/>,
 /// <see cref="lifetime"/>, and <see cref="fadeOutTime/> set to their default values set in the Inspector
 /// </summary>
 /// <param name="rotation">Rotation.</param>
 /// <param name="position">Position.</param>
 /// <param name="sprite">Sprite.</param>
 public void Init(Quaternion rotation, Vector3 position, Sprite sprite, TempObjectInfo tempObjectInfo)
 {
     gameObject.SetActive(true);
     transform.rotation = rotation;
     transform.position = position;
     sr.sprite          = sprite;
     this.info          = new TempObjectInfo(tempObjectInfo);
     StartCoroutine(FadeIn());
 }
예제 #4
0
    private void SpawnSmoke()
    {
        TempObject     smoke = effectsPool.GetPooledObject().GetComponent <TempObject>();
        TempObjectInfo info  = new TempObjectInfo(true, 0.2f, lifetime / 2f, lifetime / 2f, new Color(1, 1, 1, 0.5f));

        smoke.Init(
            Quaternion.Euler(0, 0, Random.Range(0, 360f)),
            transform.position,
            smokeSprites [Random.Range(0, smokeSprites.Length)],
            info
            );
    }
예제 #5
0
    public static void PlayEffect(SimpleAnimation toPlay, Vector3 position, TempObjectInfo info)
    {
        GameObject            o       = instance.GetPooledObject();
        SimpleAnimationPlayer anim    = o.GetComponent <SimpleAnimationPlayer>();
        TempObject            tempObj = o.GetComponent <TempObject>();

        tempObj.info = info;
        anim.anim    = toPlay;
        tempObj.Init(Quaternion.identity,
                     position,
                     toPlay.frames[0]);
        anim.Play();
    }
예제 #6
0
        protected override void DoAction()
        {
            // Set the rotation for the effect
            Quaternion rot = GetRotation();

            // Initialize the effect properties
            TempObjectInfo info = new TempObjectInfo();

            info.targetColor = color;
            if (duration < 0)
            {
                duration = effect.TimeLength;
            }
            info.lifeTime    = duration;
            info.fadeOutTime = 0.1f;

            lastPlayedEffect = EffectPooler.PlayEffect(effect, position, info);
        }
예제 #7
0
    private void SmokeEffect()
    {
        TempObject     smokeBomb = effectsPool.GetPooledObject().GetComponent <TempObject> ();
        TempObjectInfo info      = new TempObjectInfo(true,
                                                      0f,
                                                      smokeBombEffect.TimeLength * 0.9f,
                                                      smokeBombEffect.TimeLength * 0.1f,
                                                      new Color(1, 1, 1, 0.7f));
        SimpleAnimationPlayer animPlayer = smokeBomb.GetComponent <SimpleAnimationPlayer> ();

        animPlayer.anim = smokeBombEffect;
        smokeBomb.Init(
            Quaternion.identity,
            transform.position,
            smokeBombEffect.frames[0],
            info
            );
        animPlayer.Play();
    }