コード例 #1
0
    // Use this for initialization
    void Start()
    {
        this.sheepObject = GetComponent <Rigidbody2D>();

        for (int i = 0; i < NUM_OF_WOOLS; i++)
        {
            // Create a diamond
            GameObject woolGO = Instantiate(Resources.Load("Wool")) as GameObject;
            woolGO.transform.SetParent(mWools.transform);

            float xPos = Random.Range(-11f, 11f);
            float yPos = Random.Range(-9f, 8f);

            woolGO.transform.position = new Vector3(xPos, yPos, 0);

            float randAngle = Random.Range(0, 200f);
            woolGO.transform.eulerAngles = new Vector3(0, 0, randAngle);
        }

        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Debug.Log("destroying this: " + this.name);
            Destroy(this);
        }
    }
コード例 #2
0
    public void AddPoint(string name)
    {
        SheepScript sheep = null;

        if (name == "Sheep1")
        {
            sheep = sheep1;
        }
        if (name == "Sheep2")
        {
            sheep = sheep2;
        }

        sheep.AddPoint();

        UpdatePointsText();
    }
コード例 #3
0
 // Start is called before the first frame update
 void Start()
 {
     _sheep      = transform.parent;
     _sheepBehav = _sheep.GetComponent <SheepScript>();
 }