private void Movie() { Collider2D[] coliders = Physics2D.OverlapAreaAll(head[4].position, head[5].position); // точки касания для разворота if (coliders.Length > 0 && coliders.All(x => x.GetComponentInParent <BulletDestroy>() || x.GetComponentInParent <timeToGOBACK>() || x.GetComponentInParent <Monster>())) { direction *= -1.0F; transform.localScale = Vector3.Scale(transform.localScale, new Vector3(-1, 1, 1)); } transform.position = Vector3.MoveTowards(transform.position, transform.position + direction, speed * Time.deltaTime); if (jumper) // прыгун { if (coliders.Length > 0 && coliders.All(x => x.GetComponentInParent <BulletDestroy>() || x.GetComponentInParent <timeToGOBACK>() || x.GetComponentInParent <NewHero>())) { rigidbody.AddForce(transform.up * jumpForce, ForceMode2D.Impulse); } } if (earth_touch_jumper) { Collider2D[] coliders_nogi = Physics2D.OverlapAreaAll(head[6].position, head[7].position); // ноги прыжок if ((coliders_nogi.Length > 0 && coliders.All(x => x.GetComponentInParent <BulletDestroy>()))) { rigidbody.AddForce(transform.up * jumpForce, ForceMode2D.Impulse); } } Collider2D[] headColliders = Physics2D.OverlapAreaAll(head[2].position, head[3].position); if (headColliders.Length > 0 && headColliders.All(x => x.GetComponentInParent <NewHero>())) { LazyMan.Jump(15.0F); ReciveDamage(1, true); } }
protected override void Update() { if (!active) { return; } Collider2D[] headColliders = Physics2D.OverlapAreaAll(head[2].position, head[3].position); if (headColliders.Length > 0 && headColliders.All(x => x.GetComponentInParent <NewHero>())) { LazyMan.Jump(15.0F); ReciveDamage(1, true); } povorot = LazyMan.transform.position.x <= head[1].position.x ? -1.0F : 1.0F; // узнаем, левее или правее от стрелюна игрок if (povorot != povorotHistory) { povorotHistory = povorot; transform.localScale = Vector3.Scale(transform.localScale, new Vector3(-1, 1, 1)); } }