Ejemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     zapState              = electricityState.groundState;
     spriteRenderer        = GetComponent <SpriteRenderer>();
     currentCostume        = groundState1;
     spriteRenderer.sprite = currentCostume;
     growingZaps           = new List <Sprite>();
     growingZaps.Add(zap1); growingZaps.Add(zap2); growingZaps.Add(zap3);
     circleCollider = GetComponent <CircleCollider2D>();
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        zapTime     += Time.deltaTime;
        animateTime += Time.deltaTime;

        switch (zapState)
        {
        case electricityState.groundState:
            circleCollider.radius = groundRadius;
            if (animateTime >= animationFrameLength)
            {
                toggleCostume(groundState1, groundState2);
                animateTime = 0;
            }
            if (zapTime >= timeBetweenZaps)
            {
                zapTime          = 0;
                zapState         = electricityState.growingZap;
                currentZapGrowth = 0;
                currentCostume   = growingZaps[0];
            }
            break;

        case electricityState.growingZap:
            circleCollider.radius = growingRadius;

            if (animateTime >= animationFrameLength)
            {
                currentZapGrowth++;
                if (currentZapGrowth <= 2)
                {
                    currentCostume = growingZaps[currentZapGrowth];
                }
                else
                {
                    currentZapGrowth = 0;
                    currentCostume   = bigzap1;
                    zapState         = electricityState.bigZap;
                    zapTime          = 0;
                }
                animateTime = 0;
            }
            break;

        case electricityState.bigZap:
            circleCollider.radius = bigZapRadius;

            if (animateTime >= animationFrameLength)
            {
                toggleCostume(bigzap1, bigzap2);
                animateTime = 0;
            }
            if (zapTime >= timeLengthOfZaps)
            {
                zapTime  = 0;
                zapState = electricityState.groundState;
            }
            break;
        }
        spriteRenderer.sprite = currentCostume;
    }