示例#1
0
 //Set references to the playerIcon, start necessary coroutines, etc.
 void InitializeNPCPanelController()
 {
     playerTransform   = CurrentLevelVariableManagement.GetPlayerReference().transform;
     playerIcon        = transform.Find("FlippingItem").Find("Character").Find("Head").GetComponent <SpriteRenderer> ().sprite;
     mainSpeechControl = CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Speech Bubble").GetComponent <SpeechControl> ();
     mainInteractablePanelController = CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("InteractablePanels").gameObject.GetComponent <InteractablePanelController> ();
     StartCoroutine("CheckForAndAttemptToSpeakToPlayer");
 }
示例#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);
    }
 //Look into initializing this once the player comes into activation distance.
 protected virtual void InitializeHealthBar()
 {
     player        = CurrentLevelVariableManagement.GetPlayerReference().transform;
     currentHealth = lifePoints;
     //Create panel
     uiHealthController = CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Health Controller").gameObject.GetComponent <UIHealthController> ();
     //Initialize icon
     characterHeadSprite = transform.GetChild(0).GetChild(0).Find("Head").GetComponent <SpriteRenderer> ().sprite;
     //Start the coroutine that manages the active state of the health bar item.
     StartCoroutine(ControlHealthBarState());
 }
示例#4
0
    protected override void InitializeNPC()
    {
        //Find and hide the inventory.
        merchantInventory = CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Merchant Inventory").GetComponent <MerchantInventoryFunctions> ();

        //Define the UISlotContent items that will be added to the inventory.
        merchantItems     = new ResourceReferenceWithStackAndPrice[2];
        merchantItems [0] = new ResourceReferenceWithStackAndPrice(new ResourceReferenceWithStack(ResourceDatabase.GetItemByParameter("Wooden Hatchet"), 1), 10);
        merchantItems [1] = new ResourceReferenceWithStackAndPrice(new ResourceReferenceWithStack(ResourceDatabase.GetItemByParameter("Diamond Sword"), 2), 20);

        string[] dialogue = new string[] {
            "Purchase any item you like!",
            "Everything is cheap at Sluk's Hardware Store!"
        };
        GetComponent <NPCPanelController> ().SetCharacterDialogue(dialogue);
    }
示例#5
0
    protected override void InitializeHealthBar()
    {
        if (lifePoints <= 0)
        {
            Debug.Log("Player health is " + lifePoints + " which is an invalid value.  Switching to 10.");
            lifePoints = 10;
        }
        currentHealth = lifePoints;
        //Create panel
        uiHealthController         = CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Health Controller").gameObject.GetComponent <UIHealthController> ();
        playerHealthPanelReference = uiHealthController.GetPlayerHealthPanelReference();
        //Initialize icon
        characterHeadSprite = transform.Find("FlippingItem").GetChild(0).Find("Head").GetComponent <SpriteRenderer> ().sprite;
        playerHealthPanelReference.InitializePanel(characterHeadSprite, lifePoints, currentHealth);

        //Give player money obtained previously.
        GiveMoneyToPlayer(CurrentLevelVariableManagement.GetMainGameData().currentPlayerMoney);
    }
示例#6
0
 //Just added.
 protected void ChangeStackOfCurrentHotbarItem(int stackToChangeBy)
 {
     CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Hotbar").GetComponent <HotbarManager> ().ModifyStackOfSelectedItem(1);
 }