public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        //casts target to DemonController
        FastDemon enemy = (FastDemon)target;

        if (GUILayout.Button("Generate ID"))
        {
            enemy.enemyID = System.Guid.NewGuid().ToString();
            EditorUtility.SetDirty(enemy);
        }
    }
示例#2
0
    public void RayShoot(int c)
    {
        if (c == 1)
        {
            StartCoroutine(ShotEffect(1));
        }

        //gets point at exact center of viewport
        Vector3    rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0));
        RaycastHit hit;

        laserLine[0].SetPosition(0, gunEnd1.position);

        if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, weaponRange))
        {
            laserLine[0].SetPosition(1, hit.point);
            //gets script from hit object
            StrongDemon enemyCollider = hit.collider.transform.GetComponentInParent <StrongDemon>();
            //StrongDemon enemyCollider = hit.collider.GetComponent<StrongDemon>();
            FastDemon  enemyCollider2 = hit.collider.transform.GetComponentInParent <FastDemon>();
            RangeDemon enemyCollider3 = hit.collider.GetComponent <RangeDemon>();
            //DemonController demonController = hit.collider.GetComponent<DemonController>();

            //checks if there is a shootablebox script
            if (enemyCollider != null)
            {
                //spawn blood particle fx at location of the hit.
                GameEvents.ReportEnemyHit();
                StartCoroutine(HitTargetIndicator());

                if (hit.collider.CompareTag("Enemy"))
                {
                    enemyCollider.CurrentHealth -= _pShoot.currentDamage;

                    if (enemyCollider.hitVulnerable)
                    {
                        enemyCollider.HitActivate();
                    }

                    if (_pShoot.currentWeapon == 3 && enemyCollider.CurrentHealth > 0)
                    {
                        enemyCollider.HitActivate();
                    }
                }
                else if (hit.collider.CompareTag("EnemyHead"))
                {
                    enemyCollider.CurrentHealth -= _pShoot.currentDamage * 2;

                    if (_pShoot.currentWeapon == 3 && enemyCollider.CurrentHealth > 0)
                    {
                        enemyCollider.HitActivate();
                    }
                }
            }

            if (enemyCollider2 != null)
            {
                StartCoroutine(HitTargetIndicator());



                if (hit.collider.CompareTag("Enemy"))
                {
                    enemyCollider2.CurrentHealth -= _pShoot.currentDamage;
                    if (enemyCollider2.hitVulnerable)
                    {
                        // enemyCollider2.HitActivate();
                    }
                }

                else if (hit.collider.CompareTag("EnemyHead"))
                {
                    enemyCollider2.CurrentHealth -= _pShoot.currentDamage * 2;
                    if (enemyCollider2.hitVulnerable)
                    {
                        //enemyCollider2.HitActivate();
                    }
                }
            }

            if (enemyCollider3 != null)
            {
                enemyCollider3.CurrentHealth -= _pShoot.currentDamage;
                StartCoroutine(HitTargetIndicator());
            }

            if (hit.rigidbody != null)
            {
                //hit.normal is direction away from surface we hit
                //use -hit.normal to make the box move away from the surface it was hit * hitforce amount
                hit.rigidbody.AddForce(-hit.normal * hitForce);
            }
        }
        else
        {   //continue past point
            laserLine[0].SetPosition(1, rayOrigin + (fpsCam.transform.forward * weaponRange));
        }
    }