Calling a method with a value c#

Hey guys What i try to do is to spawn objects according to spawn variable p, however i get those errors, any help would be much appreciated. Here are the codes and error codes right after them :

using UnityEngine;
using System.Collections;

public class PatternCreator : MonoBehaviour {
	
	public Transform prefab;
	public float myTimer = 1.0f;
	
	
	void Start()
	{
		
		
	}
	
	// Update is called once per frame
	void Update ()
	{
		if (myTimer > 0) {
			myTimer -= Time.deltaTime;
		}
		if (myTimer <= 0) {
			Spawn ();
			
			float n = Random.Range (40.0F,50.0F); // bu deger test amaçlı sonra değiştir.
			myTimer = n;
			int p = Random.Range (1,2); // pattern numarası

		}
	}
	
	
	
	void Spawn (int p)
	{
		if (p= 1) {
			float x2 = Random.Range (0.0F, 360.0F);
			float y2 = Random.Range (0.0F, 360.0F);
			float z2 = Random.Range (0.0F, 360.0F); 
			Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
		}  
		if (p= 2) {
			float x2 = Random.Range (0.0F, 360.0F);
			float y2 = Random.Range (0.0F, 360.0F);
			float z2 = Random.Range (0.0F, 360.0F); 
			Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
			Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
			Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
		}  

		
		
	}}

Assets/Scripts/PatternCreator.cs(27,29): warning CS0219: The variable `p' is assigned but its value is never used
    
    Assets/Scripts/PatternCreator.cs(23,25): error CS1501: No overload for method `Spawn' takes `0' arguments
    
    Assets/Scripts/PatternCreator.cs(36,17): error CS0029: Cannot implicitly convert type `int' to `bool'
    
    Assets/Scripts/PatternCreator.cs(42,17): error CS0029: Cannot implicitly convert type `int' to `bool'

In Spawn() u have send values,so it has to be

Spawn(p).

In have rearranged the code and the errors are cleared.

using UnityEngine;
using System.Collections;

public class PatternCreator : MonoBehaviour 
{
	
	public Transform prefab;
	public float myTimer = 1.0f;

	// Update is called once per frame
	void Update ()
	{
		if (myTimer > 0)
		{
			myTimer -= Time.deltaTime;
		}
		if (myTimer <= 0)
		{
			int p = Random.Range (1,2);
			Spawn (p);
			
			float n = Random.Range (40.0F,50.0F); // bu deger test amaçlı sonra değiştir.
			myTimer = n;
		}
	}
	
	
	
	void Spawn (int p)
	{
		if (p== 1) 
		{
			float x2 = Random.Range (0.0F, 360.0F);
			float y2 = Random.Range (0.0F, 360.0F);
			float z2 = Random.Range (0.0F, 360.0F); 
			Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
		}  
		if (p== 2)
		{
			float x2 = Random.Range (0.0F, 360.0F);
			float y2 = Random.Range (0.0F, 360.0F);
			float z2 = Random.Range (0.0F, 360.0F); 
			Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
			Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
			Instantiate( prefab, new Vector3(transform.position.x + 3, transform.position.y + 3, transform.position.z + 3) , Quaternion.Euler (x2, y2, z2)) ;
		}  
	}
}

Bottom up, the error on 42 and 36 is a right of passage error: use two equal signs inside the parens.

23: The Spawn function takes an int argument, but you are calling it without one

Finally the first warning - you’ve setup a variable “p” but aren’t using it anywhere; this is tied to the error on 23, I’m assuming you meant to call Spawn(p) so the call needs to move after the p=Random.range set.

  • int p = Random.Range (1,2); You initialize p but don’t use it (not an error)
  • Spawn (); takes an int as argument
  • if (p= 1) should be comparison: if (p==1)
  • if (p= 2) should be comparison: if (p==2)