public void CloneObject()
    {
        GameObject _temp;

        switch (presentFieldData.Step)
        {
        case 1:
            temp = UnityEngine.Random.Range(0, step1Position.Length);
            Overlap(temp, 1);
            position = stepPosition[temp].transform.position;

            break;

        case 2:
            temp = UnityEngine.Random.Range(0, step1Position.Length + step2Position.Length);
            Overlap(temp, 2);
            position = stepPosition[temp].transform.position;
            break;

        case 3:
            temp = UnityEngine.Random.Range(0, step1Position.Length + step2Position.Length + step3Position.Length);
            Overlap(temp, 3);
            position = stepPosition[temp].transform.position;

            break;

        default:

            break;
        }



        _temp = Instantiate(objects[UnityEngine.Random.Range(0, 4)], position, new Quaternion(0, UnityEngine.Random.Range(-1.0f, 1.0f), 0, 1)) as GameObject;
        ObjectOnField tempObject = _temp.transform.Find("CloudCanvas").GetComponent <ObjectOnField>();

        tempObject.position = temp;

        fieldObjectSet.Add(_temp);

        currentObjectNumber++;
    }
示例#2
0
        static void Main(string[] args)
        {
            var characters = new Character[]
            {
                new Wolf(0, 3),
                new Bear(0, 1),
                new Player(0, 0)
            };

            var objects = new ObjectOnField[]
            {
                characters[0],
                characters[1],
                characters[2],
                new Tree(4, 4),
                new Apple(5, 5),
                new Bear(3, 3)
            };

            foreach (var character in characters)
            {
                character.Move(1, 2);
            }
        }