Beispiel #1
0
        public CharacterScript(double maxLife, MovementScript movementScript, LookScript lookScript, WeaponScript weaponScript, GameObject weapon, GameObject parent)
        {
            _weapon = weapon;

            parent.AddScript(this);
            _parent.AddScript(movementScript);
            _parent.AddScript(lookScript);
            _weapon.AddScript(weaponScript);

            weapon.AddComponent(weaponScript.GetTextureComponent());

            if (!(weaponScript is Crossbow))
            {
                weapon.AddComponent(new RectangleCollider(new Vector2D(10 * 1.2f, 40 * 1.2f), false, true));
            }

            _MAX_LIFE = maxLife;
            _life     = maxLife;
            MessageBus.RegisterEvent(this);
        }
Beispiel #2
0
        public void CreateEnemy(Texture texture, double maxLife, Vector2D position, double rotation, MovementScript movementScript, LookScript lookScript, WeaponScript weaponScript, AiScript aiScript)
        {
            GameObject enemy = new GameObject(position);

            enemy.ObjectName         = "Enemy";
            enemy.transform.Rotation = rotation;

            /*CircleShape shape = new CircleShape(20);
             * shape.OutlineColor = Color.White;
             * shape.OutlineThickness = 2;
             * shape.FillColor = Color.Black;
             * shape.Origin = new Vector2D(20, 20);*/
            RenderComponent sc = new RenderComponent(texture);

            enemy.AddComponent(sc);
            SphereCollider sphereCollider = new SphereCollider(_HELMET_SIZE, false);

            enemy.AddComponent(sphereCollider);
            enemy.AddScript(aiScript);

            GameObject swordRotationLayer = new GameObject(new Vector2D(0, 0));

            swordRotationLayer.ObjectName = "EnemyRotation";
            enemy.SetChild(swordRotationLayer);


            GameObject weapon = new GameObject(new Vector2D(25, -20));

            weapon.ObjectName = "EnemyWeapon";

            new CharacterScript(maxLife, movementScript, lookScript, weaponScript, weapon, enemy);

            weapon.AddComponent(weaponScript.GetTextureComponent());

            swordRotationLayer.SetChild(weapon);

            enemy.Update(0);

            _dataManager.Enemies.Add(enemy);
            _dataManager.Environment.SetChild(enemy);
            _dataManager.DynamicObjects.Add(enemy);


            HealthBar healthBar = new HealthBar(enemy.transform.Position, new Vector2D(50, 5), _dataManager.Font, maxLife);

            EnemyGui enemyGui = new EnemyGui(healthBar);

            enemy.AddScript(enemyGui);
        }
Beispiel #3
0
        public void CreatePlayer(Texture texture, double maxLife, Vector2D position, MovementScript movementScript, LookScript lookScript, WeaponScript weaponScript, AttackScript attackScript, InteractionScript interactionScript, EstusScript estusScript, ActionScript actionScript, List <GameObject> players, int playerCount)
        {
            GameObject player = new GameObject(position);

            player.ObjectName = "MyPlayer";

            /*CircleShape shape = new CircleShape(20);
             * shape.Origin = new Vector2D(20, 20);
             * shape.FillColor = Color.White;*/
            player.AddComponent(new RenderComponent(texture));
            player.AddComponent(new SphereCollider(_HELMET_SIZE, false));
            player.AddScript(attackScript);
            player.AddScript(interactionScript);
            player.AddScript(new InvincibleScript(playerCount));
            player.AddScript(estusScript);
            player.AddScript(actionScript);


            GameObject swordRotationLayer = new GameObject(new Vector2D(0, 0));

            swordRotationLayer.ObjectName = "RotationLayer";
            player.SetChild(swordRotationLayer);

            GameObject weapon = new GameObject(new Vector2D(25, -20));

            weapon.ObjectName = "Weapon";
            //weapon.AddComponent(weaponScript.GetTextureComponent());

            new CharacterScript(maxLife, movementScript, lookScript, weaponScript, weapon, player);

            swordRotationLayer.SetChild(weapon);

            movementScript.Id = players.Count;

            _dataManager.Players.Add(player);
            _dataManager.Environment.SetChild(player);
            _dataManager.DynamicObjects.Add(player);

            player.Update(0);
        }
Beispiel #4
0
        public GameObject CreateEnemy(Vector2D position, double rotation, MovementScript movementScript, LookScript lookScript, WeaponScript weaponScript, AiScript aiScript)
        {
            GameObject enemy = new GameObject(position);

            enemy.transform.Rotation = rotation;
            CircleShape shape = new CircleShape(20);

            shape.OutlineColor     = Color.White;
            shape.OutlineThickness = 2;
            shape.FillColor        = Color.Black;
            shape.Origin           = new Vector2D(20, 20);
            RenderComponent sc = new RenderComponent(shape);

            enemy.AddComponent(sc);
            SphereCollider sphereCollider = new SphereCollider(shape.Radius, false);

            enemy.AddComponent(sphereCollider);

            GameObject swordRotationLayer = new GameObject(new Vector2D(0, 0));

            enemy.SetChild(swordRotationLayer);

            GameObject weapon = new GameObject(new Vector2D(25, 0));

            new CharacterScript(movementScript, lookScript, weaponScript, aiScript, weapon, null, enemy);

            weapon.AddComponent(weaponScript.GetTextureComponent());

            swordRotationLayer.SetChild(weapon);


            return(enemy);
        }
Beispiel #5
0
        public GameObject CreatePlayer(Vector2D position, MovementScript movementScript, LookScript lookScript, WeaponScript weaponScript, AttackScript attackScript, List <GameObject> players, int playerCount)
        {
            GameObject  player = new GameObject(position);
            CircleShape shape  = new CircleShape(20);

            shape.Origin    = new Vector2D(20, 20);
            shape.FillColor = Color.White;
            player.AddComponent(new RenderComponent(shape));
            player.AddComponent(new SphereCollider(20, false));
            player.AddScript(attackScript);


            GameObject swordRotationLayer = new GameObject(new Vector2D(0, 0));

            player.SetChild(swordRotationLayer);

            GameObject weapon = new GameObject(new Vector2D(25, 0));

            //weapon.AddComponent(weaponScript.GetTextureComponent());
            swordRotationLayer.SetChild(weapon);

            new CharacterScript(movementScript, lookScript, weaponScript, null, weapon, new InvincibleScript(playerCount), player);


            movementScript.Id = players.Count;

            return(player);
        }
Beispiel #6
0
        public override void AddPlayer(Vector2D position, MovementScript movementScript, LookScript lookScript, WeaponScript weaponScript, AttackScript attackScript)
        {
            GameObject player = _factory.CreatePlayer(position, movementScript, lookScript, weaponScript, attackScript, _dataManager.Players, _dataManager.PlayerCount);

            //_dataManager.Environment.AddScript(_factory.CreateEnvironmentMovementScript(movementScript, _dataManager.Players));
            _dataManager.Players.Add(player);
            _dataManager.Environment.SetChild(player);
        }