Collider for 2D physics representing an circle.

Inheritance: Collider2D
//	private Animator anim;

	void Awake ()
	{
		circleCollider2D = GetComponent<CircleCollider2D> ();
		circleCollider2D.isTrigger = true;
		circleCollider2D.radius = circleRadius;
//		anim = GetComponent<Animator> ();
	}
	public void DestroyGround( CircleCollider2D cc ){
		
		V2int c = World2Pixel(cc.bounds.center.x, cc.bounds.center.y);
		// c => centro do circulo de destruiƧao em pixels
		int r = Mathf.RoundToInt(cc.bounds.size.x*widthPixel/widthWorld);
		// r => raio do circulo de destruiƧao em 
		
		int x, y, px, nx, py, ny, d;
		
		for (x = 0; x <= r; x++)
		{
			d = (int)Mathf.RoundToInt(Mathf.Sqrt(r * r - x * x));
			
			for (y = 0; y <= d; y++)
			{
				px = c.x + x;
				nx = c.x - x;
				py = c.y + y;
				ny = c.y - y;
				
				sr.sprite.texture.SetPixel(px, py, transparent);
				sr.sprite.texture.SetPixel(nx, py, transparent);
				sr.sprite.texture.SetPixel(px, ny, transparent);
				sr.sprite.texture.SetPixel(nx, ny, transparent);
			}
		}
		sr.sprite.texture.Apply();
		Destroy(GetComponent<PolygonCollider2D>());
		gameObject.AddComponent<PolygonCollider2D>();
	}
Example #3
0
	void Awake (){
		m_IsAlive = true;
		m_HealthSlider.value = m_CurrentHealth = m_BaseHealth;
		m_HealthSlider.maxValue = m_BaseHealth;
		m_Collider = GetComponent<CircleCollider2D> ();
		m_Weapons = GetComponent<PlayerWeapons> ();
	}
	private bool IsOverLappingWithAnother(CircleCollider2D col){
		Collider2D[] colliders = FindObjectsOfType<Collider2D>();

		float checkGap = 0.1f;

		int ySign = 1;
		foreach(Collider2D testCol in colliders){
			if (testCol.gameObject != col.gameObject){
				for (int i = 1; i <= 2; i++){

					for (float x = col.transform.position.x - col.radius; x <= col.transform.position.x + col.radius; x += checkGap){
						Vector2 checkPoint = new Vector2(x, ySign * Mathf.Sqrt(Mathf.Pow(col.radius,2) - Mathf.Pow((x - col.transform.position.x ),2)) + col.transform.position.y);
						Debug.Log("PIE");
						if (testCol.OverlapPoint(checkPoint)){
							return true;
						}
							
					}
					ySign = -1;
				}
			}

		}
		return false;
	}
 private void Awake()
 {
     _shape = GetComponent<Shape>();
     _collider = GetComponent<CircleCollider2D>();
     _offsets = new float[_shape.m_resolution];
     RandomizeTime();
 }
Example #6
0
	void Start ()
	{
		Destroy (gameObject, m_deathTimer);

		collider = GetComponent<CircleCollider2D> ();
		StartCoroutine (EnableColliderAfterTime ());
	}
Example #7
0
    protected override void Awake()
    {
        base.Awake ();

        circleCollider = GetComponent<CircleCollider2D> ();
        originalCenter = circleCollider.offset;
    }
Example #8
0
 void Start()
 {
     circleCollider = GetComponent<CircleCollider2D>();
     rigidbody2D = GetComponent<Rigidbody2D> ();
     anim = GetComponent<Animator> ();
     basePerson = GetComponent<Person> ();
 }
Example #9
0
 // Use this for initialization
 void Start()
 {
     col = GetComponent<CircleCollider2D>();
     men = GameObject.Find("Menu");
     win = new Window(new Vector4((Screen.width - 100)/2,(Screen.height - 100)/2, 100, 100));
     script = men.GetComponent<Menu>();
 }
Example #10
0
        /// <summary>
        /// Read the data into the specified value.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="reader">Reader.</param>
        public override void ReadInto(object value, ISaveGameReader reader)
        {
            UnityEngine.CircleCollider2D circleCollider2D = (UnityEngine.CircleCollider2D)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "radius":
                    circleCollider2D.radius = reader.ReadProperty <System.Single> ();
                    break;

                case "density":
                    circleCollider2D.density = reader.ReadProperty <System.Single> ();
                    break;

                case "isTrigger":
                    circleCollider2D.isTrigger = reader.ReadProperty <System.Boolean> ();
                    break;

                case "usedByEffector":
                    circleCollider2D.usedByEffector = reader.ReadProperty <System.Boolean> ();
                    break;

                case "usedByComposite":
                    circleCollider2D.usedByComposite = reader.ReadProperty <System.Boolean> ();
                    break;

                case "offset":
                    circleCollider2D.offset = reader.ReadProperty <UnityEngine.Vector2> ();
                    break;

                case "sharedMaterial":
                    if (circleCollider2D.sharedMaterial == null)
                    {
                        circleCollider2D.sharedMaterial = reader.ReadProperty <UnityEngine.PhysicsMaterial2D> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.PhysicsMaterial2D> (circleCollider2D.sharedMaterial);
                    }
                    break;

                case "enabled":
                    circleCollider2D.enabled = reader.ReadProperty <System.Boolean> ();
                    break;

                case "tag":
                    circleCollider2D.tag = reader.ReadProperty <System.String> ();
                    break;

                case "name":
                    circleCollider2D.name = reader.ReadProperty <System.String> ();
                    break;

                case "hideFlags":
                    circleCollider2D.hideFlags = reader.ReadProperty <UnityEngine.HideFlags> ();
                    break;
                }
            }
        }
Example #11
0
		// Use this for initialization
		void Start () {
			particles = GetComponent<ParticleSystem>();
			circleColider = GetComponent <CircleCollider2D>();
			animator = GetComponent<Animator>();

			timeToRespawn = timeToRespawn + Random.Range ( timeToRespawn * 0.96f , timeToRespawn * 1.04f);
		}
Example #12
0
 void Start()
 {
     //moveVector = new Vector2(;
     col = GetComponent<CircleCollider2D> ();
     anim = GetComponent<Animator> ();
     //test arguments
 }
Example #13
0
 // Use this for initialization
 void Start()
 {
     currRadius = 0f;
     circleCollider = GetComponent<CircleCollider2D>();
     circleCollider.radius = currRadius;
     Instantiate(shockwaveFXPrefab, transform.position, Quaternion.identity);
 }
Example #14
0
	void Awake()
	{
		rb = GetComponent<Rigidbody2D>();
		trans = GetComponent<Transform>();
		anim = GetComponent<Animator>();
		circleCollider = GetComponent<CircleCollider2D>();
	}
Example #15
0
 public void Start()
 {
     findedEnemys = new List<BaseEnemy>();
     _player = transform.parent.GetComponent<Player>();
     _collider = transform.GetComponent<CircleCollider2D>();
     _baseRadius = _collider.radius;
 }
	// Use this for initialization
	void Start () {
        rbody = GetComponent<Rigidbody2D>();
        collider = GetComponent<CircleCollider2D>();
        selectorRenderer = selector.GetComponent<SpriteRenderer>();
        selectorRenderer.enabled = false;
        charController = GameObject.FindWithTag("Player").GetComponent<CharacterController>();
    }
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        exploded = false;
        explosionRadius = gameObject.GetComponent<CircleCollider2D>();
    }
	public bool checkCollidesPoint(Vector2 point, List<Point> points, CircleCollider2D collider){
		for (int i = 0; i < points.Count; i++) {
			Point p = points [i];
			//double end = p.getRad () * 100;
			
			double p1x = p.getX ();
			double p1y = p.getY ();

			Point p2 = new Point(p.getTheta(), p.getRad () * 100);
			//double p2x = - Math.Cos (p.getTheta ()) * end;
			//double p2y = - Camera.main.orthographicSize + (Math.Sin(p.getTheta()) * end);			

			double p2x = p2.getX ();
			double p2y = p2.getY ();

			double cx = point.x;
			double cy = point.y;
			if (intersects ((float)cx, (float)cy, (float)collider.radius, (float)p1x, (float)p1y, (float)p2x, (float)p2y)) {
				p.setRad (p.getRad () + p.getRad () * 0.1d);
				return true;
			}
			//Instantiate(sun, new Vector3((float)px,(float)p2y, 0), Quaternion.identity );
			//intersection((float)cx,(float) cy, (float)collider.radius,(float) p1x,(float) p1y,(float) p2x,(float) p2y);
		}
		return false;
	}
Example #19
0
 void charge()
 {
     numShots = 0;
     if (chargedShot==null) {
         charge_anim.SetBool("charge", true);
         chargedShot = Instantiate (gun.bullet, gun.firingLocation.position, Quaternion.identity) as Rigidbody2D;
         chargedShot.gameObject.SetActive(true);
         chargedCollider = chargedShot.GetComponent<CircleCollider2D>();
         chargedCollider.enabled = false;// disable the collider first
         script = chargedShot.GetComponent<BulletScript>(); // assign the script
         if (master.shipMode){
             chargedShot.rotation = 90; // 270 degrees means facing north
         }
         else {
             master.setCharge(1f); // set 'charging' layer to activate
         }
         chargedShot.GetComponent<SpriteRenderer>().enabled = false;
     } else { //if (chargeLevel<=totalCharge)
         Vector3 size = chargedShot.transform.localScale;
         chargedShot.transform.localScale = new Vector3(size.x*1.5f, size.y*1.5f, 1f);
         script.damage = script.damage*2;
     }
     // make the charged shot stronger
     chargeLevel++;
 }
Example #20
0
 void Awake()
 {
     transform = GetComponent<Transform>();
     Gravity = GetComponent<CircleCollider2D>();
     _player = GameObject.FindGameObjectWithTag("Player").GetComponent<LookAtMouseMove>();
    
 }
 // Use this for initialization
 protected override void Awake()
 {
     base.Awake();
     vfx = GetComponent<ParticleSystem>();
     coll = GetComponent<CircleCollider2D>();
     effector = GetComponent<PointEffector2D>();
 }
Example #22
0
 void Awake()
 {
     Player = GameObject.FindGameObjectWithTag("Player");
     ColliderRange = gameObject.AddComponent<CircleCollider2D>();
     ColliderRange.radius = Range;
     ColliderRange.isTrigger = true;
 }
Example #23
0
 void Awake()
 {
     spring = GetComponent<SpringJoint2D>();
     rigid2d = GetComponent<Rigidbody2D>();
     collider2d = GetComponent<CircleCollider2D>();
     catapult = spring.connectedBody.transform;
 }
Example #24
0
	// Use this for initialization
	void Start () {
        this.currentState = "Square"; // Game starts with Square
        this.animator = this.GetComponent<Animator>();
        this.currentDirection = 1; // 1 for RIGHT / -1 for LEFT

        this.world = GameObject.Find("World");
        this.isStucked = false;
        this.isControllerLocked = false;

        //Initialize the sounds
        /*this.fitTargetSound = this.audioPrefab.transform.GetChild(0).GetComponent<AudioSource>();
        this.dieSound = this.audioPrefab.transform.GetChild(1).GetComponent<AudioSource>();
        this.landscapeSound = this.audioPrefab.transform.GetChild(2).GetComponent<AudioSource>();
        this.changeSound = this.audioPrefab.transform.GetChild(3).GetComponent<AudioSource>();
        this.bounceSound = this.audioPrefab.transform.GetChild(4).GetComponent<AudioSource>();
        */
        //Grab the colliders
        this.SquareCollider = this.GetComponent<BoxCollider2D>();
        this.CircleCollider = this.GetComponent<CircleCollider2D>();
        this.TriangleCollider = this.GetComponent<PolygonCollider2D>();

        //Grab the Rigidbody
        this.rigidBody = this.GetComponent<Rigidbody2D>();
        this.setRigidbody();
	}
Example #25
0
 // Use this for initialization
 void Start()
 {
     circlecollider = GetComponent<CircleCollider2D>();
     GetComponent<RectTransform>().sizeDelta = new Vector2(Screen.width / 20, Screen.width / 20);
     circlecollider.radius = Screen.width / 40;
     //rigibody = GetComponent<Rigidbody2D>();
 }
    void Awake()
    {
        rigidbody = GetComponent<Rigidbody2D>();
        body = GetComponent<PolygonCollider2D>();
        feet = GetComponent<CircleCollider2D>();
        health = GetComponent<Health>();
        standing = body.points;
        crouched = new Vector2[standing.Length];
        grounded = false;
        onWall = false;
        upSlope = false;
        downSlope = false;

        int min = 0;
        for (int i = 0; i < standing.Length; i++)
        {
            if (standing[i].y < standing[min].y)
                min = i;
        }
        for (int i = 0; i < standing.Length; i++)
        {
            float newY = (standing[i].y - standing[min].y) * 0.5f + standing[min].y;
            crouched[i] = new Vector2(standing[i].x, newY);
        }
    }
 static public int constructor(IntPtr l)
 {
     UnityEngine.CircleCollider2D o;
     o = new UnityEngine.CircleCollider2D();
     pushObject(l, o);
     return(1);
 }
    public void Start()
    {
        // 30 rays at minimum
        var alpha = Mathf.Acos(Resources.MinSizeOfEnemy / 2 * Radius) * Mathf.Rad2Deg;
        _minAngle = 180 - 2 * alpha;
        _minAngle -= SkinRadius;
        _detectedEnemies = new List<BoxCollider2D>();

        _sonarCollider = GetComponent<CircleCollider2D>();
        if (_sonarCollider == null)
            Debug.LogError("Sonar Collider component has not been assigned");
        if (Type == Resources.FriendlyReconType.Sonar)
        {
            _sonarDetection = true;
            _sonarCollider.radius = Radius;
            _sonarCollider.isTrigger = true;
        }

        _circularDetectionAngle = 0f;
        _angleBetweenRays = 360f / NumberOfRays;

        _backgroundManager = GetComponent<FriendlyBackgroundManager>();
        if (_backgroundManager == null)
            Debug.LogError("Background Mananger is null");
    }
 void Awake()
 {
     rb2d = GetComponent<Rigidbody2D>();
     rb2d.gravityScale = 0;
     col = GetComponent<CircleCollider2D>();
     col.isTrigger = true;
 }   
 // Use this for initialization
 protected void Start()
 {
     rb = GetComponent<Rigidbody2D>();
     anim = GetComponent<Animator>();
     circleCollider = GetComponent<CircleCollider2D>();
     spriteRenderer = GetComponent<SpriteRenderer>();
 }
Example #31
0
 // Use this for initialization
 void Start()
 {
     //Get collider
     col = GetComponent<CircleCollider2D> ();
     //Rigidbody of gameobject
     //Rigidbody2D rb = transform.parent.GetComponent<Rigidbody2D> ();
 }
Example #32
0
 public void IgnoreCollisions(CircleCollider2D coll)
 {
     foreach (Transform child in transform)
     {
         Physics2D.IgnoreCollision(child.GetComponent<BoxCollider2D>(), coll);
     }
 }
Example #33
0
 static public int set_center(IntPtr l)
 {
     UnityEngine.CircleCollider2D o = (UnityEngine.CircleCollider2D)checkSelf(l);
     UnityEngine.Vector2          v;
     checkType(l, 2, out v);
     o.center = v;
     return(0);
 }
Example #34
0
    static public int set_radius(IntPtr l)
    {
        UnityEngine.CircleCollider2D o = (UnityEngine.CircleCollider2D)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.radius = v;
        return(0);
    }
 static public int get_radius(IntPtr l)
 {
     try {
         UnityEngine.CircleCollider2D self = (UnityEngine.CircleCollider2D)checkSelf(l);
         pushValue(l, self.radius);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #36
0
 static public int get_center(IntPtr l)
 {
     try {
         UnityEngine.CircleCollider2D self = (UnityEngine.CircleCollider2D)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.center);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.CircleCollider2D o;
         o = new UnityEngine.CircleCollider2D();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_center(IntPtr l)
 {
     try {
         UnityEngine.CircleCollider2D self = (UnityEngine.CircleCollider2D)checkSelf(l);
         pushValue(l, self.center);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.CircleCollider2D o;
         o = new UnityEngine.CircleCollider2D();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #40
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.CircleCollider2D o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.CircleCollider2D();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
 static public int set_radius(IntPtr l)
 {
     try {
         UnityEngine.CircleCollider2D self = (UnityEngine.CircleCollider2D)checkSelf(l);
         float v;
         checkType(l, 2, out v);
         self.radius = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #42
0
 static public int set_center(IntPtr l)
 {
     try {
         UnityEngine.CircleCollider2D self = (UnityEngine.CircleCollider2D)checkSelf(l);
         UnityEngine.Vector2          v;
         checkType(l, 2, out v);
         self.center = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_center(IntPtr l)
 {
     try {
         UnityEngine.CircleCollider2D self = (UnityEngine.CircleCollider2D)checkSelf(l);
         UnityEngine.Vector2          v;
         checkType(l, 2, out v);
         self.center = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #44
0
// fields

// properties
    static void CircleCollider2D_center(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.CircleCollider2D _this = (UnityEngine.CircleCollider2D)vc.csObj;
            var result = _this.center;
            JSApi.setVector2S((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.Vector2          arg0  = (UnityEngine.Vector2)JSApi.getVector2S((int)JSApi.GetType.Arg);
            UnityEngine.CircleCollider2D _this = (UnityEngine.CircleCollider2D)vc.csObj;
            _this.center = arg0;
        }
    }
Example #45
0
 static void CircleCollider2D_radius(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.CircleCollider2D _this = (UnityEngine.CircleCollider2D)vc.csObj;
         var result = _this.radius;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.CircleCollider2D _this = (UnityEngine.CircleCollider2D)vc.csObj;
         _this.radius = arg0;
     }
 }
Example #46
0
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.CircleCollider2D circleCollider2D = (UnityEngine.CircleCollider2D)value;
     writer.WriteProperty("radius", circleCollider2D.radius);
     writer.WriteProperty("density", circleCollider2D.density);
     writer.WriteProperty("isTrigger", circleCollider2D.isTrigger);
     writer.WriteProperty("usedByEffector", circleCollider2D.usedByEffector);
     writer.WriteProperty("usedByComposite", circleCollider2D.usedByComposite);
     writer.WriteProperty("offset", circleCollider2D.offset);
     writer.WriteProperty("sharedMaterial", circleCollider2D.sharedMaterial);
     writer.WriteProperty("enabled", circleCollider2D.enabled);
     writer.WriteProperty("tag", circleCollider2D.tag);
     writer.WriteProperty("name", circleCollider2D.name);
     writer.WriteProperty("hideFlags", circleCollider2D.hideFlags);
 }
Example #47
0
 static public int get_radius(IntPtr l)
 {
     UnityEngine.CircleCollider2D o = (UnityEngine.CircleCollider2D)checkSelf(l);
     pushValue(l, o.radius);
     return(1);
 }
Example #48
0
 public ColliderCircle2D(UnityEngine.CircleCollider2D collider) : base(collider)
 {
     m_Collider = collider;
 }
Example #49
0
 /// <summary>
 /// Read the data using the reader.
 /// </summary>
 /// <param name="reader">Reader.</param>
 public override object Read(ISaveGameReader reader)
 {
     UnityEngine.CircleCollider2D circleCollider2D = SaveGameType.CreateComponent <UnityEngine.CircleCollider2D> ();
     ReadInto(circleCollider2D, reader);
     return(circleCollider2D);
 }