public void SetTile(State state, Motion motion, Vector2 position, Texture2D tileSheet, Rectangle tileArea) { this.state = state; this.motion = motion; this.position = position; increase = true; tileImage = CropImage(tileSheet, tileArea); range = 90; counter = 0; moveSpeed = 80f; animation = new Animation(); animation.LoadContent(ScreenManager.Instance.Content, tileImage, "", position, Color.White); containsEntity = false; velocity = Vector2.Zero; }
public virtual void LoadContent(ContentManager content, List<string> attributes, List<string> contents, InputManager input) { this.content = new ContentManager(content.ServiceProvider, "Content"); moveAnimation = new Animation(); ssAnimation = new SpriteSheetAnimation(); fAnimation = new FadeAnimation(); images = new List<Texture2D>(); healths = new List<int>(); framesList = new List<Vector2>(); moveSpeeds = new List<float>(); for (int i = 0; i < attributes.Count; i++) { switch (attributes[i]) { case "Image": Texture2D tempImage = this.content.Load<Texture2D>(contents[i]); string[] name = contents[i].Split('/'); tempImage.Name = name[name.Count() - 1]; image = tempImage; break; case "Frames": string[] framesTemp = contents[i].Split(','); moveAnimation.Frames = new Vector2(int.Parse(framesTemp[0]), int.Parse(framesTemp[1])); break; case "Position": string[] pos = contents[i].Split(','); position = new Vector2(int.Parse(pos[0]) * Layer.Instance.TileDimensions.X, int.Parse(pos[1]) * Layer.Instance.TileDimensions.Y); break; case "Health": health = int.Parse(contents[i]); break; case "MoveSpeed" : moveSpeed = float.Parse(contents[i]); break; case "Range": range = int.Parse(contents[i]); break; } } gravity = 100f; velocity = Vector2.Zero; syncTilePosition = false; activateGravity = true; moveAnimation.LoadContent(content, image, "", position, Color.White); }