public void createCutPrint() { Cuttable hanzai = createCuttable(); draw(hanzai); cut(hanzai); print(hanzai); }
// Case 2: exiting a trigger. Unset it private void OnTriggerExit2D(Collider2D collision) { if (collision.CompareTag("BuildZone")) { bz = null; } if (collision.CompareTag("Cuttable")) { collision.GetComponent <SpriteRenderer>().enabled = false; cu = null; } }
// Case 1: entering a new bz / cuttable's trigger. Replace any old one indiscriminately private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("BuildZone")) { bz = collision.GetComponentInParent <BuildZone>(); } if (collision.CompareTag("Cuttable")) { if (cu) { cu.gameObject.GetComponent <SpriteRenderer>().enabled = false; } collision.GetComponent <SpriteRenderer>().enabled = true; cu = collision.GetComponent <Cuttable>(); } }
public string getDescription() { string txt = ""; GameObject tree = layers[0].getFirstObject(); if (tree != null) { txt += "<b>" + tree.name + "</b>\n"; AssignedPlant ap = tree.GetComponent <AssignedPlant>(); if (ap != null) { txt += "<i>" + ap.get().description + "</i>\n"; } Datable dat = tree.GetComponent <Datable>(); if (dat != null) { txt += "Âge : " + dat.getAge() + " ans\n"; } Cuttable cut = tree.GetComponent <Cuttable>(); if (cut != null) { txt += "Coupe : " + cut.getCutPrice() + "$\n"; } Uprootable up = tree.GetComponent <Uprootable>(); if (up != null) { txt += "Déracinement : " + up.getUprootCost() + "$\n"; } txt += "\n"; } txt += "Humidité : " + getHumidite() + "\n"; txt += "Luminosité : " + getLuminosite() + "\n"; txt += "Fertilité : " + getFertilite() + "\n\n"; txt += "Contient :\n"; for (int i = 1; i < (int)Layers.NbLayers; ++i) { txt += layers[i].getTxt(); } return(txt); }
// Case 3: if a piece happens to be in multiple triggers, then exits one, reset the reference to the other private void OnTriggerStay2D(Collider2D collision) { if (placed) { return; } if (collision.CompareTag("BuildZone")) { bz = collision.GetComponentInParent <BuildZone>(); } if (collision.CompareTag("Cuttable") && !cu) { collision.gameObject.GetComponent <SpriteRenderer>().enabled = true; cu = collision.GetComponent <Cuttable>(); } }
public GameObject cut() { for (int i = 0; i < 4; ++i) { if (objs[i] != null) { Cuttable c = objs[i].GetComponent <Cuttable>(); if (c != null) { GameObject o = c.cut(); GameObject.Destroy(objs[i]); objs[i] = o; return(o); } } } return(null); }
void OnCollisionEnter(Collision collision) { GameObject obj = collision.collider.transform.parent.gameObject; if (obj != null) { if (obj.transform.parent != null) { obj = obj.transform.parent.gameObject; } Cuttable cutObject = obj.GetComponent <Cuttable>(); Debug.Log(collision.collider); if (cutObject != null) { cutObject.OnCut(); } } }
void cut(Transform plane) { if (!canBeCut()) { return; } List <GameObject> newObjectsList = new List <GameObject>(); Renderer renderer = GetComponent <Renderer>(); Material mat = renderer.material; GameObject[] newGameObjects = this.gameObject.SliceInstantiate(plane.position, plane.transform.up, mat); bool wasCut = false; if (newGameObjects != null && newGameObjects.Length > 0) { wasCut = true; for (int i = 0; i < newGameObjects.Length; i++) { newObjectsList.Add(newGameObjects[i]); Rigidbody rb = newGameObjects[i].AddComponent <Rigidbody>(); newGameObjects[i].AddComponent <BoxCollider>(); newGameObjects[i].AddComponent <Hittable>(); Cuttable cuttable = newGameObjects[i].AddComponent <Cuttable>(); cuttable.SetChildIndex(this.childIndex + newGameObjects.Length); rb.isKinematic = TimeManager.Instance.IsSlowMotionOn; cuttable.isFrozen = TimeManager.Instance.IsSlowMotionOn; } } if (wasCut) { Destroy(this.gameObject); } }
protected override void print(Cuttable hanzai) { Console.WriteLine("インクとして、自分の血を使いプリントする"); }
protected override void cut(Cuttable hanzai) { Console.WriteLine("彫刻刀を利用して器用に彫る"); }
protected override void draw(Cuttable hanzai) { Console.WriteLine("マンガの絵を描く"); }
public abstract void print(Cuttable hanzai);
public abstract void cut(Cuttable hanzai);
public abstract void draw(Cuttable hanzai);
public override void cut(Cuttable hanzai) { Console.WriteLine("彫刻刀を使って細部まで丁寧に hanzai を彫る"); }
protected abstract void print(Cuttable hanzai);
protected abstract void cut(Cuttable hanzai);
protected abstract void draw(Cuttable hanzai);
public override void print(Cuttable hanzai) { Console.WriteLine("版画インクと馬簾を使って豪快にプリントする"); }
public override void draw(Cuttable hanzai) { Console.WriteLine("hanzai にマジックを使って大好きな女の子の絵を描く"); }