Exemple #1
0
    void OnTargetHit(EnemyHealth target, Vector3 location)
    {
        Debug.Log("Hit " + target + " with magic!");
        EnemyMovement movement = target.GetComponent <EnemyMovement>();
        float         damage   = Spell.sDamage;

        movement.animator.SetBool("damaged", true);
        target.Damage(damage, 1);
        target.hitContainer.active             = true;
        target.hitContainer.transform.position = location;
        //calculate correct rotation so that the player can see the label right
        float rotation = (movement.IsPlayerBehind()) ? 0f : 180f;

        target.hitContainer.transform.localRotation = Quaternion.identity;
        target.hitContainer.transform.Rotate(new Vector3(0f, rotation, 0f));

        target.hitMesh.text = "+ " + damage;
        ParticleSpawner parent = GetComponentInParent <ParticleSpawner>();

        parent.DeleteMsg(target);
    }