Example #1
0
    public override void ControlCharacter()
    {
        //Debug.Log(state, Department.PLAYER, Color.PINK);
        curr_hp = health.GetCurrentHealth();

        // First check if you are alive
        if (curr_hp > 0)
        {
            //Check play breath audio
            base.CheckHealth(curr_hp, max_hp, "DaenerysBreathing");

            // Check if player is moving to block attacks/abilities
            if (!movement.IsMoving())
            {
                /* Player is alive */

                switch (state)
                {
                case State.IDLE:
                {
                    //Check For Input + It has to check if she's moving to block attack (¿?)
                    CheckAttack();
                    break;
                }

                case State.ATTACKING:
                {
                    AttackLeftTimer += Time.deltaTime;
                    //Check for end of the Attack animation
                    if (anim_controller.IsAnimationStopped("Idle"))
                    {
                        if (anim_controller.IsAnimOverXTime(0.6f) && play_audio_roar)
                        {
                            GameObject flamethr = Instantiate("CorrectDaenerysFireBreath");

                            flamethr.transform.SetPosition(GetFlameBreathPosition(curr_position));
                            flamethr.transform.SetRotation(flamethr.transform.GetRotation());

                            Fireball fballscript = flamethr.GetComponent <Fireball>();
                            fballscript.vfront = curr_forward;
                            fballscript.SetDamage(left_ability_dmg);
                            fballscript.SetDistance(left_ability_distance);

                            GameObject coll_object = PhysX.RayCast(curr_position, curr_forward, 254.0f);
                            if (coll_object != null)
                            {
                                coll_object.GetTag();
                                if (coll_object.CompareTag("Enemy"))
                                {
                                    fballscript.vfront = GetSecondaryForwardToEnemy(flamethr.transform.GetPosition(), coll_object.transform.GetPosition());
                                }
                            }
                            PlayFx("DaenerysDragonRoar");
                            play_audio_roar = false;
                        }

                        if (anim_controller.IsAnimationStopped("AttackLeft"))
                        {
                            state = State.IDLE;
                        }
                    }
                    else if (play_audio_roar == false)
                    {
                        state = State.IDLE;
                    }
                    if (AttackLeftTimer >= 1.35f)
                    {
                        state = State.IDLE;
                    }
                    break;
                }

                case State.FIRE_WALL:
                {
                    //Check for end of the Attack animation
                    if (anim_controller.IsAnimationStopped("Idle"))
                    {
                        if (set_fire_wall == false && anim_controller.IsAnimOverXTime(0.3f))
                        {
                            int tile_x, tile_y;
                            movement.GetPlayerPos(out tile_x, out tile_y);
                            Vector3 player_pos = player.GetComponent <Transform>().GetPosition();
                            player_pos.y -= 9.1f;
                            MovementController.Direction direction = movement.curr_dir;
                            switch (direction)
                            {
                            case MovementController.Direction.NORTH:
                            {
                                tile_y       -= 1;
                                player_pos.z -= 25.4f;
                                break;
                            }

                            case MovementController.Direction.SOUTH:
                            {
                                tile_y       += 1;
                                player_pos.z += 25.4f;
                                break;
                            }

                            case MovementController.Direction.EAST:
                            {
                                tile_x       += 1;
                                player_pos.x += 25.4f;
                                break;
                            }

                            case MovementController.Direction.WEST:
                            {
                                tile_x       -= 1;
                                player_pos.x -= 25.4f;
                                break;
                            }

                            default:
                            {
                                break;
                            }
                            }
                            //GET TILE POS!
                            GameObject fire_wall = Instantiate("FireWall");
                            fire_wall.transform.SetPosition(player_pos);
                            FireWall fire_wall_controller = fire_wall.GetComponent <FireWall>();
                            fire_wall_controller.SetTiles(tile_x, tile_y);
                            fire_wall_controller.SetDamage(right_ability_dmg);
                            set_fire_wall = true;
                        }

                        if (anim_controller.IsAnimOverXTime(0.8f))
                        {
                            state = State.IDLE;
                        }
                    }
                    else if (set_fire_wall == true && IsAnimationStopped("AttackRight"))
                    {
                        state = State.IDLE;
                    }
                    break;
                }

                case State.HIT:
                {
                    //Check for end of the Attack animation
                    if (anim_controller.IsAnimationStopped("Hit"))
                    {
                        state = State.IDLE;
                    }
                    break;
                }

                case State.DEAD:
                {
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }
    }
Example #2
0
    //------------------------------
    //RIGHT ARM --------------------

    public bool OnRightClick()
    {
        // Check if player is in Idle State
        if (GetState() == 0)
        {
            // Check if player has enough mana to perform its attack
            int tile_x, tile_y;
            movement.GetPlayerPos(out tile_x, out tile_y);
            MovementController.Direction direction = movement.curr_dir;
            switch (direction)
            {
            case MovementController.Direction.NORTH:
            {
                tile_y -= 1;
                break;
            }

            case MovementController.Direction.SOUTH:
            {
                tile_y += 1;
                break;
            }

            case MovementController.Direction.EAST:
            {
                tile_x += 1;
                break;
            }

            case MovementController.Direction.WEST:
            {
                tile_x -= 1;
                break;
            }

            default:
            {
                break;
            }
            }
            if (movement.CheckIsWalkable(tile_x, tile_y) && !movement.CheckIsValyrianFire(tile_x, tile_y))
            {
                float mana_cost = right_ability_cost * max_mana / 100.0f;
                if (CanWasteMana(mana_cost))
                {
                    //Check if the ability is not in cooldown
                    if (!cd_right.in_cd)
                    {
                        SetState(State.FIRE_WALL);

                        // First, OnClick of RightWeapon, then, onClick of Cooldown
                        DoRightAbility();

                        // Set Animation
                        Global_Camera.GetComponent <CompAnimation>().PlayAnimationNode("D_Firewall");
                        anim_controller.PlayAnimationNode("AttackRight");

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    if (characters_manager.daenerys_tired == false)
                    {
                        PlayFx("DaenerysTired");
                        characters_manager.daenerys_tired = true;
                    }
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        return(false);
    }
Example #3
0
    protected override void InCombatDecesion()
    {
        //Attack action
        if (InRange())
        {
            bool attack_ready = attack_timer >= attack_cooldown;

            if (!GetComponent <Movement_Action>().LookingAtPlayer())
            {
                current_action.Interupt();
                next_action = GetComponent <FacePlayer_Action>();
                return;
            }

            else if (shield_block_timer >= shield_block_cd && player.GetComponent <CharactersManager>().GetCurrentCharacterName() == "Jaime")
            {
                MovementController.Direction player_dir = GetLinkedObject("player_obj").GetComponent <MovementController>().GetPlayerDirection();
                Movement_Action.Direction    enemy_dir  = GetComponent <Movement_Action>().SetDirection();
                if (player_dir == MovementController.Direction.NORTH && enemy_dir == Movement_Action.Direction.DIR_SOUTH ||
                    player_dir == MovementController.Direction.SOUTH && enemy_dir == Movement_Action.Direction.DIR_NORTH ||
                    player_dir == MovementController.Direction.EAST && enemy_dir == Movement_Action.Direction.DIR_WEST ||
                    player_dir == MovementController.Direction.WEST && enemy_dir == Movement_Action.Direction.DIR_EAST)
                {
                    next_action = GetComponent <ShieldBlock_Action>();
                }
                return;
            }

            else if (attack_ready)
            {
                attack_timer = 0.0f;
                state        = AI_STATE.AI_ATTACKING;
                Attack_Action action = GetComponent <Attack_Action>();
                action.SetDamage(attack_damage);
                current_action = action;
                current_action.ActionStart();
                return;
            }
            else
            {
                state          = AI_STATE.AI_IDLE;
                current_action = GetComponent <IdleAttack_Action>();
                current_action.ActionStart();
                return;
            }
        }
        else if (player_detected == true && Disable_Movement_Gameplay_Debbuger == false)
        {
            if (player.GetComponent <CharactersManager>().GetCurrentCharacterName() == "Jaime")
            {
                GetComponent <ChasePlayer_Action>().SetBlocking(false);
                GetComponent <ChasePlayer_Action>().ActionStart();
                current_action = GetComponent <ChasePlayer_Action>();
            }
            else
            {
                GetComponent <ChasePlayer_Action>().SetBlocking(true);
                GetComponent <ChasePlayer_Action>().ActionStart();
                current_action = GetComponent <ChasePlayer_Action>();
            }

            return;
        }
    }