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; } }
void IBallStates.Init(BallBody self) { _self = self; _speed = self.GetSpeed; _accelerationSpeed = self.GetAccSpeed; _desallerationSpeed = self.GetDesaccSpeed; }
protected virtual void Start() { body = GetComponent <BallBody>(); body.MoveEvent += OnAction; body.EndEvent += OnEnd; action_ready = true; in_action = false; }
private void Move(MovingDiractions Diraction) { if (spentEnergy < Settings.levelEnergy) { BallBody.AddForce(NormalizedForceVectorByDiraction(Diraction)); spentEnergy += NormalizedForceVectorByDiraction(Diraction).magnitude *Settings.energyMultiplyer; Logger.UpdateContent(UILogDataTypes.EnergyAmount, "Energy spent: " + spentEnergy + "/" + Settings.levelEnergy); } else { Defeat(); } }
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; } }
public static Entity New(Scene scene) { var e = scene.createEntity("ball"); e.addComponent(new Sprite(BallTexture(scene))); e.addComponent <CircleCollider>(); BallBody body = new BallBody(scene); body.velocity = new Vector2(0, 0); e.addComponent(body); e.addComponent(new CircularBounds(Vector2.Zero, 300)); return(e); }
private void Awake() { // Set up the reference. body = GetComponent <BallBody>(); // get the transform of the main camera if (Camera.main != null) { cam = Camera.main.transform; } else { Debug.LogWarning( "Warning: no main camera found. Ball needs a Camera tagged \"MainCamera\", for camera-relative controls."); // we use world-relative controls in this case, which may not be what the user wants, but hey, we warned them! } }
public void Init(BallBody self) { _self = self; }
private void Move(Vector2 Diraction) { BallBody.AddForce(ForceVectorByDiraction(Diraction)); //Functions.DrawTemporalLine(transform.position, transform.position + ForceVectorByDiraction(Diraction)); }
private void Move(MovingDiractions Diraction) { BallBody.AddForce(ForceVectorByDiraction(Diraction)); }
void IBallStates.Init(BallBody self) { _self = self; }