Beispiel #1
0
    public void initRequest(puzzlegen.relationship.ItemRequestRelationship request)
    {
        _hasRequest       = true;
        _requestFulfilled = false;
        if (_properties.ContainsKey("requesttext") && (string)(_properties["requesttext"]) != "")
        {
            string existingText = _properties["requesttext"] as string;
            existingText = existingText.Replace("REQUEST", request.requestedName);
            existingText = existingText.Replace("PROPERTY", request.requestedPropertyValue as string);
            existingText = existingText.Replace("REWARD", request.rewardItem.Name);
            _properties["requesttext"] = existingText;
        }
        if (_properties.ContainsKey("postrequesttext") && (string)(_properties["postrequesttext"]) != "")
        {
            string existingText = _properties["postrequesttext"] as string;
            existingText = existingText.Replace("REQUEST", request.requestedName);
            existingText = existingText.Replace("PROPERTY", request.requestedPropertyValue as string);
            existingText = existingText.Replace("REWARD", request.rewardItem.Name);
            _properties["postrequesttext"] = existingText;
        }
        if (!_properties.ContainsKey("wrongitemtext") || (string)(_properties["wrongitemtext"]) == "")
        {
            _properties["wrongitemtext"] = "That's not right. I wanted the REQUEST";
        }
        string wrongItemText = _properties["wrongitemtext"] as string;

        wrongItemText = wrongItemText.Replace("REQUEST", request.requestedName);
        wrongItemText = wrongItemText.Replace("PROPERTY", request.requestedPropertyValue as string);
        wrongItemText = wrongItemText.Replace("REWARD", request.rewardItem.Name);
        _properties["wrongitemtext"] = wrongItemText;

        if (!_properties.ContainsKey("wrongpropertytext") || (string)(_properties["wrongpropertytext"]) == "")
        {
            _properties["wrongpropertytext"] = "That's not right. I wanted the PROPERTY REQUEST";
        }

        string wrongPropertyText = _properties["wrongpropertytext"] as string;

        wrongPropertyText = wrongPropertyText.Replace("REQUEST", request.requestedName);
        wrongPropertyText = wrongPropertyText.Replace("PROPERTY", request.requestedPropertyValue as string);
        wrongPropertyText = wrongPropertyText.Replace("REWARD", request.rewardItem.Name);
        _properties["wrongpropertytext"] = wrongPropertyText;

        if (!_properties.ContainsKey("fulfilledtext") || (string)(_properties["fulfilledtext"]) == "")
        {
            _properties["fulfilledtext"] = "Great! Here you go!";
        }

        string fulfilledText = _properties["fulfilledtext"] as string;

        fulfilledText = fulfilledText.Replace("REQUEST", request.requestedName);
        fulfilledText = fulfilledText.Replace("PROPERTY", request.requestedPropertyValue as string);
        fulfilledText = fulfilledText.Replace("REWARD", request.rewardItem.Name);
        _properties["fulfilledtext"] = fulfilledText;
    }
Beispiel #2
0
        protected void onSuccess(string outputName, string giverName, string requestName, PuzzleOutput giverInput, PuzzleOutput requestInput, string propertyName, object propertyVal)
        {
            if (_verbose) Debug.Log(string.Format("Successfully generated item request puzzle with {0} as giver and {1} as requested item and {2} as reward.", giverName, requestName, outputName));
            _itemsToSpawn.AddRange(giverInput.Items);
            _itemsToSpawn.AddRange(requestInput.Items);
            _relationshipsToSpawn.AddRange(giverInput.Relationships);
            _relationshipsToSpawn.AddRange(requestInput.Relationships);

            ItemRequestRelationship requestRelationship = new ItemRequestRelationship(giverName, _requesterInput.outputSpawnIndex(), requestName, _requestedInput.outputSpawnIndex(), _spawnedOutput, propertyName, propertyVal);
            _relationshipsToSpawn.Add(requestRelationship);
        }
    public void accept(ItemRequestRelationship rel)
    {
        // Give one item to another.

        SpawnedPuzzleItem requested, requester;
        if (rel.requestedName == _item1.itemName) {
            requested = _item1;
            requester = _item2;
        }
        else {
            requested = _item2;
            requester = _item1;
        }
        // If the requester is inside something, have to remove it first
        if (requester.insideItem) {
            PlayState.instance.addPlayerText(string.Format("Have to remove the {0} first.", requester.itemName));
            return;
        }
        // Check to see if the item has the requested property
        if (rel.requestedPropertyName != null && (!requested.propertyExists(rel.requestedPropertyName) || requested.getProperty(rel.requestedPropertyName) != rel.requestedPropertyValue)) {
            requester.activateText(requester.npcWrongPropertyText());
            return;
        }
        requester.requestFulfilled = true;
        PlayState.instance.playAudio(PlayState.instance.pickupClip);
        // On success, destroy the old item and spawn the new one.
        if (requested.inInventory)
            requested.currentSlot.removeItem();
        if (requested.insideItem)
            requested.removeFromOtherItem();
        requested.die();

        SpawnedPuzzleItem itemToSpawn = spawnItem(rel.rewardItem);
        if (itemToSpawn.carryable) {
            itemToSpawn.init();
            itemToSpawn.addToInventory();
        }
        else {
            _currentRoom.addPiece(itemToSpawn);
        }

        // Display the fulfilled text.
        requester.activateText(requester.npcFulfilledText());
    }
Beispiel #4
0
    public void accept(ItemRequestRelationship rel)
    {
        // First, add this to our list of requests
        _requests[rel.requesterName] = rel;

        // Add the item request relationship to the map
        if (!_relationshipMap.ContainsKey(rel.requesterName))
            _relationshipMap[rel.requesterName] = new Dictionary<string, IRelationship>();
        _relationshipMap[rel.requesterName][rel.requestedName] = rel;
        if (!_relationshipMap.ContainsKey(rel.requestedName))
            _relationshipMap[rel.requestedName] = new Dictionary<string, IRelationship>();
        _relationshipMap[rel.requestedName][rel.requesterName] = rel;

        // Make sure the reward item is included in the list of item names
        _itemNames.Add(rel.rewardItem.Name);
    }