Exemple #1
0
        private Ground CreateGround(int p_x, int p_y, bool p_startWithFlood)
        {
            Vector3 __spawnPosition = new Vector3(
                GameSettings.GROUND_SIZE2 + (GameSettings.GROUND_SIZE * p_x) + (GameSettings.WALL_SIZE * p_x),
                0f,
                GameSettings.GROUND_SIZE2 + (GameSettings.GROUND_SIZE * p_y) + (GameSettings.WALL_SIZE * p_y));

            int   __bestIndex  = 0;
            float __bestResult = 0;

            for (int i = 0; i < _listGroundPrefabs.Count; i++)
            {
                float __result = _listGroundPrefabs[i].spawnPercentage * UnityEngine.Random.Range(1f, 10f);

                if (__result > __bestResult)
                {
                    __bestResult = __result;
                    __bestIndex  = i;
                }
            }

            Ground __ground = Instantiate(_listGroundPrefabs[__bestIndex].spawnObject, transform).GetComponent <Ground>();

            ListenGroundEvents(__ground);

            __ground.name = $"Ground [{p_x}][{p_y}]";

            __ground.isFloodSource = p_startWithFlood;

            __ground.Initialize(p_x, p_y);
            __ground.SetFillAmount(0f);
            __ground.SetPosition(__spawnPosition);


            return(__ground);
        }
Exemple #2
0
 private void ListenGroundEvents(Ground p_ground)
 {
     p_ground.onChangeState += Ground_OnChangeState;
     p_ground.onMaxPressure += Ground_OnMaxPressure;
 }