예제 #1
0
        public GameObject GetEnemyFootSoldier(int id = -1)
        {
            var enemy = new GameObject();
            enemy.ConstructionStamp = "EnemyFootSoldier";

            enemy.ID = id == -1 ? MechanicSingleton.Instance.GetNextObjectCountValue() : id;

            enemy.SetPhysics(new CollidingPhysics(enemy, gameRef.Level.Bounds));
            enemy.Position = new Vector2(MechanicSingleton.Instance.rand.Next(100, 500));
            //var renderer = new RenderBase(enemy, AssetRepository.Instance.Slime, AssetRepository.Instance.SlimeAnimations);

            enemy.Scale = 2f;
            var renderer = new RenderBase(enemy, AssetRepository.Instance.HeroTexture, AssetRepository.Instance.HeroAnimations(enemy.Scale));
            //var renderer = new RenderBase(enemy, AssetRepository.Instance.Slime, AssetRepository.Instance.SlimeAnimations(enemy.Scale));

            enemy.SetRenderer(renderer);

            var mover = new WalkingMover(enemy);
            mover.SetMovementNoMu(100, 75);
            enemy.SetMover(mover);
            enemy.SetEngine(new WalkerEngine(enemy));

            if (id == -1)
            {
                enemy.SetBrain(new FootSoldierBrain(enemy, gameRef.container.GetObjectById(0)));
            }
            else
            {
                enemy.SetBrain(new NetworkPlayerBrain(enemy));
            }

            enemy.SetCombat(new CombatBase(enemy));
            enemy.SetSkills(new SkillsComponent(enemy));

            // wire up the events between components
            enemy.EquipWeapon(GetSword(enemy));

            gameRef.container.AddObject(enemy);

            if (id == -1)
            {
                NetCommander.CreatedObject(enemy);
            }

            enemy.SpeedAccel = 25f;
            enemy.Team = 1;

            return enemy;
        }
예제 #2
0
        public GameObject GetPlayer(Vector2? position = null)
        {
            var player = new GameObject();
            player.ConstructionStamp = "Player";
            player.Team = 0;

            player.Scale = 2f;

            player.ID = MechanicSingleton.Instance.GetNextObjectCountValue();

            var mover = new WalkingMover(player);
            mover.SetMovementNoF(200, .5f);

            player.SetPhysics(new CollidingPhysics(player, gameRef.Level.Bounds));
            if (position == null)
            {
                position = new Vector2(MechanicSingleton.Instance.rand.Next(1, 100));
            }

            player.Position = position.Value;

            var renderer = new RenderBase(player, AssetRepository.Instance.HeroTexture, AssetRepository.Instance.HeroAnimations(player.Scale));
            player.SetRenderer(renderer);
            player.SetBrain(new PlayerBrain(player, new PlayerControlInput()));
            player.SetMover(mover);
            player.SetEngine(new WalkerEngine(player));
            player.SetCombat(new CombatBase(player));
            player.SetSkills(new SkillsComponent(player));

            player.EquipWeapon(GetSword(player));
            player.EquipRage(GetRage(player));
            player.Skills.SetBoost(new SimpleBoostSkill(player.Skills, player));

            gameRef.container.AddObject(player);

            var parms = new CreateParameters()
            {
                ConstructorId = player.ConstructionStamp,
                ID = player.ID,
                Position = player.Position
            };

            NetCommander.CreatedObject(player);

            gameRef.controlManager.BuildHUDForPlayer(player);

            return player;
        }