Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        timeToNextAttack -= Time.deltaTime;

        if (timeToNextAttack <= 0.0f)
        {
            timeToNextAttack = attackInterval;
            attackAnimAmount[nextAttackHand]      = 1.0f;
            hands[nextAttackHand].canAttackPlayer = true;

            // Next time, use the next hand
            nextAttackHand++;
            if (nextAttackHand >= hands.Length)
            {
                nextAttackHand = 0;
            }
        }

        for (int i = 0; i < hands.Length; i++)
        {
            SkullBossHand hand    = hands[i];
            Vector3       restPos = transform.position + new Vector3(i % 2 == 0 ? -2f : 2f, 0f, 0f);

            if (enemy.target != null)
            {
                restPos = Vector3.Lerp(restPos, enemy.target.transform.position, attackAnimAmount[i]);
            }

            hand.transform.position = restPos;

            attackAnimAmount[i] *= 0.95f;
        }
    }
Beispiel #2
0
    protected override void Update()
    {
        base.Update();

        foreach (Collider coll in Physics.OverlapBox(transform.position, Vector3.one * 0.25f))
        {
            Pickup pickup = coll.GetComponent <Pickup>();
            if (pickup != null)
            {
                switch (pickup.type)
                {
                case Pickup.Type.COIN:
                    Game.inst.AwardCurrency(pickup.count);
                    pickupSFX.Play();
                    break;

                case Pickup.Type.HEALTH:
                    Heal(pickup.count);
                    break;
                }
                Destroy(coll.gameObject);
            }

            if (coll.GetComponent <Hole>())
            {
                levelupSFX.Play();
                Game.inst.EnteredHole();
            }

            SkullBossHand hand = coll.GetComponent <SkullBossHand>();
            if (hand != null)
            {
                if (hand.canAttackPlayer)
                {
                    SufferDamage(hand.boss.enemy.attackDamage, hand.boss.enemy.dType, hand.boss.enemy.dElement, hand.transform.position);
                    hand.canAttackPlayer = false;
                }
            }
        }
    }