Esempio n. 1
0
    // Start is called before the first frame update
    void Awake()
    {
        controller2D    = GetComponent <LagueController2D>();
        onHitObject     = GetComponent <SpawnOnHit>();
        animator        = GetComponent <Animator>();
        spriteRenderer  = GetComponent <SpriteRenderer>();
        health          = GetComponent <Health>();
        hitbox          = GetComponent <RectHitbox>();
        defaultMaterial = spriteRenderer.material;

        health.OnDiedEvent += this.OnDied;
    }
Esempio n. 2
0
    public void OnHurt(RectHitbox hitbox)
    {
        this.state    = State.KNOCKBACK;
        this.velocity = knockbackVelocity;

        Hitstop();
        StopAllCoroutines();
        StartCoroutine(HitFlash());

        if (onHitObject != null)
        {
            onHitObject.Spawn();
        }

        health.subtract(1);
    }
Esempio n. 3
0
 internal Player(IHitbox area, Texture2D texture, Texture2D armoredTexture, Texture2D shieldedTexture)
     : base(area, texture, armoredTexture, shieldedTexture, 100, 100, 100, 3)
 {
     rectArea = (RectHitbox)area;
 }
Esempio n. 4
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            backgrounds[0] = new ParallaxingBG(
                Content.Load <Texture2D>("Background/Farthest"),
                graphics.PreferredBackBufferHeight,
                30);
            backgrounds[1] = new ParallaxingBG(
                Content.Load <Texture2D>("Background/Middle"),
                graphics.PreferredBackBufferHeight,
                7);
            backgrounds[2] = new ParallaxingBG(
                Content.Load <Texture2D>("Background/Closest"),
                graphics.PreferredBackBufferHeight,
                1);

            Texture2D playerShip = Content.Load <Texture2D>("Ships/Player");

            playerStartPos = new Point(
                graphics.PreferredBackBufferWidth / 2 - playerShip.Width / 2,
                graphics.PreferredBackBufferHeight - playerShip.Height - 15);
            IHitbox playerHB = new RectHitbox(
                playerStartPos.X, playerStartPos.Y,
                playerShip.Width,
                playerShip.Height);

            player = new Player(playerHB, playerShip, playerShip, playerShip);

            Gunfire.Texture       = Content.Load <Texture2D>("Attacks/Bullet");
            PhotonTorpedo.Texture = Content.Load <Texture2D>("Attacks/Torpedo");
            //Missile.Texture = Content.Load<Texture2D>("Attacks/Missile");

            Texture2D bft = Content.Load <Texture2D>("Ships/BasicFighter");

            BasicFighter.SetTextures(bft, bft, bft);

            logo = Content.Load <Texture2D>("Art/Logo");
            font = Content.Load <SpriteFont>("Fonts/Consolas");

            var mainMenuActions = new Dictionary <String, Menu.MenuAction>
            {
                {
                    "Start", () =>
                    {
                        state = GameState.InGame;
                        return(true);
                    }
                },
                {
                    "Instructions", () =>
                    {
                        state = GameState.Instructions;
                        return(true);
                    }
                },
                {
                    "Exit", () =>
                    {
                        Exit();
                        return(false);
                    }
                }
            };

            mainMenu = new Menu(200, graphics.PreferredBackBufferWidth, font, mainMenuActions);

            var pauseMenuActions = new Dictionary <String, Menu.MenuAction>
            {
                {
                    "Resume", () =>
                    {
                        state = GameState.InGame;
                        return(true);
                    }
                },
                {
                    "Main Menu", () =>
                    {
                        state = GameState.MainMenu;
                        return(true);
                    }
                }
            };

            pauseMenu = new Menu(400, graphics.PreferredBackBufferWidth, font, pauseMenuActions);
        }
Esempio n. 5
0
 public void OnHurt(RectHitbox hitbox)
 {
     Debug.Log("Hurt");
 }