Exemple #1
0
 private void OnTriggerStay(Collider other) //03.07
 {
     if (other.tag == "Gas")                // 독가스에 맞을 시 체력 감소 및 판넬 On
     {
         if (player == Player_number)
         {
             Gas.SetActive(true);
             GasDamDelay += Time.deltaTime;
             if (GasDamDelay > 1)
             {
                 hp         -= GasDam;
                 GasDamDelay = 0;
             }
         }
     }
     if (player == Player_number)
     {
         if (other.tag == "PlayerBox") // 적 플레이어 사망후 남는 시체상자를 채집
         {
             if (Input.GetMouseButtonUp(0) && Mode == 0)
             {
                 Atk = true;
                 transform.GetComponent <AudioSource>().clip = AttackSound;
                 transform.GetComponent <AudioSource>().Play();
                 PlayerBox PB = other.transform.GetComponent <PlayerBox>();
                 if (PB != null)
                 {
                     ParticleSystem PCS = Instantiate(PS.gameObject).GetComponent <ParticleSystem>();
                     PCS.transform.position = new Vector3(other.transform.position.x, transform.position.y + 0.2f, other.transform.position.z);
                     PCS.transform.LookAt(transform);
                     PCS.Play();
                     PB.ondie(Player_number);
                 }
                 CreateDelay = 0;
             }
         }
         if (other.tag == "SupplyBox") // 게임 도중 떨어지는 보급상자를 채집
         {
             if (Input.GetMouseButtonUp(0) && Mode == 0)
             {
                 Atk = true;
                 transform.GetComponent <AudioSource>().clip = AttackSound;
                 transform.GetComponent <AudioSource>().Play();
                 SupplyBox SB = other.GetComponent <SupplyBox>();
                 if (SB != null)
                 {
                     ParticleSystem PCS = Instantiate(PS.gameObject).GetComponent <ParticleSystem>();
                     PCS.transform.position = new Vector3(other.transform.position.x, transform.position.y + 0.2f, other.transform.position.z);
                     PCS.transform.LookAt(transform);
                     PCS.Play();
                     SB.onDemage(Player_number);
                 }
                 CreateDelay = 0;
             }
         }
     }
 }
    private void Drop()
    {
        ACustomItem customItem = GetComponent <ACustomItem>();
        bool        interactResponse;

        if (SupplyBox != null)
        {
            customItem.SetItemSlotManager(SupplyBox._itemSlotManager);
        }
        interactResponse = customItem.InteractOnDrop();

        // Decrements supply box capacity only if the drag was coming from a supply box and if the drop was successfull
        // (It can be unsuccessfull if not enough slot available)
        if (SupplyBox != null && interactResponse)
        {
            SupplyBox.DecrementCurrentCapacity();
            SupplyBox = null;
        }
    }