Пример #1
0
        private void SetRandomPattern()
        {
            IEnumerable <LevelPattern> availablePatterns = _levelPatterns.Where(p => !p.GetType().Equals(_currentPattern.GetType()));

            _currentPattern = availablePatterns.ToArray()[UnityEngine.Random.Range(0, availablePatterns.ToArray().Count())];
            _currentPattern.init();
        }
Пример #2
0
        public void TestCreating()
        {
            var pattern = new LevelPattern();

            Assert.AreNotEqual(null, pattern.MonsterSpawns);
            Assert.AreNotEqual(null, pattern.Walls);
        }
Пример #3
0
    // Start is called before the first frame update
    void Awake()
    {
        simulator      = new BlockMapSimulator(Width, Height, BlockRegistry);
        levelGenerator = new BlockLevelGenerator(BlockRegistry, MaterialRegistry, InstantiateBlock, CanPlace);

        if (!IsEditor)
        {
            if (LevelRegistry)
            {
                LevelPatternSaveAsset = LevelRegistry.Patterns[Random.Range(0, LevelRegistry.Patterns.Length)];
            }
            if (LevelPatternSaveAsset)
            {
                LoadFromLevelPatternAsset();
            }
            if (LevelPatternSaveAsset)
            {
                LoadFromLevelPatternAsset();
            }
            else
            {
                levelGenerator.GenerateLevel();
            }
        }
        else
        {
            if (LevelPatternSaveAsset)
            {
                LoadFromLevelPatternAsset();
            }
            int x = 0;
            int y = 4;
            foreach (var block in BlockRegistry.Blocks)
            {
                x += block.Width + 1;
                if (x > Width)
                {
                    x  = 0;
                    y += 5;
                }
                var kblock = InstantiateBlock(block, BlockOrientation.O0, x, y, MaterialRegistry.Materials[0], false);
                var pos    = kblock.transform.position;
                pos.z = -.5f;
                kblock.transform.position = pos;
                kblock.PushOut(0f);
            }
        }
    }
Пример #4
0
        private void StartFalling()
        {
            bool isLeft = false;

            int numberOfWalls = ((2 * UnityEngine.Random.Range(1, 6)) * UnityEngine.Random.Range(1, 3));

            for (int i = 0; i < numberOfWalls; i++)
            {
                GameObject floor = Instantiate(_floorObject);
                floor.tag = "Wall";
                floor.transform.localScale = new Vector3(CameraScreen.width, 0.1f);

                Vector3 newPos = _floors.OrderByDescending(f => f.transform.position.x).First().transform.position;

                if (isLeft)
                {
                    newPos.x += (CameraScreen.width / 2);
                    newPos.y  = _currentYFloor - floor.GetComponent <SpriteRenderer>().bounds.extents.x;

                    if (i == 1)
                    {
                        GameObject gate = Instantiate(_gate);
                        gate.GetComponent <PatternGateScript>().pattern = new FallingGatePattern();
                        gate.transform.position = new Vector2(newPos.x, newPos.y + floor.GetComponent <SpriteRenderer>().bounds.extents.x);
                    }
                }
                else
                {
                    newPos.x += CameraScreen.width;
                    newPos.y  = _currentYFloor;
                }

                floor.transform.position = newPos;

                floor.transform.Rotate(0, 0, 90);

                SetFallingObstacle(floor, isLeft, i);

                _currentYFloor = floor.transform.position.y;

                isLeft = !isLeft;
            }

            _currentYFloor -= (CameraScreen.width / 2);
            fallingPattern  = null;
        }
Пример #5
0
        private void SetRequiredPattern()
        {
            PatternToAdd p = _difficultyManager.GetPatternToAdd();

            _currentPattern = p.Pattern;
            p.Added         = true;

            if (p.ExtraPatterns.Count != 0)
            {
                AddPatterns(p.ExtraPatterns);
            }

            if (p.Color != null)
            {
                _colorsToAdd.Add(p.Color ?? default(Color));
            }

            if (p.Notification != "")
            {
                FindObjectOfType <NotificationManager>().AddNotification(p.Notification, 2.5f);
            }
        }
Пример #6
0
    /**
     *
     * キャラクターのレベルによるパラメータを取得。(ATK, etc)
     *
     */
    public static int CalcLevelParameter(float min, float max, int level, int maxLevel, LevelPattern pattern = LevelPattern.Normal, bool overEnable = false)
    {
        //上限Lvを無視するパラメータ取得以外(敵は上限Lvを無視して取得する)
        if (!overEnable)
        {
            if (level >= maxLevel)
            {
                return((int)max);
            }
        }

        float x = 0;

        switch (pattern)
        {
        case LevelPattern.Early:
            x = Mathf.Abs(Mathf.Log(level, maxLevel) - Mathf.Log(1, maxLevel));
            break;

        case LevelPattern.Late:
            x = Mathf.Abs(Mathf.Log(maxLevel - level + 1, maxLevel) - Mathf.Log(maxLevel, maxLevel));
            break;

        default:
            if (maxLevel != 1)
            {
                x = ((float)level - 1.0f) / ((float)maxLevel - 1.0f);
            }
            break;
        }
        return((int)(min + (max - min) * x));
    }
Пример #7
0
 void Start()
 {
     _currentPattern  = new StartingPattern();
     _playerInPattern = _currentPattern;
     InitPattern();
 }