public void FindBodyType(Transform body) { GameLoopManager.Instance.UpdatePlayer -= OnUpdate; if (_humanoid != null) { _humanoid.SetPlayer(null); _humanoid = null; SetCurrentBody = E_Bodies.PLAYER; } else if (_ball != null) { _ball.SetPlayer(null); _ball = null; SetCurrentBody = E_Bodies.PLAYER; } switch (body.gameObject.layer) { case 8: _humanoid = body.GetComponent <HumanoidBody>(); this.transform.position = body.transform.position; this.transform.SetParent(body); _humanoid.SetPlayer(this); SetCurrentBody = E_Bodies.HUMANOID; _body = body; _bodyCol = body.GetComponent <Collider2D>(); GameLoopManager.Instance.UpdatePlayer += OnUpdate; break; case 9: _ball = body.GetComponent <BallBody>(); this.transform.position = body.transform.position; this.transform.SetParent(body); _ball.SetPlayer(this); SetCurrentBody = E_Bodies.BALL; _body = body; _bodyCol = body.GetComponent <Collider2D>(); GameLoopManager.Instance.UpdatePlayer += OnUpdate; break; case 10: break; case 11: break; case 12: break; case 13: break; case 14: break; default: break; } }
public Player(World world, Play play) { _play = play; Body = new HumanoidBody( world: world, dimensions: _sprite.Animation.MaxDimensions.ToMeters() * .9f, userData: this); Body.Torso.OnCollision += OnCollision; Body.Wheel.OnCollision += Wheel_OnCollision; Body.Motor.MotorSpeed = MaxSpeed; //_sprite.Key = AnimationKeys.Walk; }
private void OnTriggerEnter2D(Collider2D collision) { switch (collision.gameObject.layer) { case 8: HumanoidBody body = collision.GetComponent <HumanoidBody>(); if (body.GetStatus == E_BodyStatus.POSSESSED) { _body.bodyType = RigidbodyType2D.Dynamic; gameObject.SetActive(false); } break; case 9: BallBody ball = collision.GetComponent <BallBody>(); if (ball.GetStatus == E_BodyStatus.POSSESSED) { _body.bodyType = RigidbodyType2D.Dynamic; gameObject.SetActive(false); } break; case 10: //set break; case 11: //set break; case 12: //set break; case 13: //set break; case 14: //set break; default: break; } }
private void OnTriggerEnter2D(Collider2D collision) { switch (collision.gameObject.layer) { case 8: HumanoidBody body = collision.GetComponent <HumanoidBody>(); if (body.GetStatus == E_BodyStatus.POSSESSED) { Debug.Log("you win"); GameLoopManager.Instance.SetIsPaused = true; } break; case 9: BallBody ball = collision.GetComponent <BallBody>(); if (ball.GetStatus == E_BodyStatus.POSSESSED) { GameLoopManager.Instance.SetIsPaused = true; Debug.Log("you win"); } break; case 10: //set break; case 11: //set break; case 12: //set break; case 13: //set break; case 14: //set break; default: break; } }
private void OnTriggerEnter2D(Collider2D collision) { switch (collision.gameObject.layer) { case 8: HumanoidBody body = collision.GetComponent <HumanoidBody>(); if (body.GetStatus == E_BodyStatus.POSSESSED) { CPsManager.Instance.SetLastHitCP = this; gameObject.SetActive(false); } break; case 9: BallBody ball = collision.GetComponent <BallBody>(); if (ball.GetStatus == E_BodyStatus.POSSESSED) { CPsManager.Instance.SetLastHitCP = this; gameObject.SetActive(false); } break; case 10: //set break; case 11: //set break; case 12: //set break; case 13: //set break; case 14: //set break; default: break; } }
private void MousePosition(Vector3 pos) { Vector2 raycastPos = pos; RaycastHit2D hit = Physics2D.Raycast(raycastPos, Vector2.zero); if (hit.collider != null) { _newBody = hit.collider.gameObject; switch (_newBody.layer) { case 9: _player.SetPortableObj = _newBody; break; default: break; } } else { if (_player.GetPortableObj != null) { _player.GetPortableObj.transform.SetParent(null); } _player.SetPortableObj = null; _newBody = null; } HumanoidBody body = _player.GetHumanoid; if (body != null && body.IsHolding == true) { if (_player.GetPortableObj != null) { float dist = Vector2.Distance(_player.transform.localPosition, _player.GetPortableObj.transform.localPosition); _player.GetPortableObj.transform.position = (Vector2)pos; } } }
void IHumanoidState.Init(HumanoidBody self) { _self = self; }