Exemple #1
0
 public void flyAtTarget(GameObject target)
 {
     _target = target;
     _anim.SetTrigger("Fly");
     parrotState = ParrotState.position;
     delayTime   = _positionTime;
 }
Exemple #2
0
    public override void damage(int damage, AbstractDamageCollider.DamageType type, int knockback)
    {
        // Only has one hitpoint.
        parrotState = ParrotState.die;
        _anim.SetTrigger("Die");

        // Got hit by something. Drop item.
        drop(healItem);
    }
Exemple #3
0
 protected override void Start()
 {
     _anim = GetComponent <Animator> ();
     EnemyAbstractBehaviour[] eabs = _anim.GetBehaviours <EnemyAbstractBehaviour> ();
     for (var i = eabs.Length - 1; i >= 0; i--)
     {
         Debug.Log("Behaviours: " + eabs [i]);
         eabs [i].enemy = this;
     }
     parrotState = ParrotState.idle;
 }
Exemple #4
0
 public void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.gameObject == _target && collider.tag != "AllyHazard")
     {
         // Only damage the target.
         AbstractClass ac = collider.GetComponent <AbstractClass> ();
         if (ac)
         {
             ac.damage(_damage, AbstractDamageCollider.DamageType.medium, _knockback);
             _anim.SetTrigger("Die");
             parrotState = ParrotState.die;
         }
     }
 }
Exemple #5
0
    protected override void Update()
    {
        // Yes. Alright, state time.
        switch (parrotState)
        {
        case ParrotState.idle:
            // Idle. Do nothing. Duh.
            break;

        case ParrotState.position:
            // Parrot has its target. Float around on their x-axis.
            transform.position = Vector3.Lerp(transform.position, new Vector3(transform.position.x, _target.transform.position.y, transform.position.z), .5f);
            delayTime         -= Time.deltaTime;
            if (delayTime <= 0)
            {
                parrotState = ParrotState.launch;
                delayTime   = _launchTime;
            }
            break;

        case ParrotState.launch:
            // Parrot fires at target!
            transform.Translate(Vector3.left * _launchVelocity * Time.deltaTime);
            delayTime -= Time.deltaTime;
            if (delayTime <= 0)
            {
                parrotState = ParrotState.die;
            }
            break;

        case ParrotState.die:
            // Parrot is just resting. Pining. Or maybe stunned. It's your fault. No refunds.
            Destroy(gameObject);
            break;
        }
    }