Beispiel #1
0
    private void OnCollisionEnter(Collision other)
    {
        Rigidbody targetRigidbody = other.gameObject.GetComponent <Rigidbody>();

        if (targetRigidbody != null)
        {
            targetRigidbody.AddExplosionForce(m_ExplosionForce, transform.position, m_ExplosionRadius);
            HealthBars targetHealth = targetRigidbody.GetComponent <HealthBars>();

            if (targetHealth != null)
            {
                float damage = CalculateDamage(targetRigidbody.position);

                targetHealth.TakeDamage(damage);

                Destroy(gameObject);
            }
        }
    }
        public cNiv1(IServiceProvider serviceProvider, GraphicsDeviceManager graphics)
            : base(serviceProvider, graphics)
        {
            Player          = new Player(true, true);
            Player.Position = new Vector2(140, 140);


            m_patrolData.m_PatrolAnimation = GameResources.RifleSoldierPatrouilleAnimation;
            m_patrolData.m_PatrolDistance  = 150f;
            m_patrolData.m_PatrolSpeed     = 10f;

            EnnemiePatrol = new EnemyPatrol(GameResources.TestPatrouille, new Vector2(400, 300), m_patrolData);

            BarreVie  = new HealthBars(GameResources.HealtBar, new Vector2(-80, -180));
            Obstacles = new List <ObjCollisionable>();
            Obstacles.Add(new ObjCollisionable(10, 200, GameResources.Test, 132, 132, Color.Blue));
            Obstacles.Add(new ObjCollisionable(600, 400, GameResources.Test, 62, 62, Color.Blue));
            Obstacles.Add(new ObjCollisionable(300, 200, GameResources.Test, 122, 122, Color.Blue));
            Camera = new Camera(graphics.GraphicsDevice.Viewport);
            // Background1 = new cBackground();
            //Background1.Rectangle = new Rectangle(-180, -90, 1000, 1000);
            // Background1.texture = cRessources.BG1;
            BackgroundPosition = new Vector2(0, 0);
        }