public void AttachPallet(GameObject _Pallet) { Pallet pallet = _Pallet.GetComponent <Pallet>(); if (pallet == null) { return; } if (Contents == null) { return; } PalletContent content = Contents.GetComponentInChildren <PalletContent>(); if (content == null) { return; } if (content.Stackable) { StackedPallet = _Pallet; } }
void OnStartMoveBackward() { if (BottomPallet == null) { return; } if (CurrentLiftLevel == 0) { DetatchPallet(); } else if (CurrentLiftLevel > 0) { Collider[] collisions = Physics.OverlapBox(Lift.transform.position - new Vector3(0.0f, CurrentLiftLevel, 0.0f), new Vector3(0.4f, 0.4f, 0.4f)); foreach (Collider col in collisions) { Pallet p = col.gameObject.GetComponent <Pallet>(); if (p != null) { PalletContent pc = p.Contents.GetComponentInChildren <PalletContent>(); if (pc != null && pc.Stackable) { DetatchPallet(); return; } } } } }
public void OnDetatched() { Collider[] collisions = Physics.OverlapBox(transform.position - new Vector3(0.0f, 1.0f, 0.0f), new Vector3(0.4f, 0.4f, 0.4f)); foreach (Collider col in collisions) { Pallet p = col.gameObject.GetComponent <Pallet>(); if (p != null) { PalletContent pc = p.Contents.GetComponentInChildren <PalletContent>(); if (pc != null && pc.Stackable) { p.AttachPallet(gameObject); return; } } } }
private bool CheckGoods() { Vector3 size = GetComponent <BoxCollider>().size; List <ContentType> remainingTypes = new List <ContentType>(); foreach (ContentType c in RequiredContents) { if (c != ContentType.None) { remainingTypes.Add(c); } } List <GameObject> foundPallets = new List <GameObject>(); Collider[] collisions = Physics.OverlapBox(transform.position, new Vector3(0.4f, 0.8f, 0.4f)); foreach (Collider col in collisions) { Pallet p = col.gameObject.GetComponent <Pallet>(); if (p != null) { PalletContent pc = p.Contents.GetComponentInChildren <PalletContent>(); if (pc != null) { if (remainingTypes.Contains(pc.Type)) { remainingTypes.Remove(pc.Type); foundPallets.Add(p.gameObject); } else { return(false); //WARNING UI HERE } } } } if (remainingTypes.Count == 0) { GameLogic.Instance.AddDeliveryScore(foundPallets.Count); foreach (GameObject go in foundPallets) { Player_Forklift f = go.GetComponent <Pallet>().forklift; if (f != null) { f.DetatchPallet(); } if (go.transform.parent.gameObject) { Destroy(go.transform.parent.gameObject); } else { Destroy(go); } } for (int i = 0; i < 4; ++i) { RequiredContents[i] = ContentType.None; GoodsSlot[i].enabled = false; } return(true); } //ADD SCORE HERE return(false); }