Esempio n. 1
0
        public Player(MacGame game)
        {
            playerStates = new Dictionary<string, bool>();
            _sprites = new Dictionary<string, Sprite>();
            _spriteBatch = game.spriteBatch;
            _graphics = game.graphics;
            _camera = game.camera;
            Speed = 10;
            JumpHeight = 14;
            this.AddSprite("right",
                        new Sprite(game.Content,
                        "maker_walk",1,4));
            this.AddSprite("left",
                           new Sprite(game.Content,
                       "maker_walk_left",1,4));

            this.SelectedAction = "right";

            playerStates.Add("UP", false);
            playerStates.Add("DOWN", false);
            playerStates.Add("LEFT", false);
            playerStates.Add("RIGHT", false);
            playerStates.Add("JUMP", false);
            playerStates.Add("RUN", false);
            playerStates.Add("FALL", false);
            playerStates.Add("DEAD", false);
              //this.Position = new Vector2(this.Position.X - Speed, this.Position.Y);
        }
Esempio n. 2
0
 public Tile(MacGame game,
             bool collidable)
 {
     _sprites = new Dictionary<string, Sprite>();
     //this.AddSprite("tile", sprite);
     //this.SelectedAction = "tile";
     //_sprite = sprite;
     _spriteBatch = game.spriteBatch;
     _graphics = game.graphics;
     _camera = game.camera;
     _game = game;
     Collidable = collidable;
 }
Esempio n. 3
0
        public Objekt(MacGame game,
                            bool collidable)
        {
            _top = new Rectangle();
            _bottom = new Rectangle();
            _right = new Rectangle();
            _left = new Rectangle();

            _sprites = new Dictionary<string, Sprite>();
            _spriteBatch = game.spriteBatch;
            _graphics = game.graphics;
            _camera = game.camera;
            Collidable = collidable;
        }
Esempio n. 4
0
        public MousePointer(MacGame game)
        {
            _sprites = new Dictionary<string, Sprite>();
            _spriteBatch = game.spriteBatch;
            _graphics = game.graphics;
            _camera = game.camera;

            this.AddSprite("main",
                           new Sprite(game.Content,
                                "mouse-pointer",
                                true));
            this.AddSprite("erase",
                           new Sprite(game.Content,
                                      "eraser",
                                      true));
            State = MouseState.Point;
        }
Esempio n. 5
0
        public Dictionary<string, Objekt> Load(MacGame game,
                                               ContentManager content)
        {
            Dictionary<string, Objekt> levelObjects =
                new Dictionary<string, Objekt> ();

            Objekt add = null;

            foreach (ObjectInfo o in Objects) {
                switch(o.Type)
                {
                case "maker.Objekt":
                    add = new Objekt(game,o.Obj.Collidable);
                    break;
                case "maker.Tile":
                    Tile tile = (Tile)o.Obj;
                    add = new Tile(game,true);
                    //((Tile)add).SolidBottom = tile.SolidBottom;
                    //((Tile)add).SolidLeft = tile.SolidLeft;
                    //((Tile)add).SolidRight = tile.SolidRight;
                    //((Tile)add).SolidTop = tile.SolidTop;
                    break;
                case "maker.Player":
                    Player player = (Player)o.Obj;
                    add = new Player(game);
                    break;
                }

                add.Position = o.Obj.Position;
                foreach(ObjectInfo.Action a in o.Actions)
                {
                    add.AddSprite(a.Name, new Sprite(content,a.Asset));
                }

                levelObjects.Add(o.Name,add);
            }

            return levelObjects;
        }
Esempio n. 6
0
        private static void LoadActions(Objekt o, JArray actions, MacGame game)
        {
            //JArray actions = (JArray)obj["Actions"];
            string firstAction = (string)actions[0]["Name"];
            int rows = 0;
            int cols = 0;

            for(int i2 = 0; i2 < actions.Count; i2++)
            {
                rows = (int)actions[i2]["Rows"];
                cols = (int)actions[i2]["Columns"];
                //scale = (float)actions[i2]["Scale"];
                if(rows == 0 && cols == 0)
                {
                    o.AddSprite((string)actions[i2]["Name"],
                                  new Sprite(game.Content, (string)actions[i2]["Asset"]));
                }
                else
                {
                    o.AddSprite((string)actions[i2]["Name"],
                                  new Sprite(game.Content, (string)actions[i2]["Asset"],rows,cols));
                }
            }

            o.SelectedAction = firstAction;
        }
Esempio n. 7
0
        public static Dictionary<string, Objekt> Load(string fileName,
                                                       MacGame game,
                                                       ContentManager content)
        {
            Dictionary<string, Objekt> gameObjekts = new Dictionary<string, Objekt>();

            string levelFile = File.ReadAllText (@"/Users/Fritz/Documents/level_Save.json");
            JObject l = JObject.Parse (levelFile);

            Level level = new Level ((string)l ["Name"]);
            JArray objekts = (JArray)l ["Objects"];
            Objekt o = null;
            for (int i = 0; i < objekts.Count; i++) {
                JObject obj = (JObject)objekts[i];
                Objekt add = null;
                JObject gObject = (JObject)obj["Obj"];
                JArray actions = (JArray)obj["Actions"];

                switch((string)obj["Type"])
                {
                    case "maker.Objekt":
                        add = new Objekt(game,false);
                        LoadActions(add, actions, game);
                        break;
                    case "maker.Tile":
                        add = new Tile(game,true);
                        ((Tile)add).SolidBottom = (bool)gObject["SolidBottom"];
                        ((Tile)add).SolidLeft = (bool)gObject["SolidLeft"];
                        ((Tile)add).SolidRight = (bool)gObject["SolidRight"];
                        ((Tile)add).SolidTop = (bool)gObject["SolidTop"];
                        LoadActions(add, actions, game);
                        break;
                    case "maker.Player":
                        add = new Player(game);
                        break;
                    case "maker.MousePointer":
                        add = new MousePointer(game);
                        break;
                }

                //JObject gObject = (JObject)obj["Obj"];
                bool collidable = (bool)gObject["Collidable"];
                JObject position = (JObject)gObject["Position"];
                add.Position = new Vector2((float)position["X"],
                                           (float)position["Y"]);

                string firstAction = (string)actions[0]["Name"];
                float scale = (float)actions[0]["Scale"];

                add.Scale = scale;
                add.Name = (string)obj["Name"];
                gameObjekts.Add((string)obj["Name"], add);
            }

            return gameObjekts;
        }
Esempio n. 8
0
 /// <summary>
 /// Called when Mac app is finished launching.
 /// </summary>
 /// <param name='notification'>
 /// Notification.
 /// </param>
 public override void FinishedLaunching(NSObject notification)
 {
     game = new MacGame();
     game.Run();
 }