Ejemplo n.º 1
0
    // TODO Rename this function
    /// <summary>
    /// Initialize Packet data to it's Current Room.
    /// Optional param sets to given room index
    /// </summary>
    /// <param name="packet_key"></param>
    /// <param name="new_room_index">optional; sets the packet to this room index</param>
    public void InitializePacketToRoom(string packet_key, int new_room_index = -1)
    {
        PartyController party = m_questingParties[packet_key].GetComponent <PartyController>();

        //  TODO aherrera, wspier : should 0 be allowed? That would mean fighting Boss Room right away
        if (new_room_index >= 0)
        {
            party.SetCurrentRoomIndex(new_room_index);
        }

        //  TODO aherrera : replace this check with something more elegant :/
        if (new_room_index >= mDungeonModel.RoomCount)
        {
            Debug.LogError("GIVEN INDEX LARGER THAN ARRAY SIZE");
        }

        RoomModel current_room_reference = mDungeonModel.GetRoom(party.GetCurrentRoomIndex());
        RoomView  currentRoomView        = current_room_reference.gameObject.GetComponent <RoomView> ();

        if (current_room_reference != null)
        {
            party.SetRoomTimer(Helper.Epoch.GetEpochTimestamp(current_room_reference.timer_frequency));
            currentRoomView.addAdventurer(party.GetAdventurers()[0]);
        }
        else
        {
            Debug.LogError("DungeonModel::InitializePacketToCurrentRoom -- currentroom not found for string: " + packet_key);
        }
    }