コード例 #1
0
    public void FireActiveGun(bool fire)
    {
        if (activeGun == null || uiViewSprite == null)
        {
            return;
        }

        activeGun.ToggleFiring(fire);
        uiViewSprite.ToggleFiring(activeGun.firing);

        if (activeGun.BulletFiredOnFrame())
        {
            inventoryUpdated = true;
            uiViewSprite.Fire();
        }
    }
コード例 #2
0
    void Act()
    {
        movementController.SetMovementVector(Vector3.zero);

        if (state == EnemyState.Sleep)
        {
            weapon.ToggleFiring(false);
            if (meleeWeapon != null)
            {
                meleeWeapon.ToggleFiring(false);
            }

            Sleep();
        }
        else if (state == EnemyState.Dead)
        {
            DETH();
        }
        else if (state == EnemyState.Injured)
        {
            animator.ChangeAnimation("hit", true, false, injuryAnimationFPS, false);
        }
        else
        {
            UpdateAggro();

            if (state == EnemyState.RangedAttack)
            {
                weapon.transform.LookAt(target.transform);
                UpdateDirection(false);

                if (!weapon.firing)
                {
                    animator.ChangeAnimation("sleep", true, false);
                    weapon.DisableShot(0.33f);
                }

                weapon.ToggleFiring(true);

                if (weapon.BulletFiredOnFrame())
                {
                    animator.ChangeAnimation("shoot", true, false, shootAnimationFPS);
                }
                //else
                //    animator.ChangeAnimation("sleep", true, false);
            }
            else if (state == EnemyState.MeleeAttack)
            {
                meleeWeapon.transform.LookAt(target.transform);
                UpdateDirection(false);
                meleeWeapon.ToggleFiring(true);

                if (meleeWeapon.BulletFiredOnFrame())
                {
                    animator.ChangeAnimation("melee", true, false, meleeAnimationFPS);
                }
                //else
                //    animator.ChangeAnimation("sleep", true, false);
            }
            else if (state == EnemyState.Chase)
            {
                weapon.ToggleFiring(false);

                if (meleeWeapon != null)
                {
                    meleeWeapon.ToggleFiring(false);
                }

                UpdateDirection(true);
                Move();
            }
        }
    }