// 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); } }
public void ResolveChallengeFailure(PartyController party, RoomModel room) { foreach (GameObject adventurer in party.GetAdventurers()) { AdventurerModel a = adventurer.GetComponent <AdventurerModel>(); a.applyDamage(room.room_attack); } }
//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); }