Пример #1
0
    public override void NPCActionBeforeSpeaking()
    {
        //Check to make sure that the player has not already created fire.
        if (playerHasCreatedFire == false)
        {
            if (CurrentLevelVariableManagement.GetMainObjectiveManager().CheckStateOfObjective(5))               //Check whether the player has created fire;
            {
                playerHasCreatedFire = true;
                string[] dialogue = new string[] {
                    "Nice job!",
                    "I wish you luck on your travels."
                };
                GetComponent <NPCPanelController> ().SetCharacterDialogue(dialogue);
            }
        }

        //Check whether the NPC has talked to the player
        if (talkedToPlayer && playerHasCreatedFire == false)
        {
            string[] dialogue = new string[] {
                "Hello again!  Forgot already?",
                "While on me many travels, I discovered something that will change our lives forever.",
                "I call it FIRE.",
                "Here's how you make it.  Gather some wood.  6 blocks should be enough.",
                "Combine them to make 3 planks.",
                "Then burn a bit of wood to make charcoal, and combine that with the planks."
            };
            GetComponent <NPCPanelController>().SetCharacterDialogue(dialogue);
        }
    }
Пример #2
0
    //Assigns a new item to the best possible slot.
    public bool AssignNewItemToBestSlot(ResourceReferenceWithStack item)
    {
        //Has to be here for the return statement
        bool successfullyAssigned = false;

        //Make sure that the prerequisites are met.
        if (initialized && item != null)
        {
            SlotScript bestAvailableSlot = FindBestAvailableSlot(item);

            if (bestAvailableSlot != null)
            {
                //Set successfully assigned.
                successfullyAssigned = true;
                //Add the new stack to the current item stack.
                bestAvailableSlot.ModifyCurrentItemStack(item.stack);
                Debug.Log("Assigned " + item.uiSlotContent.itemScreenName + " to slot with items of same type.");
                //Check whether an objective has been completed
                CurrentLevelVariableManagement.GetMainObjectiveManager().OnNewItemAddedToPlayerInventory();
            }
            else
            {
                Debug.Log("Could not stack item: Attempting to add to an empty slot");
                bestAvailableSlot = FindBestAvailableNullSlot();
                if (bestAvailableSlot != null)
                {
                    successfullyAssigned = true;
                    bestAvailableSlot.AssignNewItem(item);
                    //Update the hotbar item.
                    CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Hotbar").GetComponent <HotbarManager> ().UpdateSelectedItem();
                    //Check whether an objective has been completed
                    CurrentLevelVariableManagement.GetMainObjectiveManager().OnNewItemAddedToPlayerInventory();
                }
                else
                {
                    Debug.LogError("No slots are empty!");
                }
            }
        }
        else
        {
            if (initialized == false && item == null)
            {
                Debug.LogError("Not initialized and item is null");
            }
            else if (initialized == false)
            {
                Debug.LogError("Not initialized");
            }
            else
            {
                Debug.LogError("Item is null");
            }
        }

        return(successfullyAssigned);
    }
Пример #3
0
    public void TreeChopped()
    {
        currentlyActiveSegments--;
        UpdateTree();
        DropItems();
        if (currentlyActiveSegments == 0)
        {
            Destroy(gameObject);
        }

        CurrentLevelVariableManagement.GetMainObjectiveManager().OnTreeChopped();
    }
Пример #4
0
    //Add/subtract coins.
    public bool UpdateCoinValue(int valueToAdd)
    {
        //In case an objective depends on this.
        CurrentLevelVariableManagement.GetMainObjectiveManager().OnMoneyModified(valueToAdd);
        //Determine the new coin value.
        int newCoinValue = int.Parse(coinValue.text) + valueToAdd;

        if (newCoinValue >= 0)
        {
            coinValue.text = newCoinValue.ToString();
            return(true);
        }
        else
        {
            return(false);
        }
    }
Пример #5
0
 //No initialization is required, when the thing is instantiated the particle system should start.  The only real
 //required functionality is linecasting.
 public void OnFireCreated()
 {
     CurrentLevelVariableManagement.GetMainObjectiveManager().OnFireBuilt();
     //Normally this would start right now.
     //StartCoroutine ("LookForCookableFood");
 }