コード例 #1
0
        public void createCutPrint()
        {
            Cuttable hanzai = createCuttable();

            draw(hanzai);
            cut(hanzai);
            print(hanzai);
        }
コード例 #2
0
 // 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;
     }
 }
コード例 #3
0
 // 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>();
     }
 }
コード例 #4
0
    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);
    }
コード例 #5
0
    // 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>();
        }
    }
コード例 #6
0
 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);
 }
コード例 #7
0
    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();
            }
        }
    }
コード例 #8
0
ファイル: Cuttable.cs プロジェクト: pjanek935/burinkeru
    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);
        }
    }
コード例 #9
0
 protected override void print(Cuttable hanzai)
 {
     Console.WriteLine("インクとして、自分の血を使いプリントする");
 }
コード例 #10
0
 protected override void cut(Cuttable hanzai)
 {
     Console.WriteLine("彫刻刀を利用して器用に彫る");
 }
コード例 #11
0
 protected override void draw(Cuttable hanzai)
 {
     Console.WriteLine("マンガの絵を描く");
 }
コード例 #12
0
 public abstract void print(Cuttable hanzai);
コード例 #13
0
 public abstract void cut(Cuttable hanzai);
コード例 #14
0
 public abstract void draw(Cuttable hanzai);
コード例 #15
0
 public override void cut(Cuttable hanzai)
 {
     Console.WriteLine("彫刻刀を使って細部まで丁寧に hanzai を彫る");
 }
コード例 #16
0
 protected abstract void print(Cuttable hanzai);
コード例 #17
0
 protected abstract void cut(Cuttable hanzai);
コード例 #18
0
 protected abstract void draw(Cuttable hanzai);
コード例 #19
0
 public override void print(Cuttable hanzai)
 {
     Console.WriteLine("版画インクと馬簾を使って豪快にプリントする");
 }
コード例 #20
0
 public override void draw(Cuttable hanzai)
 {
     Console.WriteLine("hanzai にマジックを使って大好きな女の子の絵を描く");
 }