Why is my variable always true?

This script is a random encounter script I’ve been working on, everything is working as i expected aside from one slight problem. My “InBattle” bool is always true and i can’t understand why. I only have one spot where it is even allowed to return true, but that is after certain numerical conditions are met. Maybe someone on here could shine some light on this irritation. (:

using System.Collections;

public class BattleSystem : MonoBehaviour {
	
public  bool InBattle = false;	
	
private int RandNum;
public int RangeStart = 1;
public int RangeEnd = 4000;
private bool Encounter = false;
public int EncounterRangeStart = 400;	
public int EncounterRangeEnd = 600;	
	
public float SecondsWalking;
public float StartWalking;
	
	//for player location/rotation on load
public string AfterBattleMap; 	
public Vector3 AfterBattleLocation;
public Quaternion AfterBattleRotation;	
 

void Awake () {
		
		  Application.targetFrameRate = 30;
	}	
	
	// Use this for initialization
void Start () {
 
}
 
// Update is called once per frame
	//This is used to initiate the random battles.
void Update () {
 
		//initialize RandNum with a random number 1-1000
    RandNum = Random.Range(RangeStart, RangeEnd);
		
		//keep track of when the player started walking
	if(Input.GetKeyDown(KeyCode.W)||Input.GetKeyDown (KeyCode.S)||Input.GetKeyDown(KeyCode.A)||Input.GetKeyDown (KeyCode.D)){
		
		StartWalking = Time.time;	
			
		}
		//add the difference of when the player started walking and when the player stopped walking
	if(Input.GetKeyUp(KeyCode.W)||Input.GetKeyUp (KeyCode.S)||Input.GetKeyUp(KeyCode.A)||Input.GetKeyUp (KeyCode.D)){
			
		SecondsWalking+=Time.time-StartWalking;	
			
		}
	if(InBattle=false){	
	//get forward and back movement and check for battle conditions, also increment time walkin	
    	if (Input.GetKey(KeyCode.W)||Input.GetKey(KeyCode.S)){
				if(Mathf.Round (Time.time)%10==0){ 
				Encounter = true;
					
			//Random battle conditions, ir Rand is greater than 4 but less than 10 start a battle,
			//and if RandNum is greater than 400 but less than 600 start a battle.
    				if(Encounter){
				//Debug.Log("TimeTrue");
				//reset encounter chance
						Encounter = false;
						if(RandNum > EncounterRangeStart && RandNum < EncounterRangeEnd){  
							InBattle = true;
							StartBattle ();
							
        					
						}
					}	
				}
			}
		}
		
		if(InBattle=true){
			if(Input.GetKeyDown(KeyCode.Q))
			{
				EndBattle();
			}
		}
	}
	
	
	
void StartBattle () {
	if(InBattle){	
		Debug.Log ("StartBattle");
		//caches the map the player was on.
		AfterBattleMap = Application.loadedLevelName;
						
		//caches the Player's location & rotation.
		AfterBattleLocation = GameObject.FindGameObjectWithTag("Player").transform.position;
		AfterBattleRotation = GameObject.FindGameObjectWithTag("Player").transform.rotation;
						
       	
		if(InBattle){
		Application.LoadLevel("000Creation");
		Debug.Log("Battle!");
		}
		}
		
	}
void EndBattle()
	{
		Application.LoadLevel(AfterBattleMap);
		Debug.Log ("EndBattle");
				
				InBattle=false;
				if(GameObject.FindGameObjectWithTag("Player")== null)
				{
				OnLevelWasLoaded();
				}
	}
	
void OnLevelWasLoaded()
	{Debug.Log("OnLevelWasLoaded");
		if(GameObject.FindGameObjectWithTag("Player")!= null)
				{
				GameObject.FindGameObjectWithTag("Player").transform.position = AfterBattleLocation;
				GameObject.FindGameObjectWithTag("Player").transform.rotation = AfterBattleRotation;
				}
	}	
}

if(InBattle=false) needs to be if(InBattle==false) (or, if you prefer, if(!InBattle))

if(InBattle=true) needs to be if(InBattle==true) (or, if you prefer, if(InBattle))