public MonsterMoveController(MonsterPosition monsterPosition, MonsterStats monsterStats)
        {
            MonsterStats    = monsterStats;
            MonsterPosition = monsterPosition;

            _interval = _random.Next(1, 6);
        }
Esempio n. 2
0
        public MonsterMoveController[] CreateMonsters(World world, MapLevelDetails map)
        {
            MonsterPosition monster1      = new MonsterPosition(map, world);
            MonsterStats    statsMonster1 = new MonsterStats("rabbit");

            monster1.MoveTo(151, statsMonster1);
            MonsterPosition monster2      = new MonsterPosition(map, world);
            MonsterStats    statsMonster2 = new MonsterStats("rabbit");

            monster2.MoveTo(152, statsMonster2);
            MonsterPosition monster3      = new MonsterPosition(map, world);
            MonsterStats    statsMonster3 = new MonsterStats("rabbit");

            monster3.MoveTo(177, statsMonster3);
            MonsterPosition monster4      = new MonsterPosition(map, world);
            MonsterStats    statsMonster4 = new MonsterStats("cat");

            monster4.MoveTo(60, statsMonster4);
            MonsterPosition monster5      = new MonsterPosition(map, world);
            MonsterStats    statsMonster5 = new MonsterStats("cat");

            monster5.MoveTo(36, statsMonster5);
            MonsterPosition monster6      = new MonsterPosition(map, world);
            MonsterStats    statsMonster6 = new MonsterStats("cat");

            monster6.MoveTo(37, statsMonster6);
            MonsterMoveController[] monsters = new MonsterMoveController[6];
            monsters[0] = new MonsterMoveController(monster1, statsMonster1);
            monsters[1] = new MonsterMoveController(monster2, statsMonster2);
            monsters[2] = new MonsterMoveController(monster3, statsMonster3);
            monsters[3] = new MonsterMoveController(monster4, statsMonster4);
            monsters[4] = new MonsterMoveController(monster5, statsMonster5);
            monsters[5] = new MonsterMoveController(monster6, statsMonster6);
            return(monsters);
        }
Esempio n. 3
0
 public static MonsterPositions ToPositions(this MonsterPosition position)
 {
     return(position switch
     {
         MonsterPosition.South => MonsterPositions.South,
         MonsterPosition.North => MonsterPositions.North,
         MonsterPosition.West => MonsterPositions.West,
         MonsterPosition.East => MonsterPositions.East,
         MonsterPosition.Center => MonsterPositions.Center,
         _ => throw new ArgumentOutOfRangeException(nameof(position), position, null),
     });
Esempio n. 4
0
        public bool TryGetMonsterSpawnPoint(MonsterPosition position, out Transform spawnPoint)
        {
            foreach (var monsterSpawnPoint in _monsterSpawnPoints)
            {
                if (monsterSpawnPoint.Position != position)
                {
                    continue;
                }
                spawnPoint = monsterSpawnPoint.SpawnPoint;
                return(true);
            }

            spawnPoint = default;
            return(false);
        }
        private void TryAddPosition(LevelTile tile, ref MonsterData data, MonsterPosition position)
        {
            if (!CanGenerateMonster(tile, position))
            {
                return;
            }

            var randomValue = _random.NextDouble();
            var probability = _probabilities.GetProbability(position);

            if (randomValue > probability)
            {
                return;
            }

            data.Add(position);
        }
Esempio n. 6
0
        public void Update(GameTime gameTime)
        {
            MonsterPosition monsterPosition;

            if (_world.Has <MonsterPosition>())
            {
                monsterPosition = _world.Get <MonsterPosition>();
            }
            else
            {
                monsterPosition = new MonsterPosition();
            }

            var elapsedTimeSincePrevious = gameTime.Elapsed.Subtract(_previousRegenUpdateGameTime);

            if (elapsedTimeSincePrevious >= RegenInterval)
            {
                _previousRegenUpdateGameTime = gameTime.Elapsed;
                Random rdm = new Random(Environment.TickCount);
                _timeBeforeNextMove = rdm.Next(2, 9);
                int moveToRandomDirection = rdm.Next(0, 4);
                switch (moveToRandomDirection)
                {
                case 0:
                    monsterPosition.MoveDown();
                    break;

                case 1:
                    monsterPosition.MoveUp();
                    break;

                case 2:
                    monsterPosition.MoveLeft();
                    break;

                case 3:
                    monsterPosition.MoveRight();
                    break;
                }
            }
            else
            {
                monsterPosition.Changed = false;
            }
        }
Esempio n. 7
0
        public MonsterCard()
        {
            // super fields
            name     = "no name";
            cardText = "no text";

            // member fields
            attack            = 0;
            defense           = 0;
            effect            = false;
            canAttack         = true;
            canAttackDirectly = false;
            canChangePosition = false;
            stars             = 0;
            monsterType       = MonsterType.NONE;
            subType           = MonsterSubType.NONE;
            attribute         = MonsterAttribute.NONE;
            mode = MonsterPosition.NONE;
        }
Esempio n. 8
0
        private void DrawMonster(Rect tileRect, MonsterPosition position)
        {
            var monsterHalfSize = _monsterSize * 0.5f;
            var center          = position switch
            {
                MonsterPosition.South => new Vector2(tileRect.center.x, tileRect.max.y - monsterHalfSize),
                MonsterPosition.North => new Vector2(tileRect.center.x, tileRect.min.y + monsterHalfSize),
                MonsterPosition.West => new Vector2(tileRect.min.x + monsterHalfSize, tileRect.center.y),
                MonsterPosition.East => new Vector2(tileRect.max.x - monsterHalfSize, tileRect.center.y),
                MonsterPosition.Center => tileRect.center,
                _ => tileRect.center,
            };
            var size = Vector2.one * _monsterSize;

            var monsterRect = new Rect
            {
                size   = size,
                center = center,
            };

            EditorGUI.DrawRect(monsterRect, _monsterColor);
        }
Esempio n. 9
0
 public void Add(MonsterPosition position)
 {
     Positions |= position.ToPositions();
 }
Esempio n. 10
0
 public float GetProbability(MonsterPosition position) =>
 position switch
 {
Esempio n. 11
0
 public static bool Include(this MonsterPositions positions, MonsterPosition otherPosition) =>
 positions.Include(otherPosition.ToPositions());
 private static bool CanGenerateMonster(LevelTile tile, MonsterPosition position) =>
 position switch
 {
Esempio n. 13
0
        static void Main(string[] args)
        {
            System.Console.OutputEncoding = Encoding.Unicode;

            //System.Console.WriteLine("\u2665");
            //System.Console.WriteLine("\uF496");

            //System.Console.Write('\u003A');
            //System.Console.WriteLine('\u0029');//

            //System.Console.Write('\u263A');
            //System.Console.Write('♥');
            //System.Console.Write('♡');
            //System.Console.WriteLine('\u263B');
            //System.Console.Read();

            Console.SetWindowSize(120, 35);
            Console.CursorVisible = false;
            var world = new World();

            var health = new HealthComponent(world)
            {
                Health = new RegenAttribute
                {
                    Current = 50, Max = 100, Name = "Health", RegenRatePerSecond = 1
                }
            };
            var mana = new ManaComponent(world)
            {
                Mana = new RegenAttribute
                {
                    Current = 30, Max = 60, Name = "Mana", RegenRatePerSecond = 0.2
                }
            };

            var fpsCounter = new FramesPerSecondCounter(world);

            var fpsWriter = new FpsRenderer(world);

            var inputSystem = new ConsoleInputSystem(world);

            var playerRenderSystem  = new PlayerRenderSystem(world);
            var monsterRenderSystem = new MonsterRenderSystem(world);

            var playerMovement  = new PlayerMovementSystem(world);
            var monsterMovement = new MonsterMovementSystem(world);
            //Initialize Player position
            var initialPlayerPosition = new PlayerPosition();

            initialPlayerPosition.MoveTo(10, 10);
            world.Set(initialPlayerPosition);
            //initializ monster/s
            var initialMonsterPosition = new MonsterPosition();

            initialMonsterPosition.MoveTo(12, 12);
            world.Set(initialMonsterPosition);

            var updateSystems = new IUpdate[] { inputSystem, fpsCounter, playerMovement, monsterMovement, health, mana }; //Order is important!
            var renderSystems = new IRender[] { playerRenderSystem, monsterRenderSystem, health, mana, fpsWriter, fpsCounter };

            GameEngine gameEngine = new GameEngine(updateSystems, renderSystems);

            gameEngine.Start();
        }