bool MatchRelations(Relationships.State relations) { // loop through all required relationships foreach (Relationships.State relation in requiredAnyOfRelationships) { // verify if relationships match required if (relation == relations) { // match return(true); } } // don't match return(false); }
//public bool MatchScope(PartyUnit srcPartyUnitUPMOwner, PartyUnit dstPartyUnit) //{ // // Match // switch (ModifierScope) // { // case ModifierScope.Self: // // verify if source and destination party units are the same // if (srcPartyUnitUPMOwner.GetInstanceID() == dstPartyUnit.GetInstanceID()) // { // return true; // } // else // { // return false; // } // case ModifierScope.SingleUnit: // case ModifierScope.EntireParty: // case ModifierScope.AllPlayerUnits: // Debug.LogError("Finish this function logic implementation"); // return true; // default: // Debug.LogError("Unknown modifier scope: " + ModifierScope.ToString()); // return false; // } //} public bool MatchRelationships(PartyUnit srcPartyUnitUPMOwner, PartyUnit dstPartyUnit) { // get relationships Relationships.State relationships = Relationships.Instance.GetRelationships(srcPartyUnitUPMOwner.GetUnitParty().Faction, dstPartyUnit.GetUnitParty().Faction); // loop through all required relationships foreach (Relationships.State relation in RequiredRelationships) { // verify if relationships match if (relation == relationships) { return(true); } } // if none of required relations match return false return(false); }
ValidationResult MatchRelationsBetweenCityAndParty(City sourceCity, HeroParty destinationParty) { // verify if parameters are not null if (sourceCity != null && destinationParty != null) { // get relationships between item ower and destination (validated) unit Relationships.State relations = Relationships.Instance.GetRelationships(sourceCity.CityCurrentFaction, destinationParty.Faction); // verify if relationships match if (MatchRelations(relations)) { // don't limit return(ValidationResult.Pass()); } } // default: don't allow propagation, limit return(ValidationResult.Discard(onDiscardMessage)); }