示例#1
0
    public void RetrieveCorePart(CorePart i_corePart)
    {
        i_corePart.Pick(playerController);
        FeedbackManager.SendFeedback("event.PlayerPickingBodyPart", playerController, i_corePart.transform.position, i_corePart.transform.position - transform.position, i_corePart.transform.position - transform.position);
        bool i_partsFound = false;
        List <ReviveInformations> newList = new List <ReviveInformations>();

        foreach (ReviveInformations i_parts in retrievedParts)
        {
            if (i_parts.linkedPlayer == i_corePart.linkedPawn)
            {
                i_partsFound = true;
                i_parts.amount++;
                if (i_parts.amount >= i_parts.maxAmount)
                {
                    AllowPlayerRevive(i_parts);
                }
                else
                {
                    i_parts.linkedPanel.transform.Find("TextHolder").transform.Find("Amount").GetComponent <TextMeshProUGUI>().text = i_parts.amount + "/" + i_parts.maxAmount;
                    i_parts.linkedPanel.GetComponent <Animator>().SetTrigger("showAmount");
                    newList.Add(i_parts);
                }
            }
            else
            {
                newList.Add(i_parts);
            }
        }
        retrievedParts = newList;
        if (!i_partsFound)
        {
            ReviveInformations i_newPart = new ReviveInformations();
            i_newPart.linkedPlayer = (PlayerController)i_corePart.linkedPawn;
            i_newPart.maxAmount    = i_corePart.totalPartCount;
            i_newPart.amount       = 1;
            i_newPart.linkedPanel  = Instantiate(Resources.Load <GameObject>("PlayerResource/CollectedPartsPanel"), GameManager.mainCanvas.transform).GetComponent <AssemblingPartPanel>();
            i_newPart.linkedPanel.revivedPlayer  = i_newPart.linkedPlayer;
            i_newPart.linkedPanel.revivingPlayer = playerController;
            i_newPart.linkedPanel.Init();
            i_newPart.linkedPanel.transform.Find("TextHolder").transform.Find("Amount").GetComponent <TextMeshProUGUI>().text = i_newPart.amount + "/" + i_corePart.totalPartCount;
            retrievedParts.Add(i_newPart);
        }
    }
示例#2
0
 private void OnTriggerStay(Collider other)
 {
     if (other.tag == "CorePart" && playerController)
     {
         CorePart i_corePart = other.GetComponent <CorePart>();
         if (!i_corePart.grounded)
         {
             return;
         }
         if (!i_corePart.CanBePicked())
         {
             return;
         }
         if (i_corePart.linkedPawn != null)
         {
             RetrieveCorePart(i_corePart);
         }
         else
         {
             i_corePart.Pick(playerController);
             playerController.Heal(i_corePart.healthValue);
         }
     }
 }