Exemple #1
0
        /// <summary>
        /// Constructs a new physics actor.
        /// </summary>
        /// <param name="desc">Descriptor for the actor.</param>
        public CharacterBEPUActor(ActorDesc desc) : base(desc)
        {
            character     = new CharacterController(desc.Position, 17f, 17f * 0.6f, 6.0f, 4500.0f);
            characterBody = character.Body;

            // Tag the physics with data needed by the engine
            var tag = new CharacterTag(this.ownerEntityID, characterBody);

            this.characterBody.Tag = tag;
            this.characterBody.CollisionInformation.Tag = tag;

            this.Position    = desc.Position;
            this.Orientation = desc.Orientation;

            Debug.Assert(this.characterBody != null, "A physics entity was not properly created.");

            this.spaceObject = this.character;

            this.characterBody.IsAffectedByGravity = desc.AffectedByGravity;

#if WINDOWS
            // We add the character's cylinder body to the physics viewer.
            var msgAddPhys = ObjectPool.Aquire <MsgAddPhysicsToModelViewer>();
            msgAddPhys.SpaceObject = this.characterBody;
            this.game.SendInterfaceMessage(msgAddPhys, InterfaceType.Physics);
#endif //WINDOW
        }
        public void UpsertCharacterTags_ShouldUpdateExistingTags()
        {
            var tags = new List <Tag>();

            for (int i = 0; i < 3; ++i)
            {
                var newTag = new CharacterTag(DatabaseConstants.DEFAULT_ID, "test " + i, "");
                tags.Add(newTag);
            }

            repository.UpsertCharacterTags(tags);
            tags[0].Type = "1";
            tags[2].Type = "2";
            tags[0].Name = "new tag 0";
            tags[2].Name = "new tag 2";
            repository.UpsertCharacterTags(tags);

            var retrievedTags = repository.GetCharacterTags();

            foreach (var tag in tags)
            {
                foreach (var retrievedTag in retrievedTags)
                {
                    if (tag.Name == retrievedTag.Name)
                    {
                        tag.TagId = retrievedTag.TagId;
                        break;
                    }
                }
            }

            CollectionAssert.AreEquivalent(tags, retrievedTags);
        }
Exemple #3
0
    public void SetQuestTopic(CharacterTag npc, Quest quest)
    {
        this.npc = npc;

        this.quest     = quest;
        textField.text = quest.GetTopic();
        mode           = Mode.QuestTopic;
    }
Exemple #4
0
    public Quest GetRandomQuest(CharacterTag characterTag)
    {
        // Add quest type randomization

        Quest_Collection quest = new Quest_Collection(characterTag);

        return(quest);
    }
Exemple #5
0
    public void SetChoice(CharacterTag npc, Choice choice)
    {
        this.npc = npc;

        this.choice    = choice;
        textField.text = choice.text;
        mode           = Mode.InkChoice;
    }
        public override bool CanStart(CharacterTag character)
        {
            if (!startedOnce && character == Core.Instance.DB.CharacterDB.Mermaid)
            {
                return(true);
            }

            return(false);
        }
Exemple #7
0
 public Story GetCharacterStory(CharacterTag character)
 {
     if (character = DB.CharacterDB.Mermaid)
     {
         return(MermaidStory);
     }
     else
     {
         return(null);
     }
 }
Exemple #8
0
        public List <Quest> GetOpenQuests(CharacterTag character)
        {
            List <Quest> results = new List <Quest>();

            foreach (Quest q in quests)
            {
                if (q.CanStart(character))
                {
                    results.Add(q);
                }
            }

            return(results);
        }
Exemple #9
0
    public static bool QuestNPC(CharacterTag character)
    {
        foreach (Quest quest in QuestLog)
        {
            foreach (CharacterTag tag in quest.GetInvolvedCharacters())
            {
                if (tag == character)
                {
                    return(true);
                }
            }
        }

        return(false);
    }
Exemple #10
0
    public void Close()
    {
        InputSystem.EndDialogue();

        isActive     = false;
        firstStory   = null;
        currentStory = null;
        NPC          = null;
        SetQuest(null);

        dialogueOpen.Value = false;

        namePanel.SetActive(false);
        nameField.text     = string.Empty;
        dialogueField.text = string.Empty;
    }
Exemple #11
0
        public List <Tag> GetTagsOnCharacter(long characterId)
        {
            using (var db = DataAccessUtil.CreateSqlConnection()) {
                db.Open();
                var command = new SqliteCommand($"SELECT t.tag_id, t.name, t.type, t.unique_id FROM tag_on_character v, tag t WHERE v.character_id = {characterId} AND v.tag_id = t.tag_id AND t.deleted = false", db);
                var reader  = command.ExecuteReader();

                var tags = new List <Tag>();
                while (reader.Read())
                {
                    var tag = new CharacterTag(reader.GetInt64(0), reader.GetString(1), reader.GetString(2), reader.GetString(3));
                    tags.Add(tag);
                }

                return(tags);
            }
        }
 static void Shoot(CharacterTag tag, EntityCommandBuffer.Concurrent CommandBuffer, Translation position, int jobIndex)
 {
     if (tag.Value == ChTags.Cooper)
     {
         Entity shot = CommandBuffer.CreateEntity(jobIndex);
         CommandBuffer.AddComponent(jobIndex, shot, new Translation
         {
             Value = new float3(position.Value.x, position.Value.y + 0.2f, position.Value.z)
         });
         CommandBuffer.AddComponent(jobIndex, shot, new ShotTag {
             Character = ChTags.Cooper
         });
         CommandBuffer.AddComponent(jobIndex, shot, new Scale {
             Value = 0.1f
         });
         CommandBuffer.AddComponent(jobIndex, shot, new LocalToWorld {
         });
         CommandBuffer.AddSharedComponent(jobIndex, shot, new RenderMesh
         {
             mesh     = GameDetails.GD.Mesh,
             material = GameDetails.GD.CooperShotMaterial,
         });
     }
     else
     {
         Entity shot = CommandBuffer.CreateEntity(jobIndex);
         CommandBuffer.AddComponent(jobIndex, shot, new Translation
         {
             Value = new float3(position.Value.x, position.Value.y - 0.2f, position.Value.z)
         });
         CommandBuffer.AddComponent(jobIndex, shot, new ShotTag {
             Character = ChTags.Spider
         });
         CommandBuffer.AddComponent(jobIndex, shot, new Scale {
             Value = 0.1f
         });
         CommandBuffer.AddComponent(jobIndex, shot, new LocalToWorld {
         });
         CommandBuffer.AddSharedComponent(jobIndex, shot, new RenderMesh
         {
             mesh     = GameDetails.GD.Mesh,
             material = GameDetails.GD.SpiderShotMaterial,
         });
     }
 }
Exemple #13
0
    public static bool QuestNPC(CharacterTag character, out List <Quest> quests)
    {
        List <Quest> questList = new List <Quest>();
        bool         onQuest   = false;

        foreach (Quest quest in QuestLog)
        {
            foreach (CharacterTag tag in quest.GetInvolvedCharacters())
            {
                if (tag == character)
                {
                    questList.Add(quest);
                    onQuest = true;
                }
            }
        }

        quests = questList;
        return(onQuest);
    }
Exemple #14
0
 private void CreateOrGetTags(Picture picture, List <TagData> tags)
 {
     foreach (var tagData in tags)
     {
         if (tagData.CharacterTag == null)
         {
             continue;
         }
         Tag tag = null;
         if (!tagData.Exists)
         {
             tag = new Tag
             {
                 CharacterTags = new HashSet <CharacterTag>(),
                 Name          = tagData.SuggestedTag
             };
         }
         else
         {
             using (TagRepository repo = new TagRepository())
             {
                 tag = repo.GetByName(tagData.SuggestedTag);
             }
         }
         List <CharacterTag> charTags = new List <CharacterTag>();
         CharacterTag        charTag  = null;
         foreach (var character in tagData.CharacterTag)
         {
             Character characterObj = picture.Characters.Where(c => c.DanbooruName == character).Take(1).SingleOrDefault();
             charTag = new CharacterTag
             {
                 Tag       = tag,
                 Picture   = picture,
                 Character = characterObj
             };
             tag.CharacterTags.Add(charTag);
             picture.CharacterTags.Add(charTag);
             characterObj.CharacterTags.Add(charTag);
         }
     }
 }
Exemple #15
0
    private void OnTriggerEnter(Collider other)
    {
        CharacterTag tag = other.GetComponent <CharacterTag>();

        if (tag)
        {
            //will not impact the shooter until it travels out of it
            if (tag.attachedCharacter == shooter)
            {
                if (Time.time - startFrame < Time.deltaTime)
                {
                    if (insideShooterColliders == null)
                    {
                        insideShooterColliders = new List <Collider>(1);
                    }
                    insideShooterColliders.Add(other);
                    return;
                }
                else if (insideShooterColliders != null && 0 < insideShooterColliders.Count)
                {
                    insideShooterColliders.Add(other);
                    return;
                }
            }

            //damage!
            tag.attachedCharacter.LandAttack(
                damage,
                other.ClosestPoint(transform.position),
                shooter.characterComponents,
                heft,
                out _);
        }

        enabled = false;
        travellingEffect.SetActive(false);
        impactEffect.SetActive(true);
        Destroy(gameObject, impactDuration);
    }
    private void RecursiveCopy(Transform target)
    {
        Collider col = target.GetComponent <Collider>();

        if (col)
        {
            col.isTrigger = true;

            CharacterTag targetTag = target.GetComponent <CharacterTag>();
            if (targetTag == null)
            {
                targetTag = target.gameObject.AddComponent <CharacterTag>();
            }

            targetTag.attachedCharacter = attachedCharacter;
        }

        for (int i = 0; i < target.childCount; i++)
        {
            RecursiveCopy(target.GetChild(i));
        }
    }
Exemple #17
0
    private void OnTriggerEnter(Collider other)
    {
        CharacterTag tag = other.GetComponent <CharacterTag>();

        if (tag &&
            targetsAttacked.Contains(tag.attachedCharacter) == false)
        {
            targetsAttacked.Add(tag.attachedCharacter);

            tag.attachedCharacter.LandAttack(damage,
                                             owner.characterComponents.CenterPosition,
                                             owner.characterComponents,
                                             heft,
                                             out int ricochet);
            OnLandAttack?.Invoke(tag.attachedCharacter.characterComponents);

            if (heft < ricochet)
            {
                owner.RicochetStagger();
            }
        }
    }
Exemple #18
0
    public Story GetStateDialogue(CharacterTag npc)
    {
        story.variablesState["npc"] = npc.GetName();

        if (CompletionConditionsMet())
        {
            story.ChoosePathString("Quest.Complete");
            Complete();
            QuestSystem.Instance.QuestEnded(this);
            return(story);
        }
        else if (FailConditionsMet())
        {
            story.ChoosePathString("Quest.Fail");
            Fail();
            return(story);
        }
        else
        {
            story.ChoosePathString("Quest.State");
            return(story);
        }
    }
    public Quest_Collection(CharacterTag npc)
    {
        this.npc = npc;

        Database DB = Core.Instance.DB;

        story          = new Story(DB.QuestDB.CollectionQuest_Json.text);
        requiredItem   = DB.ItemDB.Common.GetRandom();
        requiredAmount = 1;
        rewardItem     = DB.ItemDB.Money;
        rewardQuantity = requiredItem.Price * 3;

        story.variablesState["player"]    = GameManager.Instance.PlayerName;
        story.variablesState["npc"]       = npc.GetName();
        story.variablesState["partitive"] = npc.Partitive();
        story.variablesState["genetive"]  = npc.Genetive();
        story.variablesState["itemName"]  = requiredItem.ItemName;
        story.variablesState["amount"]    = requiredAmount;

        AssignID();

        SetInvolvedCharacters(new CharacterTag[] { npc });
    }
        private void TransformTags(Post change, Picture picture)
        {
            if (change.Tags.Length == 0)
            {
                return;
            }
            using (CharacterTagRepository charRepo = new CharacterTagRepository())
            {
                Tag tagObj = null;
                foreach (var tag in change.Tags)
                {
                    string newTag = tag.ToLower().Replace(' ', '_').Capitalize();

                    CharacterTag chTag = new CharacterTag();

                    picture.CharacterTags.Add(chTag);
                    chTag.Picture = picture;

                    var character = picture.Characters.First();
                    chTag.Character = character;
                    character.CharacterTags.Add(chTag);

                    tagObj = charRepo.GetTagByName(newTag);
                    if (tagObj == null)
                    {
                        tagObj = new Tag
                        {
                            Name          = newTag,
                            CharacterTags = new HashSet <CharacterTag>()
                        };
                    }
                    tagObj.CharacterTags.Add(chTag);
                    chTag.Tag = tagObj;
                    _changedObjects.ChangedTags.Add(chTag);
                }
            }
        }
Exemple #21
0
 public async Task PermanentlyRemoveCharacterTag(CharacterTag tag)
 {
     tagRepository.PermanentlyRemoveCharacterTag(tag);
 }
 public override bool CanStart(CharacterTag character)
 {
     return(true);
 }
 public static Character ToCharacter(this CharacterTag characterTag)
 {
     return(AssetTag.Characters.ToAsset().GetItem <Character>(characterTag));
 }
Exemple #24
0
 public void UpdateCharacterTag(CharacterTag tag)
 {
     tagRepository.UpdateTag(tag);
 }
Exemple #25
0
 public async Task DeleteCharacterTag(CharacterTag tag)
 {
     tagRepository.DeleteCharacterTag(tag);
 }
Exemple #26
0
 public Story GetStartDialogue(CharacterTag npc)
 {
     story.variablesState["npc"] = npc.GetName();
     story.ChoosePathString("Quest.StartDialogue");
     return(story);
 }
Exemple #27
0
 // Here we check the requirements for giving the quest
 public abstract bool CanStart(CharacterTag character);
Exemple #28
0
 public async Task RestoreCharacterTag(CharacterTag tag)
 {
     tagRepository.RestoreCharacterTag(tag);
 }
Exemple #29
0
    public void StartDialogue(Story story, CharacterTag character)
    {
        NPC = character;

        StartDialogue(story);
    }
Exemple #30
0
 public bool DBEquals(CharacterTag obj)
 {
     return(Id == obj.Id &&
            CharacterId == obj.CharacterId &&
            Tag == obj.Tag);
 }