Beispiel #1
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 #2
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);
        }