示例#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);
        }
    }
示例#2
0
    /// <summary>
    /// Advances Packet to the next room.
    /// Updates packet with new room data.
    /// Returns : TRUE if packet has completed dungeon
    /// </summary>
    /// <param name="packet"></param>
    public bool UpdatePacketToNextRoom(string packet_key)
    {
        PartyController party = m_questingParties[packet_key].GetComponent <PartyController>();

        if (party != null)
        {
            //  We move in the list from last->first
            bool completed_dungeon = (0 > party.AdvanceRoom());

            if (completed_dungeon)
            {
                //  TODO aherrera : Party has defeated the boss?
                party.SetState(PartyState.PARTY_SUCCESS);
            }
            else
            {
                RoomModel party_new_current_room = mDungeonModel.GetRoom(party.GetCurrentRoomIndex());
                if (party_new_current_room != null)
                {
                    InitializePacketToRoom(packet_key);
                }
            }

            return(completed_dungeon);
        }
        else
        {
            Debug.LogError("DungeonModel::UpdatePacketToNextRoom -- packet not found in list with string: " + packet_key);
        }

        //  Hey pls don't be here
        //  TODO aherrera : handle these kinds of errors to search out and erase traces of this packet?
        return(false);
    }
示例#3
0
    //  TODO aherrera : DEBUG SCRIPT; kill this before it's too late
    public void AddRandomParty()
    {
        GameObject      new_Adventurer       = Instantiate(AdventurerPrefab);
        AdventurerModel new_model            = AdventurerGenerator.instance.GenerateRandom(ref new_Adventurer, 1, Enums.UnitRarity.e_rarity_COMMON);
        GameObject      new_party            = new GameObject();
        PartyModel      new_party_model      = new_party.AddComponent <PartyModel> ();
        PartyController new_party_controller = new_party.AddComponent <PartyController> ();

        //AdventurerPacket newpackofcigs = go_adventurerpacket.AddComponent<AdventurerPacket>();
        new_party.name = checkDictionaryForKey(new_party_controller.GetAdventureTitle());
        new_party_controller.InitializeParty();
        new_party_model._Adventurers.Add(new_Adventurer);

        RoomModel room_model = mDungeonModel.GetRoom(new_party_controller.GetCurrentRoomIndex());

        AddNewParty(new_party, true);
        new_party_controller.BeginRoom(room_model.timer_frequency);
    }
示例#4
0
    //TODO Should be in DungeonController.cs
    /// <summary>
    /// Challenge packet to their CurrentRoom.
    /// Returns : TRUE if party is still ALIVE
    /// </summary>
    /// <param name="packet_key"></param>
    /// <returns>Returns TRUE if the party is ALIVE</returns>
    public bool ChallengePacketInCurrentRoom(string packet_key)
    {
        GameObject      party_object = m_questingParties[packet_key];
        PartyController party        = party_object.GetComponent <PartyController>();

        if (party != null)
        {
            RoomModel party_current_room = mDungeonModel.GetRoom(party.GetCurrentRoomIndex());
            if (party_current_room != null)
            {
                bool challenge_successful = party_current_room.challengeParty(party.GetAdventurers());
                if (challenge_successful)
                {
                    //party_packet.AwardPacket(party_current_room);
                }
                else
                {
                    ResolveChallengeFailure(party, party_current_room);
                }
            }
            else
            {
                Debug.LogError("DungeonModel::ChallengePacketInCurrentRoom -- room not in list from packet: " + party.GetAdventureTitle());
            }

            //  TODO aherrera, wspier : like, should this logic be in the Model?? Should it be in charge to figure it out?
            if (party.isPartyDead())
            {
                party.SetState(PartyState.PARTY_FAILED);
                NewsFeedController.instance.CreateNewAlert("Party just died! lol");
            }

            return(!party.isPartyDead());
        }
        else
        {
            Debug.LogError("DungeonModel::ChallengePacketInCurrentRoom -- packet not found in list with string: " + packet_key);
        }

        //  Hey! Pls don't come here okay thanks
        return(false);
    }