Beispiel #1
0
 void Update()
 {
     animationManager = GetComponent<SpriteManager>() as SpriteManager;
     if(hitPoints <= 0) {
       animationManager.Play("Die");
       gameObject.GetComponent<BoxCollider>().enabled = false;
       hurtTimer += Time.deltaTime/fallTime;
       //transform.position = Vector3.Lerp(oldPosition, fallPosition, hurtTimer);
     } else if(hurt) {
       hurtTimer += Time.deltaTime;
       if(hurtTimer >= cringeTime && hitPoints > 0) {
     hurt = false;
     hurtTimer = 0;
     fireTimer = 0.7f;
       }
       wasHurt = true;
     } else {
       fireTimer += Time.deltaTime;
       if(fireTimer >= fireTime) {
     fireTime = Random.Range(minFireTime, maxFireTime);
     shooter.Fire();
     fireTimer = 0;
     int lastFrame = animationManager.CurrentAnimation.FrameIndex;
     animationManager.Play("Fire", false);
     animationManager.CurrentAnimation.frameIndex = lastFrame;
       }
       animationManager.Play("Fly",(wasHurt ? true : false));
       wasHurt = false;
       }
 }
Beispiel #2
0
    void Start()
    {
        renderer.material.color = new Color(1,0,1);
        shooter = shooterTarget.GetComponent<SpitBallShooter>() as SpitBallShooter;

        animationManager = GetComponent<SpriteManager>() as SpriteManager;

        animationManager.AddAnimation("Fly", new int[] {0,1,20,21,22,23,0,1,2,3,4,5}, 10f);
        animationManager.AddAnimation("Fire", new int[] {18,19,20,21,22,23}, 10f);
        fireIterationMax += 1;

        animationManager.AddAnimation("Die", new int[] {8,9,10,11,12,13,14,15,18,18,16,17}, 15f, false);
        animationManager.AddAnimation("Hurt", new int[] {6,7}, 10f, false);

        animationManager.Play("Fly");

        fireTime = Random.Range(minFireTime, maxFireTime);
    }