コード例 #1
0
    protected virtual void Start()
    {
        player = GetLinkedObject("player_obj");
        health = GetLinkedObject("health_obj").GetComponent <Hp>();

        stamina       = GetLinkedObject("stamina_obj").GetComponent <Stamina>();
        stamina_img   = stamina.GetComponent <CompImage>();
        leftamina_img = GetLinkedObject("leftamina_bar").GetComponent <CompImage>();

        mana          = GetLinkedObject("mana_obj").GetComponent <Mana>();
        mana_img      = mana.GetComponent <CompImage>();
        left_mana_img = GetLinkedObject("leftmana_bar").GetComponent <CompImage>();

        audio    = player.GetComponent <CompAudio>();
        movement = player.GetComponent <MovementController>();

        anim_controller = GetComponent <CompAnimation>();
        damage_feedback = player.GetComponent <DamageFeedback>();

        characters_manager = player.GetComponent <CharactersManager>();
        enemy_manager      = GetLinkedObject("player_enemies_manager").GetComponent <EnemiesManager>();

        play_breathing_audio      = false;
        currently_playing_b_audio = false;
        force_audio = false;
    }
コード例 #2
0
    public override bool ActionStart()
    {
        anim  = GetComponent <CompAnimation>();
        audio = GetComponent <CompAudio>();
        move  = GetComponent <Movement_Action>();

        movement_ctrl      = GetLinkedObject("player_obj").GetComponent <MovementController>();
        characters_manager = GetLinkedObject("player_obj").GetComponent <CharactersManager>();
        state  = BWA_STATE.PRE_APPLY;
        target = GetLinkedObject("target");
        player = target.GetComponent <CharactersManager>();

        if (player == null)
        {
            Debug.Log("[error] Attack Action Start: Player is null!");
        }

        if (player.dying == false)
        {
            state = BWA_STATE.PRE_APPLY;
            Debug.Log("Wide attack anim play", Department.IA);
            GetComponent <CompAnimation>().PlayAnimationNode("WideAttack");
            GetComponent <CompAnimation>().SetClipDuration("WideAttack", preparation_time / apply_damage_point);
            GetComponent <CompAudio>().PlayEvent("AttackPreparation");
        }

        return(true);
    }
コード例 #3
0
    void Start()
    {
        level_map = GetLinkedObject("map_obj").GetComponent <LevelMap>();

        char_manager           = GetComponent <CharactersManager>();
        characters_camera      = GetLinkedObject("characters_camera");
        player_enemies_manager = GetLinkedObject("player_enemies_manager");

        Audio.StopAllSounds();
        audio = GetComponent <CompAudio>();

        audio.PlayEvent("PlayMusic");
        Audio.ChangeState("MusicState", "None");

        curr_dir        = (Direction)start_direction;
        update_rotation = false;

        map_width  = Map.GetWidthMap();
        map_height = Map.GetHeightMap();

        endPosition = GetComponent <Transform>().local_position;
        endRotation = GetComponent <Transform>().local_rotation;

        //SET PLAYER INTO THE CORRECT MAP TILE
        level_map.GetPositionByeValue(out curr_x, out curr_y, 2); //2 = player start position
        level_map.UpdateMap(curr_x, curr_y, 0);
        MovePositionInitial(new Vector3((float)curr_x * distanceToMove, GetComponent <Transform>().local_position.y, (float)curr_y * distanceToMove));

        drowning = false;
    }
コード例 #4
0
    public override bool ActionStart()
    {
        player = GetLinkedObject("target").GetComponent <CharactersManager>();

        if (player == null)
        {
            Debug.Log("[error] Attack Action Start: Player is null!");
        }

        anim_comp  = GetComponent <CompAnimation>();
        audio_comp = GetComponent <CompAudio>();

        if (player.dying == false)
        {
            anim_comp.SetClipDuration("Attack", attack_duration);
            anim_comp.PlayAnimationNode("Attack");
            Debug.Log("Back to Attack", Department.IA);
            audio_comp.PlayEvent("Enemy1_Slash");
        }


        damage_done   = false;
        shield_attack = false;

        //Interrupt player action
        return(true);
    }
コード例 #5
0
    void Start()
    {
        audio = GetComponent <CompAudio>();

        Vector3 global_pos = transform.GetGlobalPosition();

        Debug.Log(global_pos);
        tile_x = (int)((global_pos.x + (12.7f)) / 25.4);
        tile_z = (int)((global_pos.z + (12.7f)) / 25.4);

        if (trap_walkable)
        {
            global_pos.y = min_height;
            value        = 0;
        }
        else
        {
            global_pos.y = max_height;
            value        = 1;
        }
        GetComponent <Transform>().SetGlobalPosition(global_pos);
        Debug.Log(global_pos);
        map = GetLinkedObject("map_obj");
        LevelMap map_level = map.GetComponent <LevelMap>();

        if (map_level != null)
        {
            map_level.UpdateMap(tile_x, tile_z, value);
        }

        curr_state = CHANGE_STATE.TRAP_IDLE;
    }
コード例 #6
0
    void Start()
    {
        audio = GetComponent <CompAudio>();

        Vector3 global_pos = transform.GetGlobalPosition();

        door_pos_x = (int)((global_pos.x + (12.7f)) / 25.4);
        door_pos_y = (int)((global_pos.z + (12.7f)) / 25.4);

        if (door_closed)
        {
            Vector3 pos = GetComponent <Transform>().GetPosition();
            if (pos.y != min_height)
            {
                pos.y = min_height;
                GetComponent <Transform>().SetPosition(pos);
            }
            GetLinkedObject("map_obj").GetComponent <LevelMap>().UpdateMap(door_pos_x, door_pos_y, 1);
        }
        else
        {
            Vector3 pos = GetComponent <Transform>().GetPosition();
            if (pos.y != max_height)
            {
                pos.y = max_height;
                GetComponent <Transform>().SetPosition(pos);
            }
            GetLinkedObject("map_obj").GetComponent <LevelMap>().UpdateMap(door_pos_x, door_pos_y, 0);
        }

        temp_bt_sw = Enemy_connected.GetComponent <EnemySword_BT>();
        temp_bt_sp = Enemy_connected.GetComponent <EnemySpear_BT>();
        temp_bt_sh = Enemy_connected.GetComponent <EnemyShield_BT>();
    }
コード例 #7
0
    void OnTriggerEnter()
    {
        Debug.Log("REVERB ON", Department.STAGE, Color.YELLOW);
        col = GetComponent <CompCollider>();
        GameObject col_obj   = col.GetCollidedObject();
        CompAudio  col_audio = null;

        if (col_obj != null)
        {
            col_audio = col_obj.GetComponent <CompAudio>();
        }
        else
        {
            Debug.Log("COL_OBJ IS NULL!", Department.STAGE, Color.RED);
        }

        if (col_audio != null)
        {
            Debug.Log(in_value);
            col_audio.SetAuxiliarySends(bus_name, in_value);
        }
        else
        {
            Debug.Log("COL_AUDIO IS NULL!", Department.STAGE, Color.RED);
        }
    }
コード例 #8
0
 void Start()
 {
     audio = GetComponent <CompAudio>();
     if (audio == null)
     {
         Debug.Log("[error] There is no audio comp in puzzle!");
     }
 }
コード例 #9
0
 public override bool ActionStart()
 {
     comp_animation = GetComponent <CompAnimation>();
     comp_audio     = GetComponent <CompAudio>();
     comp_animation.PlayAnimationNode("Draw");
     comp_animation.SetClipDuration("Draw", duration);
     return(true);
 }
コード例 #10
0
    void Start()
    {
        map    = GetLinkedObject("map");
        player = GetLinkedObject("player");

        align          = GetComponent <Align_Steering>();
        arrive         = GetComponent <Arrive_Steering>();
        seek           = GetComponent <Seek_Steering>();
        anim_comp      = GetComponent <CompAnimation>();
        transform_comp = GetComponent <Transform>();
        audio_comp     = GetComponent <CompAudio>();

        player_t = GetLinkedObject("player_obj");

        BT bt = GetComponent <EnemySword_BT>();

        if (bt == null)
        {
            bt = GetComponent <EnemyShield_BT>();
        }
        if (bt == null)
        {
            bt = GetComponent <EnemySpear_BT>();
        }
        if (bt == null)
        {
            bt = GetComponent <Boss_BT>();
        }

        float interpolation = bt.GetCurrentInterpolation();

        current_max_vel       = hurt_max_vel + (max_vel - hurt_max_vel) * interpolation;
        current_max_accel     = hurt_accel + (max_accel - hurt_accel) * interpolation;
        current_max_rot_vel   = hurt_max_rot_vel + (max_rot_vel - hurt_max_rot_vel) * interpolation;
        current_max_rot_accel = hurt_max_rot_accel + (max_rot_accel - hurt_max_rot_accel) * interpolation;

        Vector3 fw = transform_comp.GetForwardVector();

        path = new List <PathNode>();

        //Set Occupied tile in Pathfinder
        tile = new PathNode(0, 0);
        tile.SetCoords((int)(transform_comp.position.x / tile_size + Mathf.Epsilon), (int)(transform_comp.position.z / tile_size + Mathf.Epsilon));
        map.GetComponent <Pathfinder>().UpdateOccupiedTiles(gameObject.GetName(), tile);

        //Set direction
        SetDirection();

        //Sideways animation speeds
        anim_comp.SetClipDuration("WalkRight", sideways_anim_speed);
        anim_comp.SetClipDuration("WalkLeft", sideways_anim_speed);
        anim_comp.SetClipDuration("WalkBack", sideways_anim_speed);
        anim_comp.SetClipDuration("WalkFront", sideways_anim_speed);

        blocking = false;

        path.Clear();
    }
コード例 #11
0
    void Start()
    {
        rb    = GetComponent <CompRigidBody>();
        audio = GetComponent <CompAudio>();
        Shoot();
        collision = true;

        audio.PlayEvent("DaenerysFireballImpact");
    }
コード例 #12
0
    void Start()
    {
        audio = GetComponent <CompAudio>();
        //col = GetComponent<CompCollider>();
        timeToNextFloatAnim = floatingPeriod;

        wait_time = Random.Range(0.0f, 1.0f);
        wait_time = wait_time * random_wait;
    }
コード例 #13
0
 public void StartCountdown()
 {
     current_time = initial_time;
     active       = true;
     state        = 1;
     Audio.ChangeState("PuzzleCountDownState", "State1");
     audio = GetComponent <CompAudio>();
     audio.PlayEvent("StartPuzzleCountdown");
 }
コード例 #14
0
    void OnTriggerLost()
    {
        Debug.Log("[green] REVERB OUT");
        GameObject col_obj = col.GetCollidedObject();

        CompAudio col_audio = col_obj.GetComponent <CompAudio>();

        if (col_audio != null)
        {
            col_audio.SetAuxiliarySends(bus_name, out_value);
        }
    }
コード例 #15
0
    public override bool ActionStart()
    {
        anim_comp  = GetComponent <CompAnimation>();
        audio_comp = GetComponent <CompAudio>();

        anim_comp.PlayAnimationNode("Die");
        //TODO_AI: Die audio
        audio_comp.PlayEvent("Enemy_SwordDrop");

        //PLAY COMBAT MUSIC
        Audio.ChangeState("MusicState", "None");
        GetLinkedObject("event_manager").GetComponent <PerceptionManager>().player_seen = false;
        Debug.Log("COMBAT OFF", Department.PLAYER, Color.BLUE);

        StatsScore.KillEnemy();

        //Play Dead Audio
        if (GetComponent <EnemyShield_BT>() != null)
        {
            audio_comp.PlayEvent("Enemy3_Dead");
        }
        else if (GetComponent <EnemySpear_BT>() != null)
        {
            audio_comp.PlayEvent("Enemy2_Dead");
        }
        else if (GetComponent <EnemySword_BT>() != null)
        {
            audio_comp.PlayEvent("Enemy1_Dead");
        }

        //Deactivate Listener
        if (GetComponent <SpearGuard_Listener>() != null)
        {
            GetComponent <SpearGuard_Listener>().SetEnabled(false);
        }
        else if (GetComponent <ShieldGuard_Listener>() != null)
        {
            GetComponent <ShieldGuard_Listener>().SetEnabled(false);
        }
        else if (GetComponent <SwordGuard_Listener>() != null)
        {
            GetComponent <SwordGuard_Listener>().SetEnabled(false);
        }

        anim_comp.SetClipDuration("Die", duration);
        GetComponent <CompCollider>().CollisionActive(false);
        return(true);
    }
コード例 #16
0
    //2D coordinates, y=z in 3D coordinates

    void Start()
    {
        Audio.StopAllSounds();
        audio = GetComponent <CompAudio>();
        audio.PlayEvent("PlayMusic");
        curr_dir   = (Direction)start_direction;
        map_width  = Map.GetWidthMap();
        map_height = Map.GetHeightMap();
        array2Da   = new int[map_width, map_height];
        for (int y = 0; y < map_height; y++)
        {
            for (int x = 0; x < map_width; x++)
            {
                array2Da[x, y] = 0;
            }
        }
        //array2Da[0,0] = 1;
        endPosition = GetComponent <Transform>().local_position;
        endRotation = GetComponent <Transform>().local_rotation;

        string map = Map.GetMapString();
        int    t   = 0;

        for (int y = 0; y < map_height; y++)
        {
            for (int x = 0; x < map_width; x++)
            {
                array2Da[x, y] = int.Parse(map[t].ToString());
                t += 1;
            }
        }

        //Search player position
        for (int y = 0; y < map_height; y++)
        {
            for (int x = 0; x < map_width; x++)
            {
                if (array2Da[x, y] == 2)
                {
                    curr_x         = x;
                    curr_y         = y;
                    array2Da[x, y] = 0;
                    MovePositionInitial(new Vector3((float)curr_x * distanceToMove, GetComponent <Transform>().position.y, (float)curr_y * distanceToMove));
                }
            }
        }
    }
コード例 #17
0
    void OnTriggerLost()
    {
        Debug.Log("REVERB OUT", Department.STAGE, Color.RED);
        col = GetComponent <CompCollider>();
        GameObject col_obj   = col.GetCollidedObject();
        CompAudio  col_audio = null;

        if (col_obj != null)
        {
            col_audio = col_obj.GetComponent <CompAudio>();
        }
        if (col_audio != null)
        {
            Debug.Log("REVERB OUT", Department.STAGE);
            col_audio.SetAuxiliarySends(bus_name, out_value);
        }
    }
コード例 #18
0
    void Start()
    {
        lever_go = GetLinkedObject("lever_go");
        if (door_to_open1 != null)
        {
            door_to_open1 = GetLinkedObject("door_to_open1");
        }

        if (door_to_open2 != null)
        {
            door_to_open2 = GetLinkedObject("door_to_open2");
        }

        close_door_collider = GetLinkedObject("close_door_collider");

        audio = GetComponent <CompAudio>();
        if (audio == null)
        {
            Debug.Log("There is no audio in puzzle!");
        }


        anim_controller = lever_go.GetComponent <CompAnimation>();
        if (anim_controller == null)
        {
            Debug.Log("Animation is null!");
        }


        lever_interact = GetLinkedObject("lever_interact");
        if (lever_interact != null)
        {
            lever_interact.SetActive(false);
            Debug.Log("[green] Deactivated Interact");
        }

        lvl_player = GetLinkedObject("lvl_player");
        if (lvl_player != null)
        {
            movement_player = lvl_player.GetComponent <MovementController>();
        }

        // -------------------------------------------------------
    }
コード例 #19
0
 public override void Start()
 {
     in_combat = false;
     player    = GetLinkedObject("player");
     if (GetLinkedObject("player") == null)
     {
         Debug.Log("PLAYER NULL!!", Department.IA, Color.RED);
     }
     current_hp = total_hp;
     //Enemy starts with the attack loaded
     attack_timer = 0.0f;
     mesh         = GetLinkedObject("mesh");
     if (GetLinkedObject("mesh") == null)
     {
         Debug.Log("MESH NULL!!", Department.IA, Color.RED);
     }
     enemies_manager = GetLinkedObject("enemies_manager");
     if (GetLinkedObject("enemies_manager") == null)
     {
         Debug.Log("ENEMIES MANAGER NULL!!", Department.IA, Color.RED);
     }
     GetComponent <CompAnimation>().PlayAnimationNode("Idle");
     dmg_alpha = 0.0f;
     //ChangeTexturesToAlive();
     enemy_hp_bar = GetLinkedObject("enemy_hp_bar");
     if (GetLinkedObject("enemy_hp_bar") == null)
     {
         Debug.Log("HALTH BAR NULL!!", Department.IA, Color.RED);
     }
     if (enemy_hp_bar.GetComponent <CompImage>() == null)
     {
         Debug.Log("COMP IMAGE NULL!!", Department.IA, Color.RED);
     }
     enemy_hp_border = GetLinkedObject("enemy_hp_border");
     enemy_hp_bar.GetComponent <CompImage>().DeactivateRender();
     enemy_hp_border.GetComponent <CompImage>().DeactivateRender();
     hp_timer_total = 10.0f;
     hp_timer       = 0.0f;
     hud_active     = false;
     audio_comp     = GetComponent <CompAudio>();
     base.Start();
 }
コード例 #20
0
    void Start()
    {
        audio            = GetComponent <CompAudio>();
        childs_to_switch = new List <GameObject>();

        bool stop       = false;
        int  num_childs = 0;

        while (stop == false)
        {
            GameObject temp = gameObject.GetChildByTagIndex("trap_floor", num_childs++);
            if (temp == null)
            {
                stop = true;
            }
            else
            {
                childs_to_switch.Add(temp);
            }
        }
    }
コード例 #21
0
    public override void Start()
    {
        GameObject Temp_go = GetLinkedObject("enemies_manager");

        if (Temp_go == null)
        {
            Debug.Log("[error] Gameobject enemies_manager not found (EnemyShield_BT)");
        }
        else
        {
            EnemiesManager enemy_manager = Temp_go.GetComponent <EnemiesManager>();

            if (enemy_manager == null)
            {
                Debug.Log("[error] EnemyShield_BT: enemies_manager is not detected");
            }
            else
            {
                enemy_manager.AddShieldEnemy(gameObject);
            }
        }

        if (texture_type == 0)
        {
            enemy_mat_sword = GetMaterialByName("Alpha1_ShieldEnemy_Material_21_04");
        }
        else if (texture_type == 1)
        {
            enemy_mat_sword = GetMaterialByName("Alpha1_ShieldEnemy2_Material_21_04");
        }

        audio_comp  = GetComponent <CompAudio>();
        shield_name = GetLinkedObject("shield_name");

        base.Start();
        base.DeactivateHUD(shield_name);
    }
コード例 #22
0
    public override bool ActionStart()
    {
        state  = BASD_STATE.PRE_APPLY;
        target = GetLinkedObject("target");
        player = target.GetComponent <CharactersManager>();

        if (player == null)
        {
            Debug.Log("[error] Attack Action Start: Player is null!");
        }

        if (player.dying == false)
        {
            state = BASD_STATE.PRE_APPLY;
            Debug.Log("Play Sword down", Department.IA);
            GetComponent <CompAnimation>().PlayAnimationNode("SwordDownAttack");
            GetComponent <CompAnimation>().SetClipDuration("SwordDownAttack", preparation_time / apply_damage_point);
            audio = GetComponent <CompAudio>();
            GetComponent <CompAudio>().PlayEvent("AttackPreparation");
            ground_hit = false;
        }

        return(true);
    }
コード例 #23
0
    public override bool ActionStart()
    {
        interupt = false;

        /*CompAudio audio = GetComponent<CompAudio>();
         * audio.PlayEvent("Enemy2_Hurt");
         * audio.PlayEvent("SwordHit");*/
        move       = GetComponent <Movement_Action>();
        anim_comp  = GetComponent <CompAnimation>();
        audio_comp = GetComponent <CompAudio>();


        if (next_dmg_type == Enemy_BT.ENEMY_GET_DAMAGE_TYPE.DEFAULT)
        {
            int tile_x              = move.GetCurrentTileX();
            int tile_y              = move.GetCurrentTileY();
            int player_x            = tile_x;
            int player_y            = tile_y;
            MovementController temp = GetLinkedObject("player_obj").GetComponent <MovementController>();
            if (temp != null)
            {
                temp.GetPlayerPos(out int x, out int y);
                player_x = x;
                player_y = y;
            }

            int dif_x = player_x - tile_x;
            int dif_y = player_y - tile_y;

            Movement_Action.Direction dir = move.GetDirection();

            switch (dir)
            {
            case Movement_Action.Direction.DIR_EAST:
                if (dif_x < 0)
                {
                    animation_clip = "HitBack";
                    anim_comp.PlayAnimationNode("HitBack");
                }
                else if (dif_x > 0)
                {
                    animation_clip = "HitFront";
                    anim_comp.PlayAnimationNode("HitFront");
                }
                else if (dif_y < 0)
                {
                    animation_clip = "HitLeft";
                    anim_comp.PlayAnimationNode("HitLeft");
                }
                else if (dif_y > 0)
                {
                    animation_clip = "HitRight";
                    anim_comp.PlayAnimationNode("HitRight");
                }
                break;

            case Movement_Action.Direction.DIR_NORTH:
                if (dif_x < 0)
                {
                    animation_clip = "HitLeft";
                    anim_comp.PlayAnimationNode("HitLeft");
                }
                else if (dif_x > 0)
                {
                    animation_clip = "HitRight";
                    anim_comp.PlayAnimationNode("HitRight");
                }
                else if (dif_y < 0)
                {
                    animation_clip = "HitFront";
                    anim_comp.PlayAnimationNode("HitFront");
                }
                else if (dif_y > 0)
                {
                    animation_clip = "HitBack";
                    anim_comp.PlayAnimationNode("HitBack");
                }
                break;

            case Movement_Action.Direction.DIR_SOUTH:
                if (dif_x < 0)
                {
                    animation_clip = "HitRight";
                    anim_comp.PlayAnimationNode("HitRight");
                }
                else if (dif_x > 0)
                {
                    animation_clip = "HitLeft";
                    anim_comp.PlayAnimationNode("HitLeft");
                }
                else if (dif_y < 0)
                {
                    animation_clip = "HitBack";
                    anim_comp.PlayAnimationNode("HitBack");
                }
                else if (dif_y > 0)
                {
                    animation_clip = "HitFront";
                    anim_comp.PlayAnimationNode("HitFront");
                }
                break;

            case Movement_Action.Direction.DIR_WEST:
                if (dif_x < 0)
                {
                    animation_clip = "HitFront";
                    anim_comp.PlayAnimationNode("HitFront");
                }
                else if (dif_x > 0)
                {
                    animation_clip = "HitBack";
                    anim_comp.PlayAnimationNode("HitBack");
                }
                else if (dif_y < 0)
                {
                    animation_clip = "HitRight";
                    anim_comp.PlayAnimationNode("HitRight");
                }
                else if (dif_y > 0)
                {
                    animation_clip = "HitLeft";
                    anim_comp.PlayAnimationNode("HitLeft");
                }
                break;
            }
        }

        else if (next_dmg_type == Enemy_BT.ENEMY_GET_DAMAGE_TYPE.FIREWALL)
        {
            animation_clip = "HitFire";
            anim_comp.PlayAnimationNode("HitFire");
        }

        anim_comp.SetClipDuration(animation_clip, duration);
        //TODO_AI: Hurt audio
        //GetComponent<CompAudio>().PlayEvent("JaimeHurt");
        return(true);
    }
コード例 #24
0
    void Update()
    {
        int tile_mov_x = 0;
        int tile_mov_y = 0;

        start_direction = (int)curr_dir;

        CheckIsWalkable();

        if (GetComponent <Transform>().local_position == endPosition && rotating == false)
        {
            if (Input.GetKeyDown(KeyCode.Q)) //Left
            {
                actual_angle = 0;
                angle        = -10;
                rotating     = true;
                ModificateCurrentDirection(true);
            }
            if (Input.GetKeyDown(KeyCode.E)) //Right
            {
                actual_angle = 0;
                angle        = 10;
                rotating     = true;
                ModificateCurrentDirection(false);
            }

            if (Input.GetKeyDown(KeyCode.A)) //Left
            {
                audio = GetComponent <CompAudio>();
                audio.PlayEvent("Footsteps");
                MoveLeft(out tile_mov_x, out tile_mov_y);
            }
            else if (Input.GetKeyDown(KeyCode.D)) //Right
            {
                audio = GetComponent <CompAudio>();
                audio.PlayEvent("Footsteps");
                MoveRight(out tile_mov_x, out tile_mov_y);
            }
            else if (Input.GetKeyDown(KeyCode.W)) //Up
            {
                audio = GetComponent <CompAudio>();
                audio.PlayEvent("Footsteps");
                MoveForward(out tile_mov_x, out tile_mov_y);
            }
            else if (Input.GetKeyDown(KeyCode.S)) //Down
            {
                audio = GetComponent <CompAudio>();
                audio.PlayEvent("Footsteps");
                MoveBackward(out tile_mov_x, out tile_mov_y);
            }

            //Calculate endPosition
            if ((tile_mov_x != 0 || tile_mov_y != 0) && array2Da[curr_x + tile_mov_x, curr_y + tile_mov_y] == 0)
            {
                endPosition = new Vector3(GetComponent <Transform>().local_position.x + distanceToMove * (float)tile_mov_x, GetComponent <Transform>().local_position.y, GetComponent <Transform>().local_position.z + distanceToMove * (float)tile_mov_y);
                curr_x     += tile_mov_x;
                curr_y     += tile_mov_y;
            }
        }
        else if (rotating)
        {
            GetComponent <Transform>().RotateAroundAxis(Vector3.Up, angle * speed_rotation * Time.deltaTime);
            float moved_angle = (float)angle * speed_rotation * Time.deltaTime;
            if (angle < 0)
            {
                actual_angle += (moved_angle * -1);
            }
            else
            {
                actual_angle += moved_angle;
            }

            if (actual_angle >= 90)
            {
                rotating = false;
                if (actual_angle > 90)
                {
                    float marge = actual_angle - 90;
                    if (angle < 0)
                    {
                        GetComponent <Transform>().RotateAroundAxis(Vector3.Up, marge);
                    }
                    else
                    {
                        GetComponent <Transform>().RotateAroundAxis(Vector3.Up, -marge);
                    }
                }
            }
        }
        else
        {
            GetComponent <Transform>().local_position = Vector3.MoveTowards(GetComponent <Transform>().local_position, endPosition, movSpeed * Time.deltaTime);
        }
    }
コード例 #25
0
    //--------------

    void Start()
    {
        tile_size = 25.4f;

        lever_go = GetLinkedObject("lever_go");

        audio = GetComponent <CompAudio>();
        if (audio == null)
        {
            Debug.Log("[error] There is no audio in puzzle!");
        }

        countdown = GetComponent <PuzzleCountdown>();
        if (countdown == null)
        {
            Debug.Log("[error] There is no countdown in puzzle!");
        }

        anim_controller = lever_go.GetComponent <CompAnimation>();
        if (anim_controller == null)
        {
            Debug.Log("[error] Animation is null!");
        }

        barrel_puzzel_manager = GetComponent <BarrelPuzzleManager>();
        if (barrel_puzzel_manager == null)
        {
            Debug.Log("[error] Animation is null!");
        }

        Puzzle_line_1 = GetLinkedObject("Puzzle_line_1");
        Puzzle_line_2 = GetLinkedObject("Puzzle_line_2");
        Puzzle_line_3 = GetLinkedObject("Puzzle_line_3");
        Puzzle_line_4 = GetLinkedObject("Puzzle_line_4");
        Puzzle_line_5 = GetLinkedObject("Puzzle_line_5");
        Puzzle_line_6 = GetLinkedObject("Puzzle_line_6");

        line1 = new List <GameObject>();
        line2 = new List <GameObject>();
        line3 = new List <GameObject>();
        line4 = new List <GameObject>();
        line5 = new List <GameObject>();
        line6 = new List <GameObject>();

        // Get All barrels from Puzzle.
        SetBarrels();

        // Desactivate all barrels, while the player dont stay in puzzle.
        DesactivateBarrels(line1);
        DesactivateBarrels(line2);
        DesactivateBarrels(line3);
        DesactivateBarrels(line4);
        DesactivateBarrels(line5);
        DesactivateBarrels(line6);

        // Map
        current_path = new Path(barrel_per_line, number_lines, puzzle_orientation);
        GeneratePath();

        lever_interact = GetLinkedObject("lever_interact");

        lever_interact.SetActive(false);

        if (other_lever_1 != null)
        {
            other_lever_1 = GetLinkedObject("other_lever_1");
        }
        if (other_lever_2 != null)
        {
            other_lever_2 = GetLinkedObject("other_lever_2");
        }

        chain_line_1 = GetLinkedObject("chain_line_1");
        chain_line_2 = GetLinkedObject("chain_line_2");
        chain_line_3 = GetLinkedObject("chain_line_3");
        chain_line_4 = GetLinkedObject("chain_line_4");
        chain_line_5 = GetLinkedObject("chain_line_5");
        chain_line_6 = GetLinkedObject("chain_line_6");

        chains_1 = new List <GameObject>();
        chains_2 = new List <GameObject>();
        chains_3 = new List <GameObject>();
        chains_4 = new List <GameObject>();
        chains_5 = new List <GameObject>();
        chains_6 = new List <GameObject>();

        // Get All Chains from Puzzle.
        SetChains();

        //// Testing --------------------------------------------
        //for (int y = 0; y < number_lines; y++)
        //{
        //    for (int x = 0; x < barrel_per_line; x++)
        //    {
        //        current_path.walkability[x, y] = 0;
        //    }
        //}

        //current_path.walkability[4, 0] = 1;
        //current_path.walkability[4, 1] = 1;
        //current_path.walkability[4, 2] = 1;
        //current_path.walkability[4, 3] = 1;
        //current_path.walkability[5, 3] = 1;
        //current_path.walkability[5, 4] = 1;
        //current_path.walkability[5, 5] = 1;



        // -------------------------------------------------------
    }
コード例 #26
0
    void Update()
    {
        start_direction = (int)curr_dir;

        //Update Forward Vector for rotations
        if (update_rotation)
        {
            update_rotation = false;
            char_manager.SetCurrentPosition();
        }

        if (Input.GetKeyRepeat(KeyCode.Num9) && Input.GetKeyRepeat(KeyCode.Num8) && Input.GetKeyRepeat(KeyCode.Q) && Input.GetKeyRepeat(KeyCode.E) && Input.GetKeyRepeat(KeyCode.Space))
        {
            Audio.prank = true;
        }

        CheckIsWalkable();

        if (GetComponent <Transform>().local_position == endPosition && rotating == false && face_rotating == false && char_manager.GetManagerState() != CharactersManager.State.DROWNING && push == false)
        {
            moving = false;

            // CHECK ROTATION --------------------------
            if (!CheckRotation())
            {
                // CHECK MOVEMENT --------------------------
                CheckMovement();
            }

            // CHECK FACING --------------------------
            //CheckFacingRotation();

            //Calculate endPosition
            if ((tile_mov_x != 0 || tile_mov_y != 0))
            {
                Debug.Log("GOING TO MOVE", Department.PLAYER, Color.RED);

                if (level_map[curr_x + tile_mov_x, curr_y + tile_mov_y] == 0)
                {
                    audio = GetComponent <CompAudio>();
                    audio.PlayEvent("Footsteps");
                    endPosition = new Vector3(GetComponent <Transform>().local_position.x + distanceToMove * (float)tile_mov_x, GetComponent <Transform>().local_position.y, GetComponent <Transform>().local_position.z + distanceToMove * (float)tile_mov_y);
                    curr_x     += tile_mov_x;
                    curr_y     += tile_mov_y;
                    char_manager.SetCurrentPosition();
                    moving = true;
                }
                else if (level_map[curr_x + tile_mov_x, curr_y + tile_mov_y] == 3) //Valryian Fire!
                {
                    audio = GetComponent <CompAudio>();
                    audio.PlayEvent("Footsteps");
                    endPosition = new Vector3(GetComponent <Transform>().local_position.x + distanceToMove * (float)tile_mov_x, GetComponent <Transform>().local_position.y, GetComponent <Transform>().local_position.z + distanceToMove * (float)tile_mov_y);
                    curr_x     += tile_mov_x;
                    curr_y     += tile_mov_y;
                    char_manager.SetCurrentPosition();
                    moving = true;

                    if (GetLinkedObject("player_obj").GetComponent <CharactersManager>().god_mode == false)
                    {
                        GetComponent <CompRigidBody>().UnLockMotion();
                        GetComponent <CompRigidBody>().ApplyImpulse(new Vector3(0.0f, -50.0f, 0.0f));
                        //char_manager.Drown();
                        drowning = true;
                    }
                }
            }

            tile_mov_x = 0;
            tile_mov_y = 0;
        }
        else if (push == true)
        {
            GetComponent <Transform>().local_position = Vector3.MoveTowards(GetComponent <Transform>().local_position, endPosition, movSpeed * Time.deltaTime);
            if (GetComponent <Transform>().local_position == endPosition)
            {
                push = false;
            }
        }
        else if (rotating)
        {
            moving = false;
            GetComponent <Transform>().RotateAroundAxis(Vector3.Up, angle * speed_rotation * Time.deltaTime);
            float moved_angle = (float)angle * speed_rotation * Time.deltaTime;
            if (angle < 0)
            {
                actual_angle += (moved_angle * -1);
            }
            else
            {
                actual_angle += moved_angle;
            }

            if (actual_angle >= 90)
            {
                rotating = false;
                if (actual_angle > 90)
                {
                    float marge = actual_angle - 90;
                    if (angle < 0)
                    {
                        GetComponent <Transform>().RotateAroundAxis(Vector3.Up, marge);
                    }
                    else
                    {
                        GetComponent <Transform>().RotateAroundAxis(Vector3.Up, -marge);
                    }
                }
                update_rotation = true;
            }
        }
        else if (face_rotating)
        {
            moving = false;
            GetComponent <Transform>().RotateAroundAxis(Vector3.Left, face_angle * face_speed_rotation * Time.deltaTime);
            float moved_angle = (float)face_angle * face_speed_rotation * Time.deltaTime;

            if (angle < 0)
            {
                actual_facing_angle += (moved_angle * -1);
            }
            else
            {
                actual_facing_angle += moved_angle;
            }

            if (curr_fac == Facing.UP)
            {
                if (actual_facing_angle >= up_angle)
                {
                    face_rotating = false;
                    if (actual_facing_angle > up_angle)
                    {
                        float marge = actual_facing_angle - up_angle;
                        GetComponent <Transform>().RotateAroundAxis(Vector3.Left, -marge);
                    }
                }
            }
            else if (curr_fac == Facing.STRAIGHT)
            {
                if (actual_facing_angle >= -1.0f && actual_facing_angle <= 1)
                {
                    face_rotating = false;
                }
            }
            else if (curr_fac == Facing.DOWN)
            {
                if (actual_facing_angle <= down_angle)
                {
                    face_rotating = false;
                    if (actual_facing_angle < down_angle)
                    {
                        float marge = actual_facing_angle - down_angle;
                        GetComponent <Transform>().RotateAroundAxis(Vector3.Left, marge);
                    }
                }
            }
        }
        else if (moving)
        {
            GetComponent <Transform>().local_position = Vector3.MoveTowards(GetComponent <Transform>().local_position, endPosition, movSpeed * Time.deltaTime);
            GetComponent <Transform>().local_rotation = Vector3.Lerp(new Vector3(GetComponent <Transform>().local_rotation.x, GetComponent <Transform>().local_rotation.y, GetComponent <Transform>().local_rotation.z), new Vector3(GetComponent <Transform>().local_rotation.x, GetComponent <Transform>().local_rotation.y, GetComponent <Transform>().local_rotation.z), (endPosition.Length - GetComponent <Transform>().local_position.Length));
        }

        if (!moving && characters_camera.GetComponent <CompAnimation>().IsAnimationStopped("Idle") && GetLinkedObject("player_obj").GetComponent <CharactersManager>().GetCurrCharacterState() == 0)
        {
            characters_camera.GetComponent <CompAnimation>().PlayAnimationNode("Idle");
        }
    }