예제 #1
0
        public static Player_Input.PlayerInput getPlayerInput(ref ComboInfo combo_info, bool enable_attacks, bool enable_parry, bool enable_dodge, bool enable_laser)
        {
            Player_Input.PlayerInput input = Player_Input.PlayerInput.None;

            //check if player has inputed dash
            if (enable_dodge && (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0) && Input.GetButtonDown("Dodge"))
            {
                input |= Player_Input.PlayerInput.Dodge;
            }
            //otherwise input parry
            else if (enable_parry && (Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0) && Input.GetButtonDown("Dodge"))
            {
                input |= Player_Input.PlayerInput.Parry;
            }
            //otherwise check if left or right are inputed
            else if (Math.Abs(Input.GetAxis("Horizontal")) > 0.9)
            {
                input |= Player_Input.PlayerInput.Dash;
            }

            //check if jump is inputed
            if (Input.GetButtonDown("Jump"))
            {
                input |= Player_Input.PlayerInput.Jump;
            }

            //check if attack is inputted
            if (enable_attacks && Input.GetButtonDown("Attack"))
            {
                input |= Player_Input.PlayerInput.Attack;
            }
            //check if laser is inputted
            if (enable_laser && Input.GetButtonDown("SpecialAttack1") && combo_info.canFireLaser())
            {
                input |= Player_Input.PlayerInput.Attack;
                input |= Player_Input.PlayerInput.Special_attack_0;
            }

            return(input);
        }
예제 #2
0
        public void fire_laser(Vector3 position, bool is_enemy, Vector3 direction, float radius, float max_distance)

        {
            RaycastHit hit            = new RaycastHit();
            Vector3    norm_direction = (new Vector3(direction.x - position.x, direction.y - position.y, direction.z - position.z)).normalized;
            bool       successful_hit = false;

            //determine direction of laser fire

            if (!is_enemy && combo_info.canFireLaser())
            {
                combo_info.decreaseComboPoints(500f);
            }
            //not enough points to fire laser
            else if (!is_enemy)
            {
                return;
            }
            AudioManager.instance.Play("LASER FIRE 1");

            //check collision with enemies
            if (!is_enemy && Physics.SphereCast(position, radius, norm_direction, out hit, max_distance, LayerMask.GetMask("EnemyHitbox")))
            {
                boss_health_info.doDamage(100);
                boss_health_info.setInvincible(0.4f);
                successful_hit = true;
            }
            //check collision with player
            else if (is_enemy && Physics.SphereCast(position, radius, norm_direction, out hit, max_distance, LayerMask.GetMask("PlayerHitbox")))
            {
                if (player_health_info.parry_ready)
                {
                    player_health_info.setParrySuccess(true);
                }
                else
                {
                    player_health_info.doDamage(50);
                    player_health_info.setInvincible(0.5f);

                    player_Controller.apply_knockback(enemy1_Controller.get_knockback_direction(), 50);
                }
                successful_hit = true;
            }
            //create laser visual
            GameObject laser_visual = new GameObject();

            laser_visual.transform.position = position;
            LineRenderer line_renderer = laser_visual.AddComponent <LineRenderer>();// A simple 2 color gradient with a fixed alpha of 1.0f.

            line_renderer.material   = new Material(Shader.Find("Sprites/Default"));
            line_renderer.startColor = Color.red;
            line_renderer.endColor   = Color.red;
            line_renderer.SetPosition(0, position);
            float distance;

            if (successful_hit)
            {
                distance = hit.distance;
            }
            else
            {
                distance = max_distance;
            }

            line_renderer.SetPosition(1, position + norm_direction * distance);

            line_renderer.widthMultiplier = radius;
            Destroy(laser_visual, 0.15f);
        }
        private void update_indicators()
        {
            if (enable_dodge)
            {
                if (cooldown_manager.dodge_ready && state_controller.cooldown_timers[0].Value > 0)
                {
                    cooldown_manager.dodge_ready = false;
                }
                else if (!cooldown_manager.dodge_ready && state_controller.cooldown_timers[0].Value <= 0)
                {
                    cooldown_manager.dodge_ready = true;
                }
            }

            if (enable_laser)
            {
                if (cooldown_manager.laser_ready && (state_controller.cooldown_timers[1].Value > 0 || !combo_info.canFireLaser()))
                {
                    cooldown_manager.laser_ready = false;
                }
                else if (!cooldown_manager.laser_ready && state_controller.cooldown_timers[1].Value <= 0 && combo_info.canFireLaser())
                {
                    cooldown_manager.laser_ready = true;
                }
            }
        }