Example #1
0
        public override string GenerateCode()
        {
            var code = string.Format(
                @"
			var unit = createUnit({0}, {1}, '{2}', '{3}', {4}, {5}, {6}, {7}, {8});
			"            , "RectangleUnit", IsPrototype.ToString().ToLowerInvariant(), Id, Color, Position.X, Position.Y, Size.Width, Size.Height, HealthPoints);

            return(code + base.GenerateCode());
        }
        //REVIEW: Definitely should have an interface for this.
        public override string GenerateCode()
        {
            //REVIEW: also, 1,3,4,5,6,7,8,
            var code = string.Format(
                @"
			var unit = createUnit({0}, {1}, '{2}', '{3}', {4}, {5}, {6}, {7}, {8});
			"            , "InanimatedSpriteUnit", IsPrototype.ToString().ToLowerInvariant(), Id, Texture, Position.X, Position.Y, Size.Width, Size.Height, HealthPoints);

            return(code + base.GenerateCode());
        }
        /// <summary>
        /// Generates the code that creates the new unit.
        /// </summary>
        /// <returns></returns>
        public override string GenerateCode()
        {
            // REVIEW: Put all this in a file, also 1,2,3,4,5,6,7,8,9,10,11.
            var code = string.Format(
                @"
			var unit = createUnit({0}, {1}, '{2}', '{3}', {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13});
			"            , "AnimatedSpriteUnit", IsPrototype.ToString().ToLowerInvariant(), Id, Texture, Animations.GenerateCode(this.Id, FramesPerRow),
                FramesPerRow, FramesPerColumn,
                Position.X, Position.Y, Size.Width, Size.Height, HealthPoints, Rotation.X, Rotation.Y);

            code += base.GenerateCode();

            return(code);
        }