コード例 #1
0
ファイル: Game1.cs プロジェクト: Tetewet/AlphonseGame
        public void AjoutEnnemi()
        {
            int    r = random.Next(0, spawnable.Count);
            var    ennemiPosition = new Vector2(spawnable[r].Position.X, spawnable[r].Position.Y);
            Ennemi ennemi         = new Ennemi();

            ennemi.Initialize(ennemiTexture, ennemiPosition);
            ennemis.Add(ennemi);
        }
コード例 #2
0
        public void Update(GameTime gameTime, Player pPlayer, Ennemi pEnnemi, Texture2D pTexture2, Texture2D pTexture)
        {
            Vector2.Distance(ref pEnnemi.Position, ref pPlayer.Position, out float distance);

            if (distance < 130f)
            {
                pEnnemi.ennemiTexture = pTexture2;
                Vector2 direction = pPlayer.Position - Position;
                direction.Normalize();
                Position += direction * ennemiVitesse;
            }
            else
            {
                pEnnemi.ennemiTexture = pTexture;
            }

            if (Health <= 0)
            {
                Active = false;
            }
        }