public Hero(List <Texture2D> textures, CollisionDetection objects)
        {
            //basic information of entity
            Position           = new Vector2(400, 400);
            VerticalMovement   = new Vector2(0, 0); // X: verticalmovement => 1 = ja          0= nee    Y: current jump speed
            HorizontalMovement = new Vector2(0, 4); // X: richting -1 => links 0=> stil 1=> rechts    Y: Current movespeed
            status             = CharState.idle;
            richting           = LoopRichting.rechts;
            herotexture        = textures;

            //combat
            this.Attackbox = new Rectangle(0, 0, 60, 60);
            Attacklock     = false;
            Health         = 150;
            Damage         = 80;

            //animations
            AnimationCreator creator = new AnimationCreator();

            animations = creator.GetHeroAnimation();

            //movement and input
            this.inputreader   = new KeyboardReader(this);
            this.movecommand   = new MoveCommand(objects);
            CollisionRectangle = new Rectangle((int)Position.X, (int)Position.Y, Hero.Width, Hero.height);
        }
コード例 #2
0
        public GameState(IStateChanger stateChanger, GraphicsDevice graphicsDevice, ContentManager content)
            : base(stateChanger, graphicsDevice, content)
        {
            scale       = 1.6f;
            movement    = new Movement(6, 12, 24);
            aniCreator  = new AnimationCreator();
            levelBinder = new LevelBinder();
            collidy     = new CollisionManager();
            spriteBatch = new SpriteBatch(graphicsDevice);

            Texture2D texture        = content.Load <Texture2D>("LightBandit_Spritesheet");
            Texture2D tileset        = content.Load <Texture2D>("tileset");
            Texture2D LavaTexture    = content.Load <Texture2D>("pngkey.com-lava-png-2333904");
            Texture2D portalTexture  = content.Load <Texture2D>("Green Portal Sprite Sheet");
            Texture2D HeartTexture   = content.Load <Texture2D>("heart-sprite-png-2");
            Texture2D NumbersTexture = content.Load <Texture2D>("aGOgp");

            remote = new KeyBoard();
            ((KeyBoard)remote).downk   = Keys.Down;
            ((KeyBoard)remote).upk     = Keys.Space;
            ((KeyBoard)remote).leftk   = Keys.A;
            ((KeyBoard)remote).rightk  = Keys.D;
            ((KeyBoard)remote).sprintk = Keys.LeftShift;

            gravity      = new Gravity(4, 0.3f, 0.7f);
            player       = new Player(new Vector2(100, 800), 60, 52, scale, texture, remote, movement, aniCreator, gravity);
            lava         = new LavaSheet(LavaTexture, new Vector2(-10, 1100), scale);
            currentLevel = new Level(player, tileset, portalTexture, new Vector2(-10, -40), levelBinder, lava, scale);
            levelcollidy = new LevelCollision(player, currentLevel, collidy);
            gameOver     = new GameOver(player, lava, collidy, currentLevel);
            nextLevel    = new NextLevel(player, currentLevel, collidy, stateChanger, graphicsDevice, content, lava);
            hud          = new HUD(HeartTexture, NumbersTexture, aniCreator, player);

            batchUpdater = new BatchUpdater(gravity, player, levelcollidy, currentLevel, gameOver, nextLevel, hud);
        }
        public Spearman(CollisionDetection objects, AIReader AiInputReader) : base(textures, objects, AiInputReader)
        {
            //animations
            AnimationCreator creator = new AnimationCreator();

            animations         = creator.GetSpearmanAnimation();
            CollisionRectangle = new Rectangle((int)Position.X, (int)Position.Y, Spearman.Width - 20, Spearman.height);//-20 offset door de speer die hij vastheeft
        }
コード例 #4
0
    // Start is called before the first frame update
    void Start()
    {
        p1Rigid = GameObject.Find("/player1").GetComponent <Rigidbody2D>();
        p2Rigid = GameObject.Find("/player2").GetComponent <Rigidbody2D>();
        //p1Rigid.WakeUp(); p2Rigid.WakeUp();
        p1Rigid.gravityScale = 1;
        p2Rigid.gravityScale = 1;
        p1Bc       = GameObject.Find("/player1").GetComponent <BoxCollider2D>(); p1Bc.enabled = true;
        p1Animator = GameObject.Find("/player1").GetComponent <Animator>(); p1Animator.enabled = true;
        p1c        = GameObject.Find("/player1").GetComponent <PlayerControl>(); p1c.enabled = true;
        p1Ac       = GameObject.Find("/player1").GetComponent <AnimationCreator>(); p1Ac.enabled = true;

        p2Bc       = GameObject.Find("/player2").GetComponent <BoxCollider2D>(); p2Bc.enabled = true;
        p2Animator = GameObject.Find("/player2").GetComponent <Animator>(); p2Animator.enabled = true;
        p2c        = GameObject.Find("/player2").GetComponent <Player2Control>(); p2c.enabled = true;
        p2Ac       = GameObject.Find("/player2").GetComponent <AnimationCreator>(); p2Ac.enabled = true;
        GameObject.Find("/Grass").GetComponent <SpriteRenderer>().sortingOrder = 0;

        canvasGroup = GetComponent <CanvasGroup>();
        stopButton  = transform.Find("stopButton").GetComponent <Button>();
        stopButton.onClick.AddListener(OnStopClick);
    }