Ejemplo n.º 1
0
        public static void CreatedObject(GameObject player)
        {
            var parms = new CreateParameters()
            {
                ConstructorId = player.ConstructionStamp,
                ID = player.ID,
                Position = player.Position
            };

            SendCommand(new GameObjectCommand()
            {
                CommandType = GameObjectCommandType.Create,
                Parameters = parms,
            });
        }
Ejemplo n.º 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;
        }