示例#1
0
    public void SuccessQuest1(Quest quest, QuestGiver qg, NpcAI npcai)
    {
        //journal bijwerken

        if (giverInventory.EnoughInventory(quest.rewardCoins, quest.rewardObjects))
        {
            quest.questStatus = QuestStatus.Completed;

            //beloning
            giverInventory.GiveCoins(playerInventory, quest.rewardCoins);
            foreach (WorldObject item in quest.rewardObjects)
            {
                giverInventory.GiveItem(playerInventory, item);
            }

            // gather object verwijderen en naar npc
            foreach (QuestObjective obj in quest.questObjectives)
            {
                playerInventory.GiveItem(giverInventory, obj.objectToGather);
            }
            journal.InsertQuestCompleted(quest, npcai);
            CloseQuestWindow();
        }
        else
        {
            //questgiver heeft niet alles als reward
            string npcTalk = "I'm sorry. It seems I don't have everything I promised you. While I promised you " + quest.NameRewards();
            npcTalk += ", I can only deliver " + quest.NameWhatYouGot(giverInventory) + ". Will you accept that as payment for your trouble?";
            dialogHandler.Talk(npcAI, quest.questTitle, npcTalk, "That'll do.", "No way!", SuccessQuest1a, SuccessQuest1b, quest);
        }
    }
示例#2
0
    public void InsertQuestCompleted(Quest quest, NpcAI npcAI = null)
    {
        //entry quest schrijven
        string entryTxt = "I finished the quest I got";

        if (npcAI != null)
        {
            entryTxt += " after talking to " + npcAI.gameObject.GetComponent <WorldObject>().objectTitle;
        }
        entryTxt += ". ";
        entryTxt += quest.questDescription;
        JournalEntry entry = new JournalEntry(EntryTypes.Quest, entryTxt, quest, null);

        InsertEntry(entry);

        //popularityWithNPC bijwerken
        AddPopularityDictionary(quest.popularityWithNPCCompleted);
        //nog een opvolgquest als die bestaat
        if (quest.nextQuest.Count > 0)
        {
            foreach (int q in quest.nextQuest)
            {
                Quest qu = gameHandler.GetQuestByID(q);
                if (qu != null)
                {
                    if (qu.questStatus == QuestStatus.Closed)
                    {
                        qu.questStatus = QuestStatus.Open;
                    }
                }
            }
        }
    }
示例#3
0
        /// <summary>
        /// Creates a new instance of the <see cref="Npc"/> class.
        /// </summary>
        public Npc(MmoZone zone, int objectId, short groupId, NpcType npcType, NpcData npcData)
            : base(zone, ObjectType.Npc, objectId, groupId, new Bounds(), npcData)
        {
            this.npcType   = npcType;
            this.alignment = (SocialAlignment)npcData.Alignment;

            this.lootGroupId         = npcData.LootGroupId;
            this.startableQuestIds   = npcData.StartQuests;
            this.completableQuestIds = npcData.CompleteQuests;

            this.BuildProperties(Properties, PropertyFlags.NpcAll);
            this.Revision = this.Properties.Count;
            if (Properties.Count > 0)
            {
                this.Flags |= MmoObjectFlags.HasProperties;
            }

            this.SetBaseStat(Stats.Health, (short)npcData.MaxHealth);
            this.SetHealth(MaximumHealth);
            this.SetBaseStat(Stats.Power, (short)npcData.MaxMana);
            this.SetPower(MaximumPower);

            this.threatTable       = new Dictionary <MmoGuid, float>();
            this.CurrentAggroState = AggroState.Idle;

            this.visibleCharacters = new Dictionary <Character, IDisposable>();

            this.radarEnterRadius = ServerGameSettings.BASE_AGGRO_RADIUS;
            this.radarExitRadius  = ServerGameSettings.BASE_AGGRO_DROP_RADIUS;

            this.ai        = npcType == NpcType.Enemy ? (NpcAI) new NpcAggressiveAI(this) : new NpcDefensiveAI(this);
            this.inventory = npcData.Items;
        }
示例#4
0
            void TryGetNewPet(BaseNpc npcPet)
            {
                var ownedAi = npcPet.GetComponent <NpcAI>();

                if (ownedAi != null && ownedAi.owner != this)
                {
                    UserMessage(player, "isPet");
                    return;
                }

                if (nextControlTime >= UnityEngine.Time.realtimeSinceStartup)
                {
                    UserMessage(player, "tooFast");
                    return;
                }

                if (usePermissions && !ins.permission.UserHasPermission(player.UserIDString, $"pets.{npcPet.ShortPrefabName}"))
                {
                    UserMessage(player, "noPerms");
                    return;
                }

                nextControlTime = UnityEngine.Time.realtimeSinceStartup + tameTimer;

                npcAi       = npcPet.gameObject.AddComponent <NpcAI>();
                npcAi.owner = this;

                UserMessage(player, "petSet");
            }
示例#5
0
    private void RegistNpcPool()
    {
        for (int i = 0; i < mNpcInfo.Count; i++)
        {
            mNpcInfo[i].Init();
            for (int j = 0; j < maxNpcCount; j++)
            {
                GameObject temp = Instantiate(mNpcInfo[i].Prefab);
                temp.SetActive(false);
                NpcAI ai = temp.GetComponent <NpcAI>();
                ai.Init(mNpcInfo[i]);

                if (mNpcPool.ContainsKey(mNpcInfo[i].name))
                {
                    mNpcPool[mNpcInfo[i].name].Add(temp);
                }
                else
                {
                    List <GameObject> lTemp = new List <GameObject>();
                    mNpcPool.Add(mNpcInfo[i].name, lTemp);
                    mNpcKeys.Add(mNpcInfo[i].name);
                    lTemp.Add(temp);
                }
            }
        }
    }
示例#6
0
            void TryGetNewPet(BaseNPC npcPet)
            {
                var OwnedNpc = npcPet.GetComponent <NpcAI>();

                if (OwnedNpc != null && OwnedNpc.owner != this)
                {
                    owner.ChatMessage(NoOwn);
                    return;
                }

                if (NextTimeToControl >= Time.realtimeSinceStartup)
                {
                    owner.ChatMessage(ReloadMsg);
                    return;
                }

                if (UsePermission && !PluginInstance.HasPermission(owner, "can" + npcPet.mdlPrefab.Get().name.Replace("_skin", "")))
                {
                    owner.ChatMessage(NoPermPetMsg);
                    return;
                }

                NextTimeToControl = Time.realtimeSinceStartup + ReloadControl;

                npc       = npcPet.gameObject.AddComponent <NpcAI>();
                npc.owner = this;

                owner.ChatMessage(NewPetMsg);
            }
示例#7
0
 private void CheckAndInitAI()
 {
     if (!IsFuncNpc)
     {
         _ai = new NpcAI();
         _ai.Init(this);
     }
 }
示例#8
0
 public PetInfo(NpcAI pet)
 {
     x           = pet.transform.position.x;
     y           = pet.transform.position.y;
     z           = pet.transform.position.z;
     prefabID    = pet.Base.prefabID;
     inventory   = pet.inventory.Save().ToProtoBytes();
     NeedToSpawn = false;
 }
示例#9
0
        private object CanAnimalAttack(BaseNpc entity, BasePlayer player)
        {
            NpcAI npcAi = entity.GetComponent <NpcAI>();

            if (npcAi != null && npcAi.owner.player == player)
            {
                return(false);
            }
            return(null);
        }
示例#10
0
        private object CanNPCEat(BaseNpc entity, BaseEntity target)
        {
            NpcAI npcAi = entity.GetComponent <NpcAI>();

            if (npcAi != null)
            {
                return(npcAi.action == Act.Eat);
            }
            return(null);
        }
示例#11
0
 public void SuccessQuest1a(Quest quest, QuestGiver qg, NpcAI npcai)
 {
     quest.GiveWhatYouGot(giverInventory, playerInventory);
     foreach (QuestObjective obj in quest.questObjectives)
     {
         playerInventory.GiveItem(giverInventory, obj.objectToGather);
     }
     journal.InsertQuestCompleted(quest, npcai);
     CloseQuestWindow();
 }
示例#12
0
 public void AddQuest(Quest quest, QuestGiver qg, NpcAI npcAI = null)
 {
     if (!HasQuest(quest))
     {
         quest.Init(qg);
         questList.Add(quest);
         questGivers.Add(quest, qg);
         InsertQuestStarted(quest, qg, npcAI);
     }
 }
示例#13
0
 void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
 {
     if (entity is BaseNPC)
     {
         NpcAI ai = entity.GetComponent <NpcAI>();
         if (ai != null)
         {
             ai.OnAttacked(hitInfo);
         }
     }
 }
示例#14
0
    public void InsertQuestStarted(Quest quest, QuestGiver qg, NpcAI npcAI = null)
    {
        string entryTxt = "I embarked upon a new quest";

        if (npcAI != null)
        {
            entryTxt += " after talking to " + npcAI.gameObject.GetComponent <WorldObject>().objectTitle;
        }
        entryTxt += ". ";
        entryTxt += quest.questDescription;
        JournalEntry entry = new JournalEntry(EntryTypes.Quest, entryTxt, quest, null);

        InsertEntry(entry);
    }
示例#15
0
 void OnServerSave()
 {
     UnityEngine.Object[] objects = GameObject.FindObjectsOfType(typeof(NpcAI));
     if (objects != null)
     {
         Puts("Saving pets...");
         foreach (UnityEngine.Object gameObj in objects)
         {
             NpcAI pet = gameObj as NpcAI;
             SaveNpcList[pet.owner.owner.userID.ToString()] = new PetInfo(pet);
         }
         Interface.GetMod().DataFileSystem.WriteObject("Pets", SaveNpcList);
     }
 }
示例#16
0
    private void Awake()
    {
        GameObject player = GameObject.Find("Player");

        journal         = player.GetComponent <Journal>();
        playerInventory = player.GetComponent <Inventory>();
        GameObject gh = GameObject.Find("GameHandler");

        gameHandler    = gh.GetComponent <GameHandler>();
        guiHandler     = gh.GetComponent <GUIHandler>();
        dialogHandler  = gh.GetComponent <DialogHandler>();
        npcAI          = GetComponent <NpcAI>();
        giverInventory = GetComponent <Inventory>();
        gameHandler.allQuests.Add(quest);
    }
示例#17
0
    private void RespawnNpc()
    {
        if (mNpcSpawnTime == 0)
            mNpcSpawnTime = Random.Range(10, mMaxNpcSpawnTime);

        mNpcCurTime += Time.deltaTime;
        if (mNpcCurTime < mNpcSpawnTime) return;

        GameObject npc = GameManager.Instance.ObjPool.GetRandomNpc();
        NpcAI ai = npc.GetComponent<NpcAI>();
        if (ai.SpawnNpc())
            npc.SetActive(true);
        
        mNpcCurTime = 0f;
        mNpcSpawnTime = 0f;
    }
示例#18
0
        public Npc(int id, Ship ship, Spacemap spacemap, Position position) : base(id, ship.Name, 0, ship, position, spacemap, GameManager.GetClan(0))
        {
            Spacemap.AddCharacter(this);

            ShieldAbsorption = 0.8;

            Damage              = ship.Damage;
            MaxHitPoints        = ship.BaseHitpoints;
            CurrentHitPoints    = MaxHitPoints;
            MaxShieldPoints     = ship.BaseShieldPoints;
            CurrentShieldPoints = MaxShieldPoints;

            NpcAI = new NpcAI(this);

            Program.TickManager.AddTick(this);
        }
示例#19
0
    private void InteractWorldObject(WorldObject worldObject)
    {
        justInteracted = true;

        QuestGiver questGiver = null;

        questGiver = worldObject.gameObject.GetComponent <QuestGiver>();

        if (questGiver != null)
        {
            NpcAI npcai = worldObject.gameObject.GetComponent <NpcAI>();
            npcai.lastState = npcai.npcState;
            npcai.npcState  = NPCState.Busy;
            questGiver.InteractWithQuestGiver(worldObject.objectTitle, npcai);
        }
    }
示例#20
0
    public void InsertQuestFailed(Quest quest, NpcAI npcAI = null)
    {
        //entry quest schrijven
        string entryTxt = "I failed the quest '" + quest.questTitle + "' that I got";

        if (npcAI != null)
        {
            entryTxt += " after talking to " + npcAI.gameObject.GetComponent <WorldObject>().objectTitle;
        }
        entryTxt += ". ";
        entryTxt += quest.questDescription;

        JournalEntry entry = new JournalEntry(EntryTypes.Quest, entryTxt, quest, null);

        InsertEntry(entry);

        //popularityWithNPC bijwerken
        AddPopularityDictionary(quest.popularityWithNPCFailed);
    }
示例#21
0
    public void InteractWithQuestGiver(string npc, NpcAI ai, RelevantPosition rp = null)
    {
        relevantPosition = rp;
        npcAI            = ai;
        switch (quest.questStatus)
        {
        case QuestStatus.Closed:
            //als de quest closed is, niks tonen. de quest is niet beschikbaar.
            break;

        case QuestStatus.Open:
            QuestOpen(npc);
            break;

        case QuestStatus.Pending:
            QuestPending(npc);
            break;

        case QuestStatus.Active:
            QuestActive(npc);
            break;

        case QuestStatus.Successful:
            if (quest.returnToGiver)
            {
                QuestSuccessful(npc);
            }
            else
            {
                QuestCompleted(npc);
            }
            break;

        case QuestStatus.Failed:
            QuestFailed(npc);
            break;

        case QuestStatus.Completed:
            QuestCompleted(npc);
            break;
        }
    }
示例#22
0
    static public HUD_GuestCondition GetUI(NpcAI ai)
    {
        HUD_GuestCondition temp = null;

        for (int i = 0; i < mConditions.Count; i++)
        {
            if (mConditions[i].gameObject.activeSelf)
            {
                continue;
            }

            temp = mConditions[i];
            temp.transform.position = Camera.main.WorldToScreenPoint(ai.transform.position);
            temp.TargetInfo         = ai.Info;
            temp.gameObject.SetActive(true);
            break;
        }

        return(temp);
    }
示例#23
0
    // ==================================================================
    //                           Buttonfuncties
    // ==================================================================


    public void AcceptQuest(Quest quest, QuestGiver qg, NpcAI npcai)
    {
        quest.questStatus = QuestStatus.Active;
        journal.AddQuest(quest, qg, npcAI);
        CloseQuestWindow();

        int ob = 0;
        int oc = quest.questObjectives.Length;

        foreach (QuestObjective qo in quest.questObjectives)
        {
            qo.CheckObjectiveCompleted();
            if (qo.objectiveStatus == ObjectiveStatus.Completed)
            {
                ob++;
            }
        }
        if (ob == oc)
        {
            quest.questStatus = QuestStatus.Successful;
        }
    }
示例#24
0
    public void Talk(NpcAI npc, string title, string text, string button1, string button2, FireButton fb1, FireButton fb2, Quest quest = null, QuestGiver giver = null)
    {
        gameHandler.isPaused = true;
        questGiver           = giver;
        // generieke manier om dialoog op te zetten. berichten en worden gepassed naar deze method
        Time.timeScale = 0;
        npcAI          = npc;
        ToggleDialog(true);
        if (npc != null)
        {
            guiHandler.ViewGUImessage(guiHandler.dialogPartner, npc.gameObject.GetComponent <WorldObject>().objectTitle);
        }
        else
        {
            guiHandler.ViewGUImessage(guiHandler.dialogPartner, "Object");
        }
        guiHandler.ViewGUImessage(guiHandler.dialogTitle, title);
        guiHandler.ViewGUImessage(guiHandler.dialogDescription, text);
        guiHandler.ViewGUImessage(guiHandler.dialogButton1, button1);
        guiHandler.ViewGUImessage(guiHandler.dialogButton2, button2);

        PressButton1  = fb1;
        PressButton2  = fb2;
        questInDialog = quest;

        buttonClick1.gameObject.SetActive(true);
        buttonClick2.gameObject.SetActive(true);
        if (button1 == "")
        {
            buttonClick1.gameObject.SetActive(false);
        }
        if (button2 == "")
        {
            buttonClick2.gameObject.SetActive(false);
        }
    }
示例#25
0
 public void FinishExamine(Quest q, QuestGiver qg, NpcAI n)
 {
     dialogHandler.ToggleDialog(false);
     gameHandler.isPaused = false;
 }
示例#26
0
        /// <summary>
        /// Creates a new npc and adds it to the game. (No other components created)
        /// </summary>
        /// <param name="name">The type of npc to create.</param>
        public uint CreateNPC(NPCName name, Position position)
        {
            uint eid = Entity.NextEntity();
            NPC npc;
            Sprite sprite;
            Collideable collideable;
            Texture2D spriteSheet;
            Movement movement;
            SpriteAnimation spriteAnimation;
            NpcAI ai;

            switch (name)
            {
                case NPCName.Trollph:
                     sprite = new Sprite()
                        {
                            EntityID = eid,
                            SpriteSheet = _game.Content.Load<Texture2D>("Spritesheets/NPC/trollph"),
                            SpriteBounds = new Rectangle(0, 0, 64, 64),
                        };

                        ai = new NpcAI()
                        {
                            EntityID = eid,
                            Type = NPCType.Background,
                        };
                        _game.NpcAIComponent.Add(eid, ai);

                        break;
                case NPCName.DarkRalph:

                        sprite = new Sprite()
                        {
                            EntityID = eid,
                            SpriteSheet = _game.Content.Load<Texture2D>("Spritesheets/NPC/darkralph"),
                            SpriteBounds = new Rectangle(0, 0, 64, 64),
                        };

                         ai = new NpcAI()
                         {
                            EntityID = eid,
                            Type = NPCType.Background,
                         };
                        _game.NpcAIComponent.Add(eid, ai);

                        break;

                    default:
                        throw new Exception("Unknown NPC");
                }

                npc.EntityID = eid;
                npc.Type = name;
                position.EntityID = eid;

                spriteAnimation = new SpriteAnimation()
                {
                    EntityID = eid,
                    FramesPerSecond = 10,
                    IsLooping = true,
                    IsPlaying = false,
                    TimePassed = 0f,
                    CurrentFrame = 0,
                    CurrentAnimationRow = 0

                };
                _game.SpriteAnimationComponent[eid] = spriteAnimation;

                movement = new Movement()
                {
                    EntityID = eid,
                };

                _game.MovementComponent[eid] = movement;

                collideable = new Collideable()
                {
                    EntityID = eid,
                    RoomID = position.RoomID,
                    Bounds = new CircleBounds(position.Center, position.Radius)
                };
                _game.CollisionComponent[eid] = collideable;

                _game.NPCComponent.Add(eid, npc);
                _game.PositionComponent.Add(eid, position);
                _game.SpriteComponent.Add(eid, sprite);
                return eid;
        }
示例#27
0
 public void CompletedQuest(Quest quest, QuestGiver qg, NpcAI npcai)
 {
     CloseQuestWindow();
 }
示例#28
0
 public void CompletedQuestUnblock(Quest quest, QuestGiver qg, NpcAI npcai)
 {
     CloseQuestWindow();
     relevantPosition.busyFirstThing = false;
 }
示例#29
0
        /// <summary>
        /// Creates a new npc and adds it to the game. (No other components created)
        /// </summary>
        /// <param name="name">The type of npc to create.</param>
        public uint CreateNPC(NPCName name, Position position)
        {
            uint            eid = Entity.NextEntity();
            NPC             npc;
            Sprite          sprite;
            Collideable     collideable;
            Texture2D       spriteSheet;
            Movement        movement;
            SpriteAnimation spriteAnimation;
            NpcAI           ai;

            switch (name)
            {
            case NPCName.Trollph:
                sprite = new Sprite()
                {
                    EntityID     = eid,
                    SpriteSheet  = _game.Content.Load <Texture2D>("Spritesheets/trollph"),
                    SpriteBounds = new Rectangle(0, 0, 64, 64),
                };

                ai = new NpcAI()
                {
                    EntityID = eid,
                    Type     = NPCType.Background,
                };
                _game.NpcAIComponent.Add(eid, ai);

                break;

            case NPCName.DarkRalph:

                sprite = new Sprite()
                {
                    EntityID     = eid,
                    SpriteSheet  = _game.Content.Load <Texture2D>("Spritesheets/darkralph"),
                    SpriteBounds = new Rectangle(0, 0, 64, 64),
                };


                ai = new NpcAI()
                {
                    EntityID = eid,
                    Type     = NPCType.Background,
                };
                _game.NpcAIComponent.Add(eid, ai);

                break;

            default:
                throw new Exception("Unknown NPC");
            }

            npc.EntityID      = eid;
            npc.Type          = name;
            position.EntityID = eid;

            spriteAnimation = new SpriteAnimation()
            {
                EntityID            = eid,
                FramesPerSecond     = 10,
                IsLooping           = true,
                IsPlaying           = false,
                TimePassed          = 0f,
                CurrentFrame        = 0,
                CurrentAnimationRow = 0
            };
            _game.SpriteAnimationComponent[eid] = spriteAnimation;

            movement = new Movement()
            {
                EntityID = eid,
            };

            _game.MovementComponent[eid] = movement;

            collideable = new Collideable()
            {
                EntityID = eid,
                Bounds   = new CircleBounds(position.Center, position.Radius)
            };
            _game.CollisionComponent[eid] = collideable;

            _game.NPCComponent.Add(eid, npc);
            _game.PositionComponent.Add(eid, position);
            _game.SpriteComponent.Add(eid, sprite);
            return(eid);
        }
示例#30
0
 public void OkButton(Quest quest, QuestGiver qg, NpcAI npcai)
 {
     CloseQuestWindow();
 }
示例#31
0
 public void DoNothing(Quest q, QuestGiver qg, NpcAI n)
 {
     //als standaardfunctie om niks te doen nav een knop.
     ToggleDialog(false);
 }