public void Insert() { if (recipient) { CollectionData[] cdata = recipient.GetComponents <CollectionData>(); for (int i = 0; i < cdata.Length; i++) { CollectionData coldat = cdata[i]; // find the collection we should insert into, by name if (coldat.name == collectionName) { coldat.Insert(this); // really, only activate passive aspects if we // successfully inserted into inventory IsPassive pas = GetComponent <IsPassive>(); if (pas) { pas.Activate(); pas.SetRecipient(this.GetRecipient()); } Hide(); break; } } } }
public void Consume() { if (buffs) { // late bind recipient if (!buffs.GetRecipient()) { buffs.SetRecipient(GetRecipient()); } buffs.Apply(); // check if item isPassive IsPassive passive = gameObject.GetComponent <IsPassive>(); if (passive == null) { // if not passive - remove from scene after usage Destroy(this.gameObject); } else { // do not destroy if passive so temp buffs can be applied that expire over time passive.Activate(); passive.SetRecipient(this.GetRecipient()); // hide after item is collected Hide(); } } }
public override int GetHashCode() { int hash = Level.GetHashCode(); if (Description != null) { hash ^= Description.GetHashCode(); } if (Name != null) { hash ^= Name.GetHashCode(); } if (Icon != null) { hash ^= Icon.GetHashCode(); } hash ^= IsHidden.GetHashCode(); hash ^= IsPassive.GetHashCode(); hash ^= Cooldown.GetHashCode(); hash ^= CastingTime.GetHashCode(); hash ^= ChannelingTime.GetHashCode(); hash ^= ForceCost.GetHashCode(); hash ^= EnergyCost.GetHashCode(); hash ^= ApCost.GetHashCode(); hash ^= ApType.GetHashCode(); hash ^= MinRange.GetHashCode(); hash ^= MaxRange.GetHashCode(); hash ^= GCD.GetHashCode(); hash ^= GcdOverride.GetHashCode(); if (AbilityTokens != null) { hash ^= AbilityTokens.GetHashCode(); } hash ^= TargetArc.GetHashCode(); hash ^= TargetArcOffset.GetHashCode(); hash ^= TargetRule.GetHashCode(); hash ^= LineOfSightCheck.GetHashCode(); hash ^= Pushback.GetHashCode(); hash ^= IgnoreAlacrity.GetHashCode(); return(hash); }
public void OnCollisionEnter2D(Collision2D other) { foreach (string s in TouchTypes) { if (other.gameObject.GetComponent(s)) { // pass reference to this, to consumable if this is consumable // ie. consume item immediately after pickup IsConsumable cons = GetComponent <IsConsumable>(); if (cons) { cons.SetRecipient(other.gameObject); } // stote in Player's inventory IsInventoriable inv = GetComponent <IsInventoriable>(); if (inv) { inv.SetRecipient(other.gameObject); } // store in item collection ie. gold in coin purse IsCollectible col = GetComponent <IsCollectible>(); if (col) { col.SetRecipient(other.gameObject); } IsPassive pas = GetComponent <IsPassive>(); if (pas) { pas.SetRecipient(other.gameObject); } // sendmessage if we actually find a component who can listen for this SendMessage(OnTouchCB); } } }
/// <summary> /// Initializes a new instance of the AuthnRequest class. /// </summary> /// <param name="identityProvider"> /// IdentityProvider to receive the AuthnRequest /// </param> /// <param name="serviceProvider"> /// ServiceProvider to issue the AuthnRequest /// </param> /// <param name="parameters"> /// NameValueCollection of varying parameters for use in the /// construction of the AuthnRequest. /// </param> public AuthnRequest(IIdentityProvider identityProvider, IServiceProvider serviceProvider, NameValueCollection parameters) { m_xml = new XmlDocument { PreserveWhitespace = true }; m_nsMgr = new XmlNamespaceManager(m_xml.NameTable); m_nsMgr.AddNamespace("saml", "urn:oasis:names:tc:SAML:2.0:assertion"); m_nsMgr.AddNamespace("samlp", "urn:oasis:names:tc:SAML:2.0:protocol"); Id = Saml2Utils.GenerateId(); IssueInstant = Saml2Utils.GenerateIssueInstant(); Issuer = serviceProvider.EntityId; if (parameters != null) { AllowCreate = Saml2Utils.GetBoolean(parameters[Saml2Constants.AllowCreate]); AssertionConsumerServiceIndex = parameters[Saml2Constants.AssertionConsumerServiceIndex]; Binding = parameters[Saml2Constants.Binding]; Consent = parameters[Saml2Constants.Consent]; Destination = parameters[Saml2Constants.Destination]; ForceAuthn = Saml2Utils.GetBoolean(parameters[Saml2Constants.ForceAuthn]); IsPassive = Saml2Utils.GetBoolean(parameters[Saml2Constants.IsPassive]); NameIDPolicyFormat = parameters[Saml2Constants.NameIDPolicyFormat]; } if (string.IsNullOrEmpty(NameIDPolicyFormat)) { NameIDPolicyFormat = Saml2Constants.NameIDPolicyFormatUnspecified; } string assertionConsumerSvcUrl = null; if (!string.IsNullOrEmpty(Binding)) { if (!string.IsNullOrEmpty(AssertionConsumerServiceIndex)) { // find assertion consumer service location by binding and index. assertionConsumerSvcUrl = serviceProvider.GetAssertionConsumerServiceLocation(Binding, AssertionConsumerServiceIndex); } else { // find assertion consumer service location by binding only, using first found. assertionConsumerSvcUrl = serviceProvider.GetAssertionConsumerServiceLocation(Binding); } } // neither index nor binding, throw exception if (string.IsNullOrEmpty(AssertionConsumerServiceIndex) && string.IsNullOrEmpty(assertionConsumerSvcUrl)) { throw new Saml2Exception(Resources.AuthnRequestAssertionConsumerServiceNotDefined); } // If destination not specified, use SSO location by binding if (string.IsNullOrEmpty(Destination)) { Destination = identityProvider.GetSingleSignOnServiceLocation(parameters[Saml2Constants.RequestBinding]); if (string.IsNullOrEmpty(Destination)) { // default to HttpRedirect Destination = identityProvider.GetSingleSignOnServiceLocation(Saml2Constants.HttpRedirectProtocolBinding); } } // Get RequestedAuthnContext if parameters are available... RequestedAuthnContext reqAuthnContext = GetRequestedAuthnContext(serviceProvider, parameters); // Generate the XML for the AuthnRequest... var rawXml = new StringBuilder(); rawXml.Append("<samlp:AuthnRequest "); rawXml.Append(" xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\""); rawXml.Append(" ID=\"" + Id + "\""); rawXml.Append(" Version=\"2.0\""); rawXml.Append(" IssueInstant=\"" + IssueInstant + "\""); rawXml.Append(" IsPassive=\"" + IsPassive.ToString().ToLower() + "\""); rawXml.Append(" ForceAuthn=\"" + ForceAuthn.ToString().ToLower() + "\""); if (!String.IsNullOrEmpty(Consent)) { rawXml.Append(" Consent=\"" + Consent + "\""); } if (!String.IsNullOrEmpty(Destination)) { rawXml.Append(" Destination=\"" + Destination + "\""); } if (!String.IsNullOrEmpty(assertionConsumerSvcUrl)) { rawXml.Append(" ProtocolBinding=\"" + Binding + "\""); rawXml.Append(" AssertionConsumerServiceURL=\"" + assertionConsumerSvcUrl + "\""); } else { rawXml.Append(" AssertionConsumerServiceIndex=\"" + AssertionConsumerServiceIndex + "\""); } rawXml.Append(">"); rawXml.Append("<saml:Issuer xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\">" + serviceProvider.EntityId + "</saml:Issuer>"); rawXml.Append("<samlp:NameIDPolicy Format=\"" + NameIDPolicyFormat + "\" AllowCreate=\"" + AllowCreate.ToString().ToLower() + "\" />"); if (reqAuthnContext != null) { rawXml.Append(reqAuthnContext.GenerateXmlString()); } rawXml.Append("</samlp:AuthnRequest>"); m_xml.LoadXml(rawXml.ToString()); }