Пример #1
0
    void ConsiderConverse(Interest interest)
    {
        if (!CanConverse)
        {
            return;
        }
        if (Time.time - ConverseEndTime < ConverseCooldownDuration)
        {
            return;
        }
        if (interest.go == null)
        {
            return;
        }
        Character cha = interest.go.GetComponent <Character>();

        if (cha == null)
        {
            return;
        }
        AffinityData aff = GetAffinity(cha.id);

        if (aff.Value < AffTalk)
        {
            return;
        }
        if (cha.RequestConversation(this))
        {
            ConverseTarget = cha;
            PushState("Converse");
        }
    }
Пример #2
0
    public void Save()
    {
        if (nameField.text.Length <= 2)
        {
            MessageManager.Instance.NewMessage("Come on, you need a longer name that that...");
            return;
        }

        AffinityData weapAffinity = PixelScanner.ScanTextureAffinity(image.sprite.texture, AssetManager.Instance.baseAffinities, Variables.Instance.PixelScannerThrehold);

        WeaponData wd = new WeaponData(nameField.text, null, nameField.text, BaseWeapon.damage.value, weapAffinity);

        weapAffinity.PrintMe();

        SaveLoadHanlder.SaveWeapon(image.sprite.texture, nameField.text, wd);

        SaveLoadHanlder.LoadSprite(nameField.text);

        ItemManager.Instance.AddWeapon(wd, WeaponSortType.playerMade);

        MessageManager.Instance.NewMessage("You have made a weapon... Good for you.");

        UIManager.Instance.ResetCanvas();

        InventoryManager.Instance.AddItem(wd);
        //To Do: Generate weapon stuffs.
    }
Пример #3
0
    void TalkShareEvent(Character instigator)
    {
        AffinityData aff = GetAffinity(instigator.id);

        if (aff.Value > AffPeaceful && aff.Value < AffShare - 1)
        {
            ModifyAffinity(instigator.id, AffModTalk);
        }

        if (aff.Value > AffTalk)
        {
            if (KnownEvents.Count == 0)
            {
                Speak("random");
                return;
            }

            foreach (var evt in KnownEvents)
            {
                CharacterInfo cia = Global.Instance.CharacterInfoLookup[evt.CharacterIdA];
                CharacterInfo cib = Global.Instance.CharacterInfoLookup[evt.CharacterIdB];
                instigator.ReceiveEvent(evt);
                // debug
                Speak(evt.type.ToString() + " " + cia.name + " " + cib.name + " " + (Time.time - evt.time).ToString("F0") + " seconds ago.", 2);
            }
        }
    }
Пример #4
0
    void TalkDirect(Character instigator)
    {
        // tell the instigator what I think about them.
        AffinityData aff = GetAffinity(instigator.id);

        if (aff.Value > AffTalk)
        {
            if (Random.Range(0, 2) > 0)
            {
                // tell instigator what I think about them
                string say = "...";
                if (aff.Value < AffPeaceful)
                {
                    say = "Die!";
                }
                else
                if (aff.Value < 0)
                {
                    say = "Hi. You can help out if you want.";
                }
                else
                if (aff.Value < AffFollow)
                {
                    say = "I think you're alright.";
                }
                else
                if (aff.Value < AffShare)
                {
                    say = "I trust you.";
                }

                Speak(say, 2);
            }
        }
    }
Пример #5
0
    public WeaponData(string n, Sprite s, string sID, int d, AffinityData aff)
    {
        name         = n;
        sprite       = s;
        spriteID     = sID;
        damage.value = d;

        affinities = aff;
        type       = ItemType.weapon;
    }
Пример #6
0
    public BossCombatData(RS3BossCombatDataSO combatData)
    {
        this.name            = combatData.name;
        this.lifepoints      = combatData.lifepoints;
        this.poisonous       = combatData.poisonous;
        this.poisonImmune    = combatData.poisonImmune;
        this.reflectImmune   = combatData.reflectImmune;
        this.stunImmune      = combatData.stunImmune;
        this.statDrainImmune = combatData.statDrainImmune;
        this.monsterType     = combatData.monsterType;
        this.combatClass     = combatData.combatClass;
        affinityData         = new AffinityData(combatData.meleeAffinity, combatData.rangedAffinity, combatData.magicAffinity, combatData.weaknessAffinity, combatData.weakness);

        this.defenseLevel = combatData.defenseLevel;
        this.armour       = combatData.armour;
    }
Пример #7
0
    public bool ShouldFollow(Character target)
    {
        /*if( target.Rank <= Rank )
         *  return;
         * if( FollowCharacter != null )
         * {
         *  if( target.Rank <= FollowCharacter.Rank )
         *    return;
         * }*/
        AffinityData aff = GetAffinity(target.id);

        if (aff.Value > AffFollow)
        {
            Speak("ok");
            return(true);
        }
        else
        {
            // rejection
            string say = "...";
            if (aff.Value > AffTalk)
            {
                string[] exp = new string[] {
                    "No.",
                    "No, thanks.",
                    "Nope!",
                    "Hmm...",
                    "I'm busy.",
                    "Nah.",
                    "Pass.",
                    "Hard pass.",
                    "I don't think so.",
                    "I can't right now.",
                    "Do you even know where you're going?",
                    "Try me again later.",
                    "Yeah, right.",
                    "Do I know you?",
                    "You're probably looking for someone else.",
                    "Not in the mood.",
                    "I don't feel like it."
                };
                say = exp[Random.Range(0, exp.Length)];
            }
            Speak(say, 2);
        }
        return(false);
    }
Пример #8
0
    public static AffinityData ScanTextureAffinity(Texture2D tex, BaseAffinityData[] affinities, float tolerance)
    {
        AffinityData affs = new AffinityData();

        Dictionary <AffType, int> values = new Dictionary <AffType, int>();

        //Add each affinity to the runnign values
        foreach (BaseAffinityData bad in affinities)
        {
            values.Add(bad.type, 0);
        }


        int numberOfActivePixels = 0;

        //Loop through and compare each pixel to the bas affinity color
        foreach (Color c in tex.GetPixels())
        {
            if (c.a > 0)
            {
                foreach (BaseAffinityData bad in affinities)
                {
                    if (bad.IsColorSimilar(tolerance, c))
                    {
                        values[bad.type]++;
                        numberOfActivePixels++;
                        break;
                    }
                }
            }
        }

        Debug.Log(numberOfActivePixels);
        //finally go through and set v;alues
        foreach (KeyValuePair <AffType, int> v in values)
        {
            affs.SetAffinityValue(v.Key, (float)v.Value / (float)numberOfActivePixels);
        }

        return(affs);
    }
Пример #9
0
    string ConstructStatementAbout(int characterId)
    {
        string        say = "";
        CharacterInfo cia = Global.Instance.CharacterInfoLookup[characterId];
        AffinityData  ad  = GetAffinity(characterId);

        /*string ThirdPersonSingularSubject = "they";
         * string ThirdPersonSingularObject = "them";
         * if( cia.female )
         * {
         * ThirdPersonSingularSubject = "she";
         * ThirdPersonSingularObject = "her";
         * }
         * else
         * {
         * ThirdPersonSingularSubject = "he";
         * ThirdPersonSingularObject = "him";
         * }
         * if( ad.Value < AffPeaceful )
         * say = "I hate " + cia.name + ". " + Cap( ThirdPersonSingularSubject ) + " can die.";
         * else
         * if( ad.Value < AffTalk )
         *  say = cia.name + " sucks. I will not talk to " + ThirdPersonSingularObject + ".";
         * else
         *  if( ad.Value < 0 )
         *    say = "I think " + cia.name + " needs to help out around here.";
         *  else
         *    if( ad.Value < AffFollow )
         *      say = cia.name + " seems okay.";
         *    else
         *      if( ad.Value < AffShare )
         *        say = "I trust " + cia.name + ". I would follow " + ThirdPersonSingularObject + " if " + ThirdPersonSingularSubject + " asked.";
         *      else
         *        if( ad.Value < AffLoyal )
         *          say = cia.name + " is great!";
         *        else
         *          say = "I love " + cia.name + ". " + Cap( ThirdPersonSingularSubject ) + " is the best.";*/
        return(say);
    }
Пример #10
0
        public async Task GetRelationsAsync()
        {
            Husk husk = Context.Husk;

            if (!Engine.CanAct(ref husk, Context.Brain))
            {
                await Context.Channel.SendMessageAsync("You are currently de-synchronized. Unable to establish connection.");

                return;
            }

            Context.Account.Husk = husk;

            var relations = new StringBuilder();

            if (Context.Account.Brain.Relations.Count == 0)
            {
                await Context.Channel.SendMessageAsync(Context.Account, "You don't seem to know anyone. Get out there and talk to others!");
            }
            else
            {
                relations.AppendLine("Relationships:");
                relations.AppendJoin("\n", Context.Account.Brain.Relations.Select(x => $"`{x.Key}` [**{AffinityData.GetLevel(x.Value).ToString()}**]"));

                await Context.Channel.SendMessageAsync(Context.Account, relations.ToString());
            }
        }
Пример #11
0
    void TalkGossip(Character instigator)
    {
        AffinityData aff = GetAffinity(instigator.id);

        if (aff.Value > AffPeaceful && aff.Value < AffShare - 1)
        {
            ModifyAffinity(instigator.id, AffModTalk);
        }

        if (aff.Value > AffTalk)
        {
            if (KnownEvents.Count == 0)
            {
                Speak("hello");
                return;
            }
            // choose a ConverseEvent to share with the instigator
            CharacterEvent evt = KnownEvents[GossipIndex++ % KnownEvents.Count];

            CharacterInfo witness = Global.Instance.CharacterInfoLookup[evt.WitnessId];
            CharacterInfo cia     = Global.Instance.CharacterInfoLookup[evt.CharacterIdA];
            CharacterInfo cib     = Global.Instance.CharacterInfoLookup[evt.CharacterIdB];

            /*
             * // lazy lookup
             * if( evt.CharacterA == null )
             * {
             * SerializedComponent sca = SerializedObject.ResolveComponentFromId( evt.CharacterIdA );
             * if( sca != null )
             *  evt.CharacterA = (Character)sca;
             * }
             * // lazy lookup
             * if( evt.CharacterB == null )
             * {
             * SerializedComponent scb = SerializedObject.ResolveComponentFromId( evt.CharacterIdB );
             * if( scb != null )
             *  evt.CharacterB = (Character)scb;
             * }
             */

            instigator.ReceiveEvent(evt);

            // 1) what happened. Whether I saw it, or someone told me. with correct object/subject dependent on who is listening, and pronouns, tense, etc.
            // 2) why it happened... assumptions, speculation, unknowns.
            // 3) personal feelings, assessment, conclusion.

            string statement = "";
            string verb;
            switch (evt.type)
            {
            case CharacterEventEnum.Damage:
                verb = "attack";
                if (cia.id == id)
                {
                    statement += cib.name + " " + PastTense(verb) + " me " + (Time.time - evt.time) + " seconds ago.";
                }
                else if (cib.id == id)
                {
                    statement += "I " + PastTense(verb) + " " + cia.name + " " + (Time.time - evt.time) + " seconds ago.";
                }
                else if (witness.id == id)
                {
                    statement += "I saw " + cib.name + " " + verb + " " + cia.name + " " + (Time.time - evt.time) + " seconds ago.";
                }
                else if (witness.id == cia.id)
                {
                    statement += cia.name + " said " + cib.name + " " + PastTense(verb) + " " + ThirdPersonSingularObject(cia) + " " + (Time.time - evt.time) + " seconds ago.";
                }
                else if (witness.id == cib.id)
                {
                    statement += cib.name + " said " + ThirdPersonSingularSubject(cib) + " " + PastTense(verb) + " " + cia.name + " " + (Time.time - evt.time) + " seconds ago.";
                }
                else
                {
                    statement += witness.name + " saw " + cib.name + " " + verb + " " + cia.name + " " + (Time.time - evt.time) + " seconds ago.";
                }
                if (!cia.alive)
                {
                    statement += " " + Cap(cia.name) + " is dead.";
                }
                break;

            case CharacterEventEnum.Death:
                statement += cib.name + " killed " + cia.name + "! " + (Time.time - evt.time) + " seconds ago.";
                break;

            default:
                statement += evt.type.ToString() + " " + cia.name + " " + cib.name + " " + (Time.time - evt.time).ToString("D") + " seconds ago.";
                statement += " " + ConstructStatementAbout(cib.id);
                break;
            }
            Speak(statement, 2);

            /*
             * // Gossip: pick a random affinity/character and say something about them
             * string say = "...";
             * List<int> keys = new List<int>();
             * foreach( var pair in Affinity )
             * if( pair.Key != instigator.id && pair.Key != GetInstanceID() )
             *  keys.Add( pair.Key );
             * if( keys.Count > 0 )
             * {
             * Character cha = null;
             * const int maxtries = 10;
             * int tries = 0;
             * while( cha == null )
             * {
             *  tries++;
             *  if( tries > maxtries || tries > keys.Count )
             *    break;
             *
             *  SerializedComponent sco = null;
             *  int key = keys[ GossipIndex++ % keys.Count ];
             *  if( SerializedObject.serializedComponents.ContainsKey( key ) )
             *    sco = SerializedObject.serializedComponents[ key ];
             *  else
             *    continue;
             *  if( sco == null )
             *  {
             *    // character is null. is dead?
             *    continue;
             *  }
             *  cha = (Character)sco;
             *  if( cha != null )
             *  {
             *    AffinityData ad = GetAffinity( cha );
             *
             *    string ThirdPersonSingularSubject = "<ThirdPersonSingularSubject>";
             *    string ThirdPersonSingularObject = "<ThirdPersonSingularObject>";
             *    if( cha.identity.female )
             *    {
             *      ThirdPersonSingularSubject = "she";
             *      ThirdPersonSingularObject = "her";
             *    }
             *    else
             *    {
             *      ThirdPersonSingularSubject = "he";
             *      ThirdPersonSingularObject = "him";
             *    }
             *
             *    if( ad.Value < AffPeaceful )
             *      say = "I hate " + cha.CharacterName + ". " + Cap( ThirdPersonSingularSubject ) + " can die.";
             *    else
             *      if( ad.Value < AffTalk )
             *        say = cha.CharacterName + " sucks. I will not talk to " + ThirdPersonSingularObject + ".";
             *      else
             *        if( ad.Value < 0 )
             *          say = "I think " + cha.CharacterName + " needs to help out around here.";
             *        else
             *          if( ad.Value < AffFollow )
             *            say = cha.CharacterName + " seems okay.";
             *          else
             *            if( ad.Value < AffShare )
             *              say = "I trust " + cha.CharacterName + ". I would follow " + ThirdPersonSingularObject + " if " + ThirdPersonSingularSubject + " asked.";
             *            else
             *              if( ad.Value < AffLoyal )
             *                say = cha.CharacterName + " is great!";
             *              else
             *                say = "I love " + cha.CharacterName + ". " + Cap( ThirdPersonSingularSubject ) + " is the best.";
             *    break;
             *  }
             * }
             * Speak( say, 2 );
             *
             * }
             */
        }
    }