예제 #1
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex)
    {
        if (animator.transform.name == "Evil Sun")
        {
            SoundSpawner.PlaySoundObj(animator.transform.position, Resources.Load <AudioClip>("Audio/sunThrown"), 1);
            animator.GetComponent <SpriteRenderer>().sprite = sunThrownSprite;
        }
        ThrownVals_script                 = animator.gameObject.GetComponent <ThrownVals>();
        animator.gameObject.layer         = 15;
        projectileHitbox                  = Instantiate(projectileHitbox, animator.transform.position, Quaternion.identity);
        projectileHitbox.transform.parent = animator.gameObject.transform;
        if (ThrownVals_script.regularExplosion)
        {
            projectileHitbox.transform.GetChild(0).GetComponent <ToGoreHitbox>().goreExplosion =
                Resources.Load <GameObject>("Explosion");
        }
        // Instantly kill if the spawn position of the thrown projectile overlaps a layer.

        if (ThrownVals_script.instaKill == false)
        {
            ThrownVals_script.beginMovement = true;
        }



        ThrownVals_script.WaitUntilExploding();
    }
    private void SetThrownProperties()
    {
        if (haveThrown && enemyObj)
        {
            if (transform.eulerAngles.z <= 300 && transform.eulerAngles.z >= 240)
            {
                PlayerController_script.jumpFromThrowingEnemy = true;
            }
            // Instantiate AudioObj from Resources to make "woosh" sound.
            var audioObj = Instantiate(Resources.Load("AudioObj") as GameObject);
            audioObj.GetComponent <AudioObj>().givenAudio = Resources.Load("Audio/throwSound2") as AudioClip;

            ThrownVals_script = enemyObj.GetComponent <ThrownVals>();
            ThrownVals_script.givenVelocity = 70;
            enemyObj.transform.position     = throwLocation.position;
            var bC = enemyObj.GetComponent <BoxCollider2D>();
            if (bC)
            {
                bC.size    = new Vector2(0.05f, 0.05f);
                bC.enabled = true;
            }

            var cC = enemyObj.GetComponent <CircleCollider2D>();
            if (cC)
            {
                cC.radius  = 0.05f;
                cC.enabled = true;
            }

            if (detectOverlap_script.isOverlapping)
            {
                ThrownVals_script.instaKill = true;
            }

            enemyObj.GetComponent <Animator>().SetBool("thrown", true);
            enemyObj = null;
            PlayerController_script.chosenSprite = 1;
            haveThrown = false;
            StartCoroutine(StartHandEnableDelay());
        }

        if (!enemyObj)
        {
            PlayerController_script.chosenSprite = 1;
            haveThrown = false;
            StartCoroutine(StartHandEnableDelay());
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     myParent          = transform.parent.gameObject;
     ThrownVals_script = myParent.GetComponent <ThrownVals>();
     enemyAnimator     = myParent.GetComponent <Animator>();
     goreExplosion     = Resources.Load("GoreSpawner") as GameObject;
     regularExplosion  = Resources.Load("Explosion") as GameObject;
     if (ThrownVals_script.givenVelocity >= ThrownVals_script.goreVelocityRequirement)
     {
         goreOrCorpse = false;
     }
     else
     {
         goreOrCorpse = true;
     }
 }
 override public void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex)
 {
     ThrownVals_script = animator.gameObject.GetComponent <ThrownVals>();
 }