public virtual void AssociateSocialAccountWithUser(User user, OpenAuthenticationParameters parameters)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            string email = null;

            if (parameters.UserClaims != null)
            {
                foreach (var userClaim in parameters.UserClaims.Where(x => x.Contact != null && !String.IsNullOrEmpty(x.Contact.Email)))
                {
                    email = userClaim.Contact.Email;
                    break;
                }
            }

            var socialRecord = new SocialRecord
            {
                UserId             = user.Id,
                Email              = email,
                Identifier         = parameters.Identifier,
                DisplayIdentifier  = parameters.DisplayIdentifier,
                OAuthToken         = parameters.OAuthToken,
                OAuthAccessToken   = parameters.OAuthAccessToken,
                ProviderSystemName = parameters.ProviderSystemName,
                CreatedOn          = DateTime.Now,
                ModifiedOn         = DateTime.Now
            };

            _socialRecordRepository.Insert(socialRecord);
        }
        public virtual void DeleteSocialRecord(SocialRecord socialRecord)
        {
            if (socialRecord == null)
            {
                throw new ArgumentNullException("socialRecord");
            }

            _socialRecordRepository.Delete(socialRecord);
        }
Ejemplo n.º 3
0
    public bool PairWiseInteraction(PersonTag initiator, PersonTag reciever)
    {
        Person sPerson = Kernal.instance.store.people[initiator.storeID];
        Person rPerson = Kernal.instance.store.people[reciever.storeID];

        int chance = (sPerson.attributes.engagement + rPerson.attributes.engagement) / 2;
        int roll   = Random.Range(0, 10);

        // true if positive, false if negative
        int multi = (roll < chance) ? 1 : -1;

        // initiator record
        bool         hasKey = Kernal.instance.store.socialRecords[initiator.storeID].ContainsKey(reciever.storeID);
        SocialRecord record = null;

        if (!hasKey)
        {
            Kernal.instance.store.socialRecords[initiator.storeID][reciever.storeID] = new SocialRecord();
        }
        record = Kernal.instance.store.socialRecords[initiator.storeID][reciever.storeID];

        // apply
        record.familiarity += multi * 5 * sPerson.attributes.aggression;
        record.trust       += multi * 5 * sPerson.attributes.popularity;
        record.eros        += multi * 5 * sPerson.attributes.charisma;

        //Debug.Log(string.Format("{0}, {1}, {2}", record.familiarity, record.trust, record.eros));
        //Debug.Log(record.desire);


        // reciever record
        hasKey = Kernal.instance.store.socialRecords[reciever.storeID].ContainsKey(initiator.storeID);
        if (!hasKey)
        {
            Kernal.instance.store.socialRecords[reciever.storeID][initiator.storeID] = new SocialRecord();
        }
        record = Kernal.instance.store.socialRecords[reciever.storeID][initiator.storeID];

        // apply
        record.familiarity += multi * 5 * rPerson.attributes.aggression;
        record.trust       += multi * 5 * rPerson.attributes.popularity;
        record.eros        += multi * 5 * rPerson.attributes.charisma;

        if (record.desire > 75)
        {
            CurrentState   = States.Confess;
            enterChat      = false;
            ChatBoxSpawned = false;
        }
        //Debug.Log(string.Format("{0}, {1}, {2}", record.familiarity, record.trust, record.eros));
        //Debug.Log(record.desire);
        bool result = roll < chance;

        if (result == true)
        {
            rPerson.attributes.popularity++;
        }
        else
        {
            rPerson.attributes.popularity--;
        }
        return(result);
    }
Ejemplo n.º 4
0
    public void DoConfession()
    {
        Agent.SetDestination(SocialTarget.transform.position);

        if (PSLove.isPlaying == false)
        {
            PSLove.Play();
        }

        if (Agent.remainingDistance < 5 && enterChat == false)
        {
            Agent.SetDestination(transform.position);

            enterChat = true;
            if (!ChatBoxSpawned && !SocialTarget.ChatBoxSpawned)
            {
                ChatBoxSpawned = true;
                PersonTag targetTag = SocialTarget.gameObject.GetComponent <PersonTag>();
                PersonTag tag       = GetComponent <PersonTag>();

                ChatCooldown = 5;
                //Debug.Log("f**k has occurred");

                GameObject        NewConvo = Instantiate(PrefabPop, transform.position, Quaternion.identity);
                ConversationPopup temp     = NewConvo.GetComponent <ConversationPopup>();

                Person rPerson = Kernal.instance.store.people[SocialTarget.GetComponent <PersonTag>().storeID];

                SocialRecord record  = null;
                SocialRecord record2 = null;
                record  = Kernal.instance.store.socialRecords[SocialTarget.GetComponent <PersonTag>().storeID][GetComponent <PersonTag>().storeID];
                record2 = Kernal.instance.store.socialRecords[GetComponent <PersonTag>().storeID][SocialTarget.GetComponent <PersonTag>().storeID];

                float AVG = record.desire + record2.desire / 2;

                bool result = (AVG > Random.Range(0, 100)) ? true : false;

                temp.Feeling = (result) ? 2 : 0;
                temp.One     = this.gameObject;
                temp.Two     = SocialTarget.gameObject;

                if (result)
                {
                    if (Partner != null)
                    {
                        Partner.Partner = null;
                    }
                    Partner = SocialTarget;
                    if (Partner.Partner != null)
                    {
                        Partner.Partner = null;
                    }
                    Partner.Partner            = this;
                    record.RelationShipStatus  = 1;
                    record2.RelationShipStatus = 1;
                    confessed         = true;
                    Partner.confessed = false;

                    LoveSource.PlayOneShot(Victory, 2);
                }

                Destroy(NewConvo, ChatLength);
            }

            SetChatLength = ChatLength;
            ChatEngaged   = false;
            //Agent.isStopped = true;
        }
        if (enterChat == true)
        {
            if (SetChatLength <= 0)
            {
                PSLove.Stop();
                enterChat      = false;
                ChatBoxSpawned = false;
                // Agent.isStopped = false;
                NewDestination();
                CurrentState = States.Roam;
            }
        }
        SetChatLength -= Time.deltaTime;
    }