// This loops through all the targets, giving each target the quest.
    //  <triggered_effect trigger="onSelfBuffStart" action="GiveQuestSDX, Mods" target="self" quest="myNewQuest" />
    public override void Execute(MinEventParams _params)
    {
        for (int j = 0; j < this.targets.Count; j++)
        {
            EntityAliveSDX entity = this.targets[j] as EntityAliveSDX;
            if (entity != null)
            {
                if (string.IsNullOrEmpty(this.strQuest))
                {
                    continue;
                }

                entity.GiveQuest(this.strQuest);
            }

            // If the target is a player.
            EntityPlayerLocal Playerentity = this.targets[j] as EntityPlayerLocal;
            if (Playerentity != null)
            {
                if (string.IsNullOrEmpty(this.strQuest))
                {
                    continue;
                }

                Quest myQuest = QuestClass.CreateQuest(this.strQuest);
                myQuest.QuestGiverID = -1;
                Playerentity.QuestJournal.AddQuest(myQuest);
            }
        }
    }
예제 #2
0
    public static void AddQuestToRadius(String strQuest, Vector3 position, int Radius)
    {
        // If there's no radius, pick 30 blocks.
        if (Radius <= 0)
        {
            Radius = 30;
        }

        World         world            = GameManager.Instance.World;
        List <Entity> entitiesInBounds = GameManager.Instance.World.GetEntitiesInBounds(null, new Bounds(position, Vector3.one * Radius));

        if (entitiesInBounds.Count > 0)
        {
            for (int i = 0; i < entitiesInBounds.Count; i++)
            {
                EntityAliveSDX entity = entitiesInBounds[i] as EntityAliveSDX;
                if (entity != null)
                {
                    entity.QuestJournal.AddQuest(QuestClass.CreateQuest(strQuest));
                }

                EntityPlayerLocal player = entitiesInBounds[i] as EntityPlayerLocal;
                if (player != null)
                {
                    player.QuestJournal.AddQuest(QuestClass.CreateQuest(strQuest));
                }
            }
        }
    }
    public override void PerformAction(EntityPlayer player)
    {
        Quest NewQuest = QuestClass.CreateQuest(ID);

        if (NewQuest == null)
        {
            return;
        }

        player.QuestJournal.RemoveQuest(NewQuest);
        player.QuestJournal.AddQuest(NewQuest);
    }
예제 #4
0
    public override void GiveReward(EntityPlayer player)
    {
        Quest quest = QuestClass.CreateQuest(base.ID);

        if (base.OwnerQuest != null)
        {
            quest.PreviousQuest = GetQuest(base.OwnerQuest.ID).Name;
        }

        if (GameManager.Instance.World.Entities.dict.ContainsKey(base.OwnerQuest.SharedOwnerID))
        {
            EntityAliveSDX questEntity = GameManager.Instance.World.Entities.dict[base.OwnerQuest.SharedOwnerID] as EntityAliveSDX;
            if (questEntity == null)
            {
                return;
            }
            questEntity.QuestJournal.AddQuest(quest);
        }
    }
예제 #5
0
    public void GiveQuest(String strQuest)
    {
        // Don't give duplicate quests.
        foreach (Quest quest in QuestJournal.quests)
        {
            if (quest.ID == strQuest.ToLower())
            {
                return;
            }
        }

        // Make sure the quest is valid
        Quest NewQuest = QuestClass.CreateQuest(strQuest);

        if (NewQuest == null)
        {
            return;
        }

        // If there's no shared owner, it tries to read the PlayerLocal's entity ID. This entity doesn't have that.
        NewQuest.SharedOwnerID = entityId;
        NewQuest.QuestGiverID  = -1;
        QuestJournal.AddQuest(NewQuest);
    }
예제 #6
0
    // Play the music when its activated. We stop the sound broadcasting, in case they want to restart it again; otherwise we can get two sounds playing.
    public override bool OnBlockActivated(int _indexInBlockActivationCommands, WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player)
    {
        #region OnBlockActivated

        // If there's no transform, no sense on keeping going for this class.
        BlockEntityData _ebcd = _world.GetChunkFromWorldPos(_blockPos).GetBlockEntity(_blockPos);
        if (_ebcd == null || _ebcd.transform == null)
        {
            return(false);
        }

        MusicBoxScript myMusicBoxScript = _ebcd.transform.GetComponent <MusicBoxScript>();
        if (myMusicBoxScript == null)
        {
            myMusicBoxScript = _ebcd.transform.gameObject.AddComponent <MusicBoxScript>();
        }

        bool bRuntimeSwitch = myMusicBoxScript.enabled;


        // Turn off the music box before we do anything with it.
        myMusicBoxScript.enabled = false;

        if (_indexInBlockActivationCommands != 0)
        {
            if (_indexInBlockActivationCommands == 1)
            {
                base.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
            }

            if (_indexInBlockActivationCommands == 2)
            {
                TakeItemWithTimer(_cIdx, _blockPos, _blockValue, _player);
            }
        }
        else
        {
            bRuntimeSwitch = !bRuntimeSwitch;

            // Check if we have an animator and set it
            myMusicBoxScript.anim = _ebcd.transform.GetComponent <Animator>();

            // Check if we have a video player as well.
            myMusicBoxScript.videoPlayer = _ebcd.transform.GetComponent <VideoPlayer>();

            myMusicBoxScript.myBlockPos = _blockPos;
            // If the switch is on, then we want to look in the loot container to find a reference to any potential items,
            // which will over-ride the default audio clip / video clip.
            if (bRuntimeSwitch)
            {
                // We'll try to support getting sounds from multiple sound data nodes, based on all the items in the loot container.
                List <String> mySounds = new List <String>();
                List <String> myVideos = new List <String>();

                TileEntityLootContainer tileLootContainer = (TileEntityLootContainer)_world.GetTileEntity(_cIdx, _blockPos);

                if (tileLootContainer.items != null)
                {
                    ItemStack[] array = tileLootContainer.items;
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (array[i].IsEmpty())
                        {
                            continue;
                        }

                        if (array[i].itemValue.ItemClass.Properties.Values.ContainsKey("OnPlayBuff"))
                        {
                            String Buff = array[i].itemValue.ItemClass.Properties.Values["OnPlayBuff"];
                            _player.Buffs.AddBuff(Buff);
                        }

                        if (array[i].itemValue.ItemClass.Properties.Values.ContainsKey("OnPlayQuest"))
                        {
                            String Quest = array[i].itemValue.ItemClass.Properties.Values["OnPlayQuest"];
                            if (_player is EntityPlayerLocal)
                            {
                                Quest myQuest = QuestClass.CreateQuest(Quest);
                                if (myQuest != null)
                                {
                                    (_player as EntityPlayerLocal).QuestJournal.AddQuest(myQuest);
                                }
                            }
                        }
                        // Check for a SoundDataNode for a potential sound clip.
                        if (array[i].itemValue.ItemClass.Properties.Values.ContainsKey("SoundDataNode"))
                        {
                            String strSound = array[i].itemValue.ItemClass.Properties.Values["SoundDataNode"];
                            if (!mySounds.Contains(strSound))
                            {
                                mySounds.Add(strSound);
                            }
                        }
                        // Check for a video Source for a video clip. If we find it, load the asset and add it to the music box script.
                        if (array[i].itemValue.ItemClass.Properties.Values.ContainsKey("VideoSource"))
                        {
                            // Check if the video source is an asset bundle, and if so, load it directly into the video clip on
                            String strVideo = array[i].itemValue.ItemClass.Properties.Values["VideoSource"];
                            if (strVideo.IndexOf('#') == 0 && strVideo.IndexOf('?') > 0)
                            {
                                if (!myVideos.Contains(strVideo))
                                {
                                    myVideos.Add(strVideo);
                                }
                            }
                        }
                    }
                }

                // Initialize the data with our defaults.
                myMusicBoxScript.strAudioSource = this.strAudioSource;
                myMusicBoxScript.strSoundSource = this.strSoundSource;
                myMusicBoxScript.strVideoSource = this.strVideoSource;
                myMusicBoxScript.myEntity       = _player;

                // List of Videos and Sound clips.
                myMusicBoxScript.VideoGroups = myVideos;
                myMusicBoxScript.SoundGroups = mySounds;

                myMusicBoxScript.myVideoClip = null;
                myMusicBoxScript.enabled     = bRuntimeSwitch;
            }
        }


        return(false);

        #endregion
    }