示例#1
0
    public void Shocked()
    {
        Collider.enabled       = false;
        ThisTransform.position = new Vector3(ThisTransform.position.x, ThisTransform.position.y, 0.0f);
        ScoreManager.UpdateScores(PointValue);

        ThisTransform.GetComponent <Rigidbody2D>().gravityScale = Mathf.Abs(ThisTransform.GetComponent <Rigidbody2D>().gravityScale - 1);

        switch (ThisTransform.name)
        {
        case "Imp One":
        case "Imp Two":
            GetComponent <FlyingEnemyMove>().enabled = false;
            break;

        case "Skeleton":
            GetComponent <SkeletonMove>().StopEverything();
            GetComponent <SkeletonMove>().enabled = false;
            break;

        case "Short Range Knight":
            GetComponent <ShortKnightMove>().StopEverything();
            GetComponent <ShortKnightMove>().enabled = false;
            break;

        case "Long Range Knight":
            GetComponent <LongKnightMove>().StopEverything();
            GetComponent <LongKnightMove>().enabled = false;
            break;
        }

        ThisTransform.GetComponent <EnemyDeath>().enabled = false;
        ThisTransform.GetComponent <Animator>().enabled   = false;

        GetComponent <AudioSource>().PlayOneShot(Impact);

        ThisTransform.GetComponent <SpriteRenderer>().sprite = DeathSprite;
        ThisTransform.localScale = new Vector3(ThisTransform.localScale.x, ThisTransform.localScale.y / 2, ThisTransform.localScale.z);

        StartCoroutine(Fade.FadingOut(GetComponent <SpriteRenderer>(), FadeOutTime));
    }