void Awake() { this.BallState = BallState.WaitingOnPaddle; velocity = 0f; direction = Vector3.down; originalWidth = transform.localScale.x; }
protected virtual void HandleStructureARGameEvent(object sender, GameEventArgs args) { this.isTracking = args.isTracking; switch(args.gameState) { case SensorState.Playing: if(args.isTracking) { this.ballstate = BallState.starting; this.GetComponent<Renderer>().enabled = true; } else { this.GetComponent<Renderer>().enabled = false; } break; case SensorState.DeviceNotReady: case SensorState.CameraAccessRequired: case SensorState.DeviceNeedsCharging: case SensorState.DeviceReady: case SensorState.Scanning: this.GetComponent<Renderer>().enabled = false; this.ballstate = BallState.ending; break; default: break; } }
public void GetMoving() { this.AddToAutoDrawSet(); this.ShouldTravel = true; this.state = BallState.Moving; this.ticks_to_die = lifetime; }
protected int ticks_to_die; //Ticks that remain until Money "dies" #endregion Fields #region Constructors public Money(Vector2 center, float radius = 1f, float weight = 1f) : base(center, radius) { this.mass = weight; this.state = BallState.Rest; this.Texture = "silvercoin"; }
void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); transf = GetComponent <Transform>(); currentBallState = BallState.Inactive; changingPath = false; nextTarget = false; detectingDoor = false; }
public void ResetBall() { if (BallState.lost == state) { gameObject.SetActive(true); } transform.position = paddle.transform.position + new Vector3(0, offsetFromPaddle, 0); state = BallState.idle; }
public float currentTime;// = Time.time; // Enable this player's turn public void StartTurn() { isTurn = true; ballState = BallState.WAITTOSTART; // Init state machine controller.TryReset(); // Reset the controller (replace the ball) cameraman.gameObject.SetActive(true); // Enable this player's camera }
void OnCollisionEnter2D(Collision2D target) { if (target.gameObject.tag == "Ground") { myBody.velocity = Vector2.zero; currentBallState = BallState.aim; GameManager.instance.CheckAllBallsGrounded(); } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player") { Debug.Log("Doing dolor"); transform.position = spawnPoint; state = BallState.calculatingTarget; } }
void OnMouseOver() { if (state == BallState.AtRest) { //Debug.Log(string.Format("mouse click at {0} ", Camera.main.ScreenToWorldPoint(Input.mousePosition))); AudioManager.Instance.OnSlingStretch(); state = BallState.Streching; } }
void EnterState(BallState NewState) { if (NewState != null) { CurrentState.Exit(); NewState.Enter(this); CurrentState = NewState; } }
void GetVelocity() { if ((rb.velocity.x < 0.3f && rb.velocity.x > -0.3f) || (rb.velocity.y < 0.3f && rb.velocity.y > -0.3f)) { rb.velocity = new Vector2(0.0f, 0.0f); B_state = BallState.Wait; Debug.Log("GetVelocity() 실행"); } }
private void UpdateBallThrow() { // check for push if (jointIndex >= 0 && manager.IsJointTracked(userId, jointIndex) && GetJointPositionInv(userId, jointIndex).y >= lowestPos.y) { handPos2 = GetJointPositionInv(userId, jointIndex); handTime2 = Time.realtimeSinceStartup; ballObject.position = handPos2; Vector3 throwDir = handPos2 - handPos1; float throwDist = throwDir.magnitude; float throwTime = handTime2 - handTime1; if ((throwTime <= timeThrowLimit) && (throwDist >= minThrowDistance) && (handPos2.z > handPos1.z)) { // test succeeded - ball was thrown float velocity = throwDist / throwTime; Debug.Log(string.Format("Dist: {0:F3}; Time: {1:F3}; Velocity: {2:F3}", throwDist, throwTime, velocity)); // if (ballP1) // ballP1.position = handPos1; // if (ballP2) // { // ballP2.position = handPos2; // ballP2.forward = throwDir.normalized; // } if (ballObject) { ballObject.forward = throwDir.normalized; Rigidbody rb = ballObject.GetComponent <Rigidbody>(); if (rb) { rb.velocity = throwDir * velocity * velocityScale; rb.isKinematic = false; } currentState = BallState.BallWait; StartCoroutine(WaitForBall()); } } else if ((handTime2 - handTime1) > timeThrowLimit) { // too slow, start new test handPos1 = handPos2; handTime1 = handTime2; } } else { // throw was cancelled currentState = BallState.Hidden; } }
/// <summary> /// Initialize a ball and set reference to class variable. /// </summary> public void InitBall() { // If there is a ball on variable, kill it. if (Ball) { KillBall(); } Ball = Instantiate(BallPrefab, transform); BallState = BallState.Ready; }
public override BallController CheckTransitions(BallState state, Rigidbody2D rb2d) { if (CheckImpactTransition(state)) { return(new ImpactController()); } // if (CheckAirjumpTransition(state)) // return new AirjumpController(); return(null); }
public void Power(BallHolder ballHolder) { if (m_state == BallState.Held) { m_holder = ballHolder; m_state = BallState.InUse; gameObject.transform.SetParent(m_holder.transform); Audio.AUDIO.PlayClip(Audio.AUDIO.m_equip); } }
public void OnDoubleClick() { if (_state != BallState.Start) { _state = BallState.Start; transform.position = _positions[0]; _trace.positionCount = 0; StopAllCoroutines(); } }
public void Shoot(hand hand) { this.currentHand = hand; if (status == BallState.inHand) { status = BallState.shooted; rb.useGravity = true; rb.AddForce(new Vector3(1 * force, 0, 0)); } }
public IEnumerator GetHitCoroutine(float hitPause) { ballState = BallState.HITSTUN; yield return(new WaitForSeconds(hitPause)); Camera.main.GetComponent <LethalCamera>().Shake(); ballState = BallState.NORMAL; }
public void RestingOnSolid(RectangleWithPhysics block) { if (!this.HasNonZeroVelocity() && (this.CenterY > block.MaxBound.Y) && (this.CenterX > block.MinBound.X) && (this.CenterX < block.MaxBound.X)) { this.state = BallState.Rest; } }
void OnTriggerEnter(Collider col) { //Enter OutOfBounds Directly OutOfBounds oob = col.gameObject.GetComponent <OutOfBounds>(); if (oob) { ballState = BallState.OutOfBounds; } }
// Start is called before the first frame update void Start() { current = BallState.Wooden; SpriteRenderer spr = gameObject.GetComponent <SpriteRenderer>(); Texture2D Tex = Resources.Load("ball2") as Texture2D; Sprite sprite = Sprite.Create(Tex, new Rect(0, 0, 32, 32), new Vector2(0.5f, 0.5f), 23); spr.sprite = sprite; gameObject.tag = "wood_ball"; }
void Start() { State = BallState.Reset; initialPos = transform.position; rigidBody = GetComponent <Rigidbody2D>(); Trail = GetComponent <BallTrail>(); }
public void ResetGame() { gameObject.transform.position = initialPos; rigidBody.velocity = new Vector2(0, 0); State = BallState.Reset; Trail.ResetTrail(transform.position); }
public void SetState(BallState ballState) { if (ballState == BallState.Floating) { rigid.bodyType = RigidbodyType2D.Kinematic; rigid.velocity = Vector2.zero; } this.state = ballState; }
void Start() { PathRendr = GetComponent <LineRenderer>(); rb = GetComponent <Rigidbody>(); PathPoints = new List <Vector3>(); angles = new List <float>(); velocities = new List <float>(); ballState = BallState.STOPPED; MinMovingVel = MIN_RESTING_VEL + HYST_VEL; velvec_xz = new Vector2(); }
// Start is called before the first frame update public override void Start() { base.Start(); rigidbody = GetComponent <Rigidbody>(); sphereCollider = GetComponent <SphereCollider>(); state = GameState.BallSpawned(); state.Release += ReleaseFromPaddle; HoldOnPaddle(); }
//GameConsole console; public Ball(Game game) : base(game) { this.State = BallState.OnPaddleStart; //console = (GameConsole)this.Game.Services.GetService(typeof(IGameConsole)); //if (console == null) //ohh no no console //{ // console = new GameConsole(this.Game); // this.Game.Components.Add(console); //add a new game console to Game //} }
void OnTriggerEnter2D(Collider2D col) { if (m_state == BallState.Free) { if (col.gameObject.tag == "Player") { m_player = col.gameObject.GetComponent <Player>(); m_state = BallState.Held; } } }
public void Win() { currentSpeed = 0; state = BallState.Win; if (OnWin != null) { OnWin(); } }
public void SetState(BallState s, bool val) { if (val) { state |= s; } else { state &= ~s; } }
public void Die() { currentSpeed = 0; state = BallState.Dead; if (OnDie != null) { OnDie(); } }
private void Damage(Collider other) { Debug.Log ("Damaging " + other.name); if (other.transform.parent != null) { // Getting parent's HP and decrease them HealthPoint otherHP = other.transform.parent.GetComponent<HealthPoint> (); otherHP.OneDown (); state = BallState.IS_EXPLODING; } }
private void OnCollisionEnter(Collision collision) { BallState newState; switch (collision.gameObject.name) { case "Player Side": newState = BallState.HitPlayerSide; if (state == newState || state == BallState.HitPlayerPaddle) { GameplayController.Singleton.AIScored(); } else { state = newState; } break; case "AI Side": newState = BallState.HitAISide; if (state == newState || state == BallState.HitAIPaddle) { GameplayController.Singleton.PlayerScored(); } else if (state == BallState.PlayerServe) { GameplayController.Singleton.AIScored(); } else { state = newState; } break; case "Wall": if (state == BallState.HitPlayerSide || state == BallState.HitPlayerPaddle || state == BallState.PlayerServe) { GameplayController.Singleton.AIScored(); } else { GameplayController.Singleton.PlayerScored(); } break; default: break; } }
/// <summary> /// Creates a new ball. Ball class must be initialised by calling Ball.Initialise or an exception is thrown. /// </summary> /// <param name="colour">The colour of the ball. Is clamped to a valid colour.</param> /// <param name="position">The position of the ball.</param> public Ball(BallColour colour, Vector2 position) { if (sColours.Count <= 0) throw new Exception("Textures not initialized"); mColour = (BallColour)MathHelper.Clamp((float)colour, 0, sColours.Count - 1); mOrigin = sSize * 0.5f; mState = BallState.Still; mDirection = Vector2.Zero; mPosition = position; }
public override void RestoreWith(State state) { BallState ballState = (BallState)state; ballState.RebuildCompoundTypes(); GetComponent <Rigidbody2D>().velocity = ballState.prevVelocity; transform.position = ballState.prevPosition; PlayerHasBall = ballState.playerHasBall; IsPlayerWithinRange = ballState.isPlayerWithinRange; }
public void FlyInDirection(Vector3 directFly) { m_directFly = directFly; m_raycastHit = Physics2D.CircleCast(transform.position, m_radius, m_directFly, 100f, m_layerMaskVaCham); Vector3 destination = m_raycastHit.point + m_raycastHit.normal * m_radius; //điểm cuối cách 1 khoảng bằng radius, để bóng ko đi xuyên qua tường hoặc khối m_tweener = transform.DOMove(destination, m_raycastHit.distance / m_flySpeed); m_tweener.SetEase(Ease.Linear); m_tweener.OnComplete(() => OnDoMoveComplete()); m_ballState = BallState.Flying; }
protected int ticks_to_die; //Ticks that remain until Money "dies" #endregion Fields #region Constructors public Money(Vector2 center, float radius = 5f, float weight = 1f) : base(center, radius) { this.mass = weight; this.state = BallState.Rest; this.RotateAngle = XNACS1Base.RandomFloat(0, 360); // sometimes be a gold coin. if (XNACS1Base.RandomFloat(1, 100) > 95) this.Texture = "goldcoin"; else this.Texture = "silvercoin"; }
protected virtual void Start() { this.ballstate = BallState.ending; this.Restart = false; scanBounds.max = new Vector3(1, 1, 1); scanBounds.min = new Vector3(-1, 0, -1); Manager.StructureARGameEvent += HandleStructureARGameEvent; PinchToScale.TouchEvent += HandleScanVolumeChangeEvent; BallLauncher.DropBallsEvent += HandleDropBallsEvent; this.GetComponent<AudioSource>().priority = 0;//most important this.gameObject.name = "Sphere"; this.GetComponent<Rigidbody>().solverIterationCount = 255;//checking at max this.GetComponent<Rigidbody>().detectCollisions = true; this.gameScale = 1.0f; }
public void SetBallState(BallState newBallState) { ballState = newBallState; switch (ballState) { case BallState.OutOfBounds: StopBall(); timeSinceOutOfBounds = 0f; break; case BallState.Goal: timeSinceGoal = 0f; break; default: timeSinceOutOfBounds = 0f; break; } }
protected int ticks_to_die; //Ticks that remain until Money "dies" #endregion Fields #region Constructors public Money(Vector2 center, float radius = 5f, float weight = 1f) : base(center, radius) { owner = null; this.mass = weight; this.state = BallState.Hidden; this.RotateAngle = XNACS1Base.RandomFloat(0, 360); this.lifetime = XNACS1Base.World.TicksInASecond * 10 + XNACS1Base.RandomInt(0, 200); // sometimes be a gold coin. int randomTexture = XNACS1Base.RandomInt(1, 100); if (randomTexture > 90) this.Texture = "goldcoin"; else if( randomTexture > 35) this.Texture = "silvercoin"; else this.Texture = "coppercoin"; if (FinalGame.kelvinMode) this.Texture = "KelvinHead"; }
/// <summary> /// Sets the current ball state. /// </summary> /// <param name="state">The state of the ball.</param> public void SetState(BallState state) { _state = state; if (_state == BallState.Hidden) { // Hide the ball. _renderer.enabled = false; return; } // Show the ball. _renderer.enabled = true; // Position the ball correctly depending on state. if (_state == BallState.Playing) { transform.position = new Vector3(0f, -3.5f, 0f); transform.localScale = new Vector3(1f, 1f, 1f); } else if (_state == BallState.Left) { transform.position = new Vector3(-4.5f, 3.5f, 0f); transform.localScale = new Vector3(0.38f, 0.38f, 1f); } else if (_state == BallState.Center) { transform.position = new Vector3(0f, 3.5f, 0f); transform.localScale = new Vector3(0.38f, 0.38f, 1f); } else if (_state == BallState.Right) { transform.position = new Vector3(4.5f, 3.5f, 0f); transform.localScale = new Vector3(0.38f, 0.38f, 1f); } }
public void Aim() { state = BallState.IS_AIMING; }
public void SendFlying(Vector2 direction, float Velocity, float verticalF) { if(Possessor!=null) Possessor.HeldBall = null; Possessor = null; verticalForce = verticalF; velocity = Velocity; this.direction = direction; this.direction.Normalize(); State = BallState.Flying; }
protected void UpdateInput() { KeyboardState newState = Keyboard.GetState(); ///user press enter key begin if (newState.IsKeyDown(Keys.Enter)) { if (!oldKeyState.IsKeyDown(Keys.Enter)) { if (gameState == GameState.INITIAL) { gameState = GameState.START; StartNewGame(); } else if (gameState == GameState.START) { gameState = GameState.PAUSE; } else if (gameState == GameState.PAUSE) { gameState = GameState.START; } else if (gameState == GameState.GAME_OVER) { gameState = GameState.INITIAL; } } } else if (oldKeyState.IsKeyDown(Keys.Enter)) { // Key was down last update, but not down now, so // it has just been released. } ///user press space key begin if (newState.IsKeyDown(Keys.Space)) { if (!oldKeyState.IsKeyDown(Keys.Space)) { if (gameState == GameState.START) { if(ballState != BallState.LAUNCH) ballState = BallState.LAUNCH; } } } else if (oldKeyState.IsKeyDown(Keys.Space)) { // Key was down last update, but not down now, so // it has just been released. } ///user press left key begin if (newState.IsKeyDown(Keys.Left)) { if (!oldKeyState.IsKeyDown(Keys.Left)) { if (gameState == GameState.START) { paddleState = PaddleState.MOVE_LEFT; } else { paddleState = PaddleState.STAY; } } } else if (oldKeyState.IsKeyDown(Keys.Tab)) { // Key was down last update, but not down now, so // it has just been released. paddleState = PaddleState.STAY; } ///user press right key begin if (newState.IsKeyDown(Keys.Right)) { if (!oldKeyState.IsKeyDown(Keys.Right)) { if (gameState == GameState.START) { paddleState = PaddleState.MOVE_RIGHT; } else { paddleState = PaddleState.STAY; } } } else if (oldKeyState.IsKeyDown(Keys.Right)) { // Key was down last update, but not down now, so // it has just been released. paddleState = PaddleState.STAY; } oldKeyState = newState; }
protected void UpdateWorld(GameTime gameTime) { //System.Diagnostics.Debug.Write("current millisecond=" + (gameTime.ElapsedGameTime.TotalMilliseconds) + "\n"); //System.Diagnostics.Debug.Write("current speed=" + (float)(speed * gameTime.ElapsedGameTime.TotalMilliseconds) +"\n"); float distance = speed * (float)gameTime.ElapsedGameTime.TotalMilliseconds; float obsolute_direction = rVal * distance; switch (gameState) { case GameState.INITIAL: { break; } case GameState.PAUSE: break; case GameState.START: { if (numOfLives == 0) { gameState = GameState.GAME_OVER; break; } if (paddleState == PaddleState.MOVE_LEFT) { if ((int)paddleRect.X <= 0) { paddleVelocity.X = 0.0f; } else { paddleVelocity.X = -obsolute_direction; } paddleRect.X = paddleRect.X + (int)paddleVelocity.X; } if (paddleState == PaddleState.MOVE_RIGHT) { if (((int)paddleRect.X + paddleRect.Width) >= this.GraphicsDevice.Viewport.Width) { paddleVelocity.X = 0.0f; } else { paddleVelocity.X = obsolute_direction; } paddleRect.X = paddleRect.X + (int)paddleVelocity.X; } if (paddleState == PaddleState.STAY) { paddleVelocity.X = 0.0f; } if (ballState == BallState.INITIAL) { ballRect.X = ballRect.X + (int)paddleVelocity.X; } if (ballState == BallState.LAUNCH) { //int rVal = r.Next(15); if (ballRect.X <= 0.0) { ballVelocity.X = obsolute_direction; } else if (ballRect.X >= this.GraphicsDevice.Viewport.Width - ballRect.Width) { ballVelocity.X = -obsolute_direction; } else if (ballRect.Y <= 0) { ballVelocity.Y = obsolute_direction; } // ball pass the paddle at the bottom of view else if (ballRect.Y >= this.GraphicsDevice.Viewport.Height - ballRect.Height) { ballRect.X = paddleRect.X + (paddleRect.Width / 2); ballRect.Y = paddleRect.Y - ballRect.Height - 15; numOfLives--; ballState = BallState.INITIAL; } //detect collision between ball and paddle if (ballRect.Intersects(paddleRect)) { ballVelocity.X = (ballVelocity.X < 0) ? obsolute_direction : -obsolute_direction; ballVelocity.Y = -obsolute_direction; //scoreText = "Score: " + (score++); } //detect collision between ball and bricks if (bricks.CheckCollision(ballRect)) { ballVelocity.X = (ballVelocity.X < 0) ? obsolute_direction : -obsolute_direction; ballVelocity.Y = (ballVelocity.Y < 0) ? obsolute_direction : -obsolute_direction; scoreText = "Score: " + (score++); } ballRect.X = ballRect.X + (int)ballVelocity.X; ballRect.Y = ballRect.Y + (int)ballVelocity.Y; if (bricks.RemainingBricks() == 0) { //gameState = GameState.GAME_OVER; gameState = GameState.START; StartNewLevel(); } } break; } case GameState.GAME_OVER: { } break; } }
public void ResetBall(float min, float max) { float[] temp = new float[2]; m_hit = Direction.None; m_ball_state = BallState.Active; // Set to initial position m_xpos = m_init_x; m_ypos = m_init_y; // Reset each animation to the current location for (int i = 0; i < m_animList.Count; i++) { m_animList[i].X_Pos = m_xpos; m_animList[i].Y_Pos = m_ypos; } temp = GenerateVelocities(m_vel_mag, min, max); // Set initial velocity of x and y m_xvel = temp[0]; m_yvel = temp[1]; if (m_xvel < 0.0f) { m_dir = Direction.Left; } else { m_dir = Direction.Right; } }
public void Clear() { direction = Vector2.Zero; apexReached = true; height = 3f; if (Possessor != null) Possessor.HeldBall = null; TimeWithBall = 0f; State = BallState.Flying; Possessor = null; Passed = false; Kicked = false; }
protected virtual void Update() { switch(this.ballstate) { case BallState.starting: this.ballstate = BallState.started; break; case BallState.started: this.ballstate = BallState.entering; break; case BallState.entering: this.gameObject.GetComponent<MeshRenderer>().material.color = this.InBoundsBallColor; this.Fade = this.FadeTime; this.GetComponent<Renderer>().material = this.OpaqueMaterial; this.GetComponent<Renderer>().material.color = this.InBoundsBallColor; this.firstBounce = false; this.ballstate = BallState.entered; break; case BallState.entered: if(CheckOutOfBounds(this.scanBounds, this.transform.position)) { if(this.BallExitClip != null && this.isTracking && this.firstBounce) { AudioSource.PlayClipAtPoint(this.BallExitClip, this.transform.position); } this.ballstate = BallState.exiting; } break; case BallState.exiting: this.gameObject.GetComponent<Renderer>().material = this.AlphaMaterial; this.gameObject.GetComponent<Renderer>().material.color = this.OutBoundsBallColor; this.ballstate = BallState.exited; break; case BallState.exited: if(this.CheckOutOfBounds(this.scanBounds, this.transform.position)) { Color color = this.OutBoundsBallColor; float alpha = (this.Fade -= Time.deltaTime) / this.FadeTime; color.a = alpha; this.GetComponent<Renderer>().material.color = color; if(alpha <= 0f) { this.ballstate = BallState.ending; } } else { if(this.BallEnterClip != null && this.isTracking && this.firstBounce) { AudioSource.PlayClipAtPoint(this.BallEnterClip, this.transform.position); } this.ballstate = BallState.entering; } break; case BallState.ending: this.transform.position = Vector3.up * 10; this.GetComponent<Rigidbody>().useGravity = false; this.GetComponent<Rigidbody>().velocity = Vector3.zero; this.ballstate = BallState.ended; break; case BallState.ended: if(this.Restart) { this.ballstate = BallState.starting; this.Restart = false; } break; } }
public virtual void HandleDropBallsEvent() { this.ballstate = BallState.starting; this.firstBounce = false; }
public virtual void Update() { switch( this.state) { case(BallState.Moving): this.ticks_to_die--; /*rotate circle based on movement in X direction*/ float xDisplacement = (this.VelocityX / this.Radius) * 180f / (float)Math.PI; this.RotateAngle -= xDisplacement; this.VelocityY += -1f * WorldPhysics.Gravity; if (this.ticks_to_die <= 0) { this.state = BallState.Dying; this.ticks_to_die = 40; // reset for poof effect to use. this.RemoveFromAutoDrawSet(); // set up poofs this.poofs = new XNACS1Rectangle[9]; float velDir = XNACS1Base.RandomFloat(-45, 0); for (int i = 0; i < poofs.Length - 1; i++) { float newSize = XNACS1Base.RandomFloat(3, 7); poofs[i] = new XNACS1Rectangle(this.Center, newSize, newSize, "poofCloud"); poofs[i].RotateAngle = XNACS1Base.RandomFloat(0,360); velDir += 45; poofs[i].VelocityDirection = new Vector2((float)Math.Cos(velDir), (float)Math.Sin(velDir)); poofs[i].Speed = XNACS1Base.RandomFloat(0.25f, 0.5f); // poofs[i].ShouldTravel = true; } this.poofs[poofs.Length - 1] = new XNACS1Rectangle(this.Center, this.SizeX + 1, this.SizeY + 1, "poof"); } break; case(BallState.Dying): this.ticks_to_die--; // the moving poofs. for (int i = 0; i < poofs.Length - 1; i++) { poofs[i].Center += poofs[i].VelocityDirection * poofs[i].Speed; poofs[i].Height *= 1.005f; poofs[i].Width *= 1.005f; } // and the final stationary poof this.poofs[poofs.Length - 1].Height *= 1.005f; this.poofs[poofs.Length - 1].Width *= 1.005f; if (this.ticks_to_die <= 0) { // all done... this.state = BallState.Hidden; for (int i = 0; i < poofs.Length; i++) { poofs[i].RemoveFromAutoDrawSet(); poofs[i] = null; } // remove the coin from the spawner's list... Spawner.removeMoney = true; } break; } }
public void setNewOwner(MachineComponent newOwner) { this.state = BallState.BeingControlled; this.ShouldTravel = false; this.owner = newOwner; }
public void UnMarshal(BinaryReader reader) { float x, y; State = (BallState) reader.ReadByte(); switch (State) { case BallState.Carried: var id = reader.ReadInt32(); Carrier = simulation.Ships[id]; Fixture.Body.Enabled = false; simulation.Ships[id].Ball = this; break; case BallState.Free: Carrier = null; Fixture.Body.Enabled = true; x = reader.ReadSingle(); y = reader.ReadSingle(); Fixture.Body.Position = new Vector2(x, y); x = reader.ReadSingle(); y = reader.ReadSingle(); Fixture.Body.LinearVelocity = new Vector2(x, y); break; case BallState.Spawning: Carrier = null; Fixture.Body.Enabled = false; Fixture.Body.LinearVelocity = new Vector2(0f, 0f); Fixture.Body.Position = SpawnPos; SpawnClock = reader.ReadSingle(); break; } }
public void Step(float elapsed) { if (State == BallState.Spawning) { SpawnClock -= elapsed; if (SpawnClock < 0f) { State = BallState.Free; Fixture.Body.Enabled = true; } } }
public void Spawn() { Fixture.Body.Enabled = false; Fixture.Body.LinearVelocity = new Vector2(0f, 0f); Fixture.Body.Position = SpawnPos; State = BallState.Spawning; SpawnClock = SpawnTime; }
public void Charge() { state = BallState.IS_CHARGING; }
public void Shoot(Vector3 shootDirection) { direction = shootDirection; state = BallState.IS_SHOOTING; }
public void collected() { this.state = BallState.Hidden; this.RemoveFromAutoDrawSet(); Spawner.num_active--; }
public void updateBottleState() { image.Source = null; state = BallState.NONE; }
public void PutBallInPlay() { velocity = minVelocity; direction = Vector3.up; this.BallState = BallState.InPlay; }