Esempio n. 1
0
    private void AddLineByPrefab(GameLine prefab)
    {
        GameLine line = PoolsContainer.PullObjectByPrefab <GameLine>(prefab.gameObject, Container.transform);

        line.PrefabForPulling = prefab.gameObject;
        line.InitialiLine(GameFieldSettings.FieldSize.x);
        if (_lines.Count > 0)
        {
            _lines[_lines.Count - 1].SetNextLine(line);
        }
        _lines.Add(line);
    }
    public override void GenerateObjects()
    {
        SubjectInstances = new List <VehicleGameSubject>();
        for (int i = 0; i < GameLine.Size; i++)
        {
            VehicleGameSubject prefab = SubjectPrefabs[Random.Range(0, SubjectPrefabs.Length)];
            bool needGenerate         = Random.Range(0, 10) < 1;
            if (needGenerate)
            {
                VehicleGameSubject gameSubject = PoolsContainer.PullObjectByPrefab <VehicleGameSubject>(prefab.gameObject, GameLine.transform);
                gameSubject.PrefabForPulling = prefab.gameObject;

                gameSubject.transform.localPosition = new Vector3(i - GameLine.Size / 2, 0, 0);
                SubjectInstances.Add(gameSubject);

                GameLine.SetCellState(i, gameSubject.Size, GameCell.CellState.Dangerous);
                i += (gameSubject.Size);
            }
        }
    }
    public override void GenerateObjects()
    {
        float gs2 = GameLine.Size / 2;

        SubjectInstances = new List <GameSubject>();
        for (int i = 0; i < GameLine.Size; i++)
        {
            GameSubject prefab = SubjectPrefabs[Random.Range(0, SubjectPrefabs.Length)];

            bool needGenerate = Random.Range(0, gs2 - Mathf.Abs(gs2 - i)) < 1;
            if (needGenerate)
            {
//                GameSubject gameSubject = Instantiate(prefab, GameLine.transform);
                GameSubject gameSubject = PoolsContainer.PullObjectByPrefab <GameSubject>(prefab.gameObject, GameLine.transform);
                gameSubject.PrefabForPulling        = prefab.gameObject;
                gameSubject.transform.localPosition = new Vector3(i - GameLine.Size / 2, 0, 0);
                SubjectInstances.Add(gameSubject);

                GameLine.SetCellState(i, GameCell.CellState.Busy);
            }
        }
    }