Example #1
0
    private void PlayerCharacterHandlerOnshoot(object sender, PlayerCharacterHandler.OnShootEventArgs e)
    {
        Vector3 quadPosition = e.gunEndPosition;
        Vector3 quadSize     = new Vector3(0.5f, 1f);
        float   rotation     = 0f;

        //ShellParticlesSystemHandlerx.Instance.SpawnShell(quadPosition, new  Vector3(1,1));
        //int spawnedQuadIndex = AddQuad(quadPosition, rotation, quadSize, true, 0);

        //FunctionUpdater.Create(() =>
        //{
        //    quadPosition += new Vector3(1, 1) * 3f * Time.deltaTime;
        //    quadSize += new Vector3(1, 1) * Time.deltaTime;
        //    rotation += 180f * Time.deltaTime;
        //    UpdateQuad(spawnedQuadIndex, quadPosition, rotation, quadSize, true, 0);

        //});
    }
    public void PlayerCharacterHandlerOnShoot(object sender, PlayerCharacterHandler.OnShootEventArgs e)
    {
        UtilsClass.ShakeCamera(0.5f, 0.25f);

        Vector3 quadPosition = e.gunEndPosition;
        Vector3 quadSize     = new Vector3(0.5f, 1f);

        DmgPopupPos.Set(playerDamagePopupPlace.position.x, playerDamagePopupPlace.position.y, playerDamagePopupPlace.position.z);

        CreateWeaponTracer(e.gunEndPosition, e.shootPosition);
        CreateShootFlash(e.gunEndPosition);

        ShellParticleSystemHandler.Instance.SpawnShell(quadPosition, new Vector3(1, 1));

        RaycastHit2D raycastHit = Physics2D.Raycast(e.gunEndPosition,
                                                    (e.shootPosition - e.gunEndPosition).normalized,
                                                    Vector3.Distance(e.gunEndPosition, e.shootPosition));

        if (raycastHit.collider != null)
        {
            EnemyHealth enemyHealth = raycastHit.collider.GetComponent <EnemyHealth>();
            isFollowing = true;
            StartCoroutine(WaitAfterFollowing());
            if (enemyHealth != null)
            {
                //Hit enemy
                int  DamageAmount = UnityEngine.Random.Range(10, 100);
                bool isCritical   = UnityEngine.Random.Range(0, 100) < 30;
                if (isCritical)
                {
                    DamageAmount *= 2;
                }
                //Deal Dmg
                enemyHealth.TakeDamage(DamageAmount);
                DamagePopupScript.Create(DmgPopupPos, DamageAmount, isCritical);
            }
        }
    }