A bit of help with an 8 way billboard/spritesheet/offset display script C#

I have been wrestling with a script to change this billboard texture display to achieve the “Doom” enemy look by combining a couple methods…

The Mathf.Atan methods described here…

…and the fourth script (3rd c# script down) reference for animating tiled textures described here…

I have a 100 by 1600 pixel sprite sheet (1 100 pixel column, 8 200 pixel rows) to represent some horizontal views.

I’m getting errors on line 7 (type struct system.int32), 17 (Parser Error unexpected symbol ‘(in class, struct or interface member declaration)’) and 22 (Parser Error unexpected symbol’IEnumerator’).

Line 7 genuinely mystifies me (how does declaring an int become a struct?) whereas the other two likely are just context problems and I need to brush up on my c# a bit.

My real concern is that this script is not going to work as expected if at all once I manage to get it compiled, I like how elegantly the “index” number can be worked into the offsets and such but I worry that considering columns in the calculations while I have just one on the spritesheet (for now) will be problematic.

Also this may get more evil to wrestle with when I go 3d and start messing with Vector3s…

Anyways my script for your perusals and thoughts…(not sure if this mssg system is formatting my code into code form, posting anyway /shrug)

Heading

using UnityEngine;
using System.Collections;

public class eightwayoffsetchange : MonoBehaviour {
	
	public int columns = 1
	public int rows = 8
			
	private int frame = 0

	// Use this for initialization
	void Start () 
	{
		StartCoroutine (updateTiling());
			
		Vector2 size = new Vector2(1f / columns,1f / rows);
		renderer.sharedMaterial.SetTextureScale("_MainTex", size);
			
	}
	

	private IEnumerator updateTiling () 
	{
		var dir = player.position - transform.position;
    	var angle = Mathf.Atan2(dir.z, dir.x);
    	if (angle < 0.0)
    	angle = angle + 360.0;
    	var index = Mathf.RoundToInt(angle / 45.0); 
		
		if index = 0 {
			
			Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
                                          (index / columns) / (float)rows);          //y index
 
            renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
			
		}
		
		else if index = 1 {
			
			Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
                                          (index / columns) / (float)rows);          //y index
 
            renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
			
		}
		
		else if index = 2 {
			
			Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
                                          (index / columns) / (float)rows);          //y index
 
            renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
			
		}
		
		else if index = 3 {
			
			Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
                                          (index / columns) / (float)rows);          //y index
 
            renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
			
		}
		
		else if index = 4 {
			
			Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
                                          (index / columns) / (float)rows);          //y index
 
            renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
			
		}
		
		else if index = 5 {
			
			Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
                                          (index / columns) / (float)rows);          //y index
 
            renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
			
		}
		
		else if index = 6 {
			
			Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
                                          (index / columns) / (float)rows);          //y index
 
            renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
			
		}
		
		else if index = 7 {
			
			Vector2 offset = new Vector2((float)index / columns - (index / columns), //x index
                                          (index / columns) / (float)rows);          //y index
 
            renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
			
		}
	
	}
}

These lines should all end with a semicolon “;” :

public int columns = 1
public int rows = 8

private int frame = 0