public void OnConnectionFailure( NetworkConnectionError _info ) { this.connectingPanelObj.SetActive( false ); this.mainPanelObj.SetActive( true ); this.currentState = STATE.MAIN; }
// 回到主界面 public void ReturnMenu() { state = STATE.Start; uiScript.ShowGameOverPanel(false); uiScript.ShowRankPanel(false); uiScript.ShowStartPanel(true); }
// 游戏开始函数 public void GameStart() { state = STATE.Gaming; uiScript.ShowStartPanel(false); // 重置所有数据 score = 0; snakeNodes.Clear(); for (int i = 0; i < w; ++i) { for (int j = 0; j < h; ++j) { if (grid[i, j] != null) { Destroy(grid[i, j]); } } } direction = -Vector2.right; for (int i = 0; i < initLength; ++i) { EatFood(); } }
// Update is called once per frame void Update() { if (m_State != m_OldState) { m_State = m_OldState; m_EnterPls = true; } else { m_EnterPls = false; } switch (m_State) { case ( STATE.INIT ): break; case (STATE.COUNT_3): break; case (STATE.COUNT_2): break; case (STATE.COUNT_1): break; case (STATE.IN_GAME): break; case (STATE.GAME_ORVER): break; case (STATE.CLEAR): break; } }
public void en_queue(STATE.states state) { lock (mf.states_queue) { mf.states_queue.Enqueue(state); } }
void stWait() { if (true) { m_State = STATE.MAIN; } }
public override void RunAI() { base.RunAI(); // Moving x. if (bestDirection.x > 0) { if (state != STATE.WALKINGLEFT) { transform.Rotate(new Vector3(0, 180, 0)); } state = STATE.WALKINGLEFT; } else { if (state != STATE.WALKINGRIGHT) { transform.Rotate(new Vector3(0, 180, 0)); } state = STATE.WALKINGRIGHT; } Vector3 unnormalizedDirection = bestDirection; bestDirection = Vector3.Normalize(new Vector3(bestDirection.x, bestDirection.y, 0.0f)); RotateArm(); if (unnormalizedDirection.magnitude < shootRange) { Shoot(); } }
// Update is called once per frame void FixedUpdate () { if (Input.GetKey(scanKey)) { currentState = STATE.SCANNING; } }
// Update is called once per frame void Update() { switch (m_State) { case STATE.STATE_IN: { this.transform.Translate(new Vector3(-moveSpeed * Time.deltaTime, 0, 0)); if (this.transform.position.x < m_TargetPos) { m_State = STATE.STATE_ATTACK; } }break; case STATE.STATE_ATTACK:{ attackStateTime -= Time.deltaTime; if (attackStateTime < 0.0f) { m_State = STATE.STATE_LEAVE; } else { m_AttackLeftTime -= Time.deltaTime; if (m_AttackLeftTime < 0.0f) { m_AttackLeftTime = attackDeltaTime; Transform blt = Instantiate(attackBullet) as Transform; if (blt) { blt.position = this.transform.position; } } } }break; case STATE.STATE_LEAVE:{ this.transform.Translate(new Vector3(-moveSpeed * Time.deltaTime, 0, 0)); if (this.transform.position.x < -20.0f) { GameObject.DestroyObject(this.gameObject); } }break; } }
// Update is called once per frame void Update() { if (m_StateOld != m_State) { m_StateOld = m_State; m_EnterPls = true; m_StateTime = 0.0f; } else { m_StateTime += Time.deltaTime; m_EnterPls = false; } switch (m_State) { case (STATE.BLANK): stBlank(); break; case ( STATE.WAIT ): stWait(); break; case (STATE.INTRO): stIntro(); break; case (STATE.MAIN): stMain(); break; } StartFlg = false; }
public MainWindow() { InitializeComponent(); this.DataContext = this; state = STATE.MENU; #region SongFix string b = Resource.get_File_Path("The Walking Dead Original Soundtrack - Theme Song HD.wav"); pathSaveData = System.IO.Path.GetFullPath(Resource.Resource_Path + "..\\" + "Properties.txt"); #endregion #region Windowsize CustomHeight = 350; CustomWidth = 525; #endregion #region Playing_Window_Sound player.URL = Resource.get_File_Path("The Walking Dead Original Soundtrack - Theme Song HD.wav"); player.settings.setMode("loop", true); player.settings.volume = 5; #endregion #region Setting_Background ImageBrush imgBrush = new ImageBrush(); imgBrush.ImageSource = new BitmapImage(new Uri(Resource.get_File_Path("Th353Y7.jpg"), UriKind.Relative)); Grid1.Background = imgBrush; #endregion }
public void toggle() { if(state == STATE.ON) { // toggle to off state = STATE.OFF; background.color = new Color(0.745f, 0.745f, 0.745f, 1.0f); description.text = "OFF"; description.color = Color.black; description.transform.localPosition = new Vector3(description.transform.localPosition.x + textOffset, description.transform.localPosition.y, description.transform.localPosition.z); thumb.transform.localPosition = new Vector3(thumb.transform.localPosition.x - spriteOffset, thumb.transform.localPosition.y, thumb.transform.localPosition.z); } else { // toggle to on state = STATE.ON; background.color = new Color(0.9921f, 0.745f, 0f, 1.0f); description.text = "ON"; description.color = Color.white; description.transform.localPosition = new Vector3(description.transform.localPosition.x - textOffset, description.transform.localPosition.y, description.transform.localPosition.z); thumb.transform.localPosition = new Vector3(thumb.transform.localPosition.x + spriteOffset, thumb.transform.localPosition.y, thumb.transform.localPosition.z); } if (eventReceiver != null && !string.IsNullOrEmpty(functionName)) { eventReceiver.SendMessage(functionName, (state == STATE.ON ? true : false), SendMessageOptions.DontRequireReceiver); } }
public Player(MainGame game, Tile spawnPoint) { //Salvando os tiles ocupados: mCurrentTiles = new List<Tile>(); mCurrentTiles.Add(spawnPoint); //Definindo o estado inicial: mCurrentState = STATE.STANDING; //Inicializando o Sprite: _sprite = new Sprite(game.Content.Load<Texture2D>("Images/Tileset"), mCurrentTiles[0].Sprite.DrawPosition); //Corrigindo o Y: _sprite.DrawPosition_Y -= 128; //Salvando o spriteRect: _sprite.SpriteRect = new Rectangle(0, 64, 128, 192); //Atualizando a origem do sprite (Sempre Centralizada): _sprite.Origin = new Vector2(_sprite.SpriteRect.Width / 2, _sprite.SpriteRect.Height / 2); _sprite.Color = new Color(Color.White, 0.5f); _sprite.Rotation = 0f; //Zerando: _qtdMoves = 0; _playTime = TimeSpan.Zero; }
private void initialize() { business = new BusinessPage(); demographics = new DemographicsPage(); tp = new Windows.TimePicker(); tp.Hide(); business.businessGrid.SelectionChanged += BusinessGrid_SelectionChanged; state = STATE.Error; users = get_users(); cb_User.ItemsSource = users; cb_User.MinimumPopulateDelay = 3; string command = "SELECT DISTINCT state_code FROM censusdata ORDER BY state_code"; using (MySqlConnection db_connection = new MySqlConnection(connectionString)) { db_connection.Open(); using (MySqlCommand c = new MySqlCommand(command, db_connection)) { using (MySqlDataReader r = c.ExecuteReader()) { while (r.Read()) { cb_state.Items.Add(r.GetString("state_code")); } } } } }
public void Initialize(Enemy enemy, Player player, Texture2D barrierTexture, Texture2D collectableTexture, Level level) { this.enemy = enemy; this.player = player; this.barrierTexture = barrierTexture; this.collectableTexture = collectableTexture; this.level = level; enemyChar = 5; playerChar = 5; GameState = STATE.Connecting; connection = new HubConnection("http://localhost:9685"); //connection = new HubConnection("http://2dgameserver.azurewebsites.net/"); proxy = connection.CreateHubProxy("GameHub"); ServicePointManager.DefaultConnectionLimit = 10; //connection.Received += Connection_Received; Action<float, float> EnemyPosReceived = received_enemy_position; proxy.On("sendPosition", EnemyPosReceived); Action EnemyActiveReceived = received_enemy_active; proxy.On("sendActive", EnemyActiveReceived); Action<int> enemyShoot = received_enemy_shoot; proxy.On("sendShoot", enemyShoot); Action<List<Vector2>, List<int>> getCollectables = received_collectables; proxy.On("sendCollectables", getCollectables); Action<List<Vector2>, List<int>> getBarriers = received_barriers; proxy.On("sendBarriers", getBarriers); Action<float, int, int, float, int> enemyVariables = received_enemy_variables; proxy.On("sendVariables", enemyVariables); Action<int> playerConnecteds = conected_players; proxy.On("playerConnecteds", playerConnecteds); Action<int> otherPlayerChar = received_enemy_char; proxy.On("otherPlayerChar", otherPlayerChar); Console.WriteLine("SERVER: Waiting for connection"); try { connection.Start().Wait(); } catch (Exception ex) { Console.WriteLine(ex); } if (connection.State == ConnectionState.Connected) { Console.WriteLine("--SERVER: CONNECTED--"); } }
protected virtual void SwitchState( STATE _state ) { if ( this.currentState != _state ) { this.currentDelta = 0.0f; this.currentState = _state; } }
public void ACTION_EmergencyDisable () { HordeManager.UnUse_Enemy (index); AnimController.Stop (); transform.parent = HordeManager.transform; transform.localPosition = Vector3.zero; currentState = STATE.IDLE; }
public void Enable_AtPosition (Vector3 _newPos) { transform.position = _newPos; transform.LookAt (Vector3.zero, transform.up); AnimController.Play ("intro"); Play_AudioClip (_sfx [3]); currentState = STATE.SPAWNING; }
public void deactivate() { if (mCurrentState == STATE.IDLE) { mIsActive = false; mCurrentState = STATE.FADE; } }
public void activate() { if (mCurrentState == STATE.IDLE) { mIsActive = true; mCurrentState = STATE.APPEAR; } }
IEnumerator Cooldown() { while (true) { yield return new WaitForSeconds(this.cooldown); this.state = STATE.IDLE; } }
public Item() { _life = _maxLife = 20f; state = STATE.ON_GROUND; _owner = null; state = STATE.ON_GROUND; }
// Use this for initialization void Start() { mText = GetComponent<Text> (); state = STATE.START; //StartCountDownを呼び出す StartCoroutine("StartCountDown"); }
public void Endgame() { Application.LoadLevel(1); isPlaying = false; curState = STATE.GAME_OVER; //Instance.StopCoroutine("UpdateScore"); AudioManager.Instance.PlayDeath(); }
private void Start () { currentState = STATE.IDLE; _as = audio; PlayerPosition = Movement_Controller.playerPos; Debug.Log (PlayerPosition.name); }
void CheckStuckInput() { if (Input.GetButton("Jump")) { state = STATE.FALLING; moveDirection.y = jumpSpeed; } }
//イベントマネージャーから操作 public void action( ) { _flag = true; _state = STATE.STATE_UP; for (int i = 0; i < Part.Count; i++) { Part[ i ].GetComponent<Renderer>().material.SetColor("_RimColor", new Color (0, 0, 0)); } }
protected override void SwitchState( STATE _state ) { base.SwitchState( _state ); if ( this.currentState != _state ) { this.oldPosition = this.transform.localPosition; } }
public void SetOwner(Man owner) { _owner = owner; state = STATE.IN_HAND; // hide gameObject.GetComponent<Collider2D>().isTrigger = true; gameObject.transform.position = new Vector3(0f, 0f, -100f); }
protected override void SwitchState( STATE _state ) { base.SwitchState( _state ); if ( this.currentState != _state ) { this.oldColour = this.currentColour; } }
public void SetState(STATE tState) { mState = tState; }
void Update() { this.step_time += Time.deltaTime; if (this.state == STATE.NONE) { this.next_state = STATE.RUN; } if (next_state != STATE.NONE) { switch (this.next_state) { case STATE.DEFEATED: { this.GetComponent <Rigidbody>().velocity = this.blowout_vector; this.GetComponent <Rigidbody>().angularVelocity = this.blowout_angular_velocity; this.transform.parent = this.main_camera.transform; this.is_alive = false; } break; } this.state = this.next_state; this.next_state = STATE.NONE; this.step_time = 0.0f; } Vector3 new_position = this.transform.position; float low_limit = this.initial_position.y; switch (this.state) { case STATE.RUN: { if (new_position.y < low_limit) { new_position.y = low_limit; } } break; case STATE.DEFEATED: { // 死后的短时间内可能会陷入地面中,速度朝上(=死后的瞬间)时,让其不落入地面中 if (new_position.y < low_limit) { if (this.GetComponent <Rigidbody>().velocity.y > 0.0f) { new_position.y = low_limit; } } if (this.transform.parent != null) { this.GetComponent <Rigidbody>().velocity += -3.0f * Vector3.right * Time.deltaTime; } } break; } this.transform.position = new_position; // if (!this.GetComponent<Renderer>().isVisible && !this.is_alive) // { // Destroy(this.gameObject); // } do { if (this.GetComponent <Renderer>().isVisible) { break; } if (this.is_alive) { break; } Destroy(this.gameObject); } while(false); }
public Tile() { state = STATE.EMPTY; pos = new Vector3(0, 0, 0); obj = null; }
public void Go() { elapsedTime = 0; state = STATE.RUN; }
public void Restart() { this.next_state = STATE.RESTART; }
public void SetState(STATE pGameState) { StopState(_state); _state = pGameState; StartState(_state); }
private void 行道岔占用ToolStripMenuItem_Click(object sender, EventArgs e) { state_down = STATE.占用; Drawpic(DF_flag_up, DF_flag_down, state_up, state_down); }
private void Drawpic_sub(Graphics g, DingFan DF_flag, STATE state, List <myLine> line) { foreach (myLine m in line) { if (m.key == 2) { if (DF_flag == DingFan.定位) { m.enable = true; } else if (DF_flag == DingFan.反位) { m.enable = false; } } else if (m.key == 4) { if (DF_flag == DingFan.定位) { m.enable = false; } else if (DF_flag == DingFan.反位) { m.enable = true; } } m.draw(g, p_blue); } if (DF_flag == DingFan.定位) { foreach (myLine m in line) { if (m.key == 1 || m.key == 2 || m.key == 3) { switch (state) { case STATE.锁闭: m.draw(g, p_white); break; case STATE.占用: m.draw(g, p_red); break; } } } } else { foreach (myLine m in line) { if (m.key == 1 || m.key == 4 || m.key == 5) { switch (state) { case STATE.锁闭: m.draw(g, p_white); break; case STATE.占用: m.draw(g, p_red); break; } } } } }
private void Update() { //ターン遷移 switch (GameManager.Instance.turnManager) { //プレイヤーのターン case GameManager.TurnManager.PlayerStart: //行動する(ポーズ時以外) if (GameManager.Instance.GamePause == false) { if (isMoving == false) { MovePlayer((int)gameObject.transform.position.x, (int)gameObject.transform.position.y); } if (Input.GetKeyDown(KeyCode.LeftShift)) { DirectionMove(); } if (InputManager.GridInputKeyDown(KeyCode.Return)) { GameManager.Instance.turnManager = GameManager.TurnManager.PlayerAttack; AttackPlayer((int)gameObject.transform.position.x, (int)gameObject.transform.position.y); GameManager.Instance.turnManager = GameManager.TurnManager.PlayerEnd; } } break; case GameManager.TurnManager.StateJudge: //状態異常の遷移 switch (state) { case STATE.NONE: break; case STATE.POISON: HP -= 1; if (ReleaseDetermination() == true) { state = STATE.NONE; } break; case STATE.PARALYSIS: if (ReleaseDetermination() == true) { state = STATE.NONE; } else { GameManager.Instance.turnManager = GameManager.TurnManager.PlayerEnd; } break; default: break; } GameManager.Instance.turnManager = GameManager.TurnManager.SatietyCheck; break; case GameManager.TurnManager.SatietyCheck: //空腹度が0 if (Satiety == 0) { HP -= 1; } //0以外 else { Satiety -= 1; } //行動終了 GameManager.Instance.turnManager = GameManager.TurnManager.PlayerEnd; break; default: break; } //死ぬとシーンチェンジ if (HP <= 0) { SceneChanger.ToOver(); } }
/// <summary> /// プレイヤーの移動判定 /// </summary> /// <param name="direction"></param> /// <param name="x"></param> /// <param name="y"></param> private bool CheckMovePlayer(DIRECTION direction, int x, int y) { switch (direction) { case DIRECTION.UP: direction = DIRECTION.UP; if (mapGenerator.MapStatusType[x, y + 1] == (int)MapGenerator.STATE.WALL || mapGenerator.MapStatusType[x, y + 1] == (int)MapGenerator.STATE.ENEMY) { return(false); } else if (mapGenerator.MapStatusType[x, y + 1] == (int)MapGenerator.STATE.TRAP_POISON) { state = STATE.POISON; return(true); } return(true); case DIRECTION.DOWN: direction = DIRECTION.DOWN; if (mapGenerator.MapStatusType[x, y - 1] == (int)MapGenerator.STATE.WALL || mapGenerator.MapStatusType[x, y - 1] == (int)MapGenerator.STATE.ENEMY) { return(false); } else if (mapGenerator.MapStatusType[x, y - 1] == (int)MapGenerator.STATE.TRAP_POISON) { state = STATE.POISON; return(true); } return(true); case DIRECTION.LEFT: direction = DIRECTION.LEFT; if (mapGenerator.MapStatusType[x - 1, y] == (int)MapGenerator.STATE.WALL || mapGenerator.MapStatusType[x - 1, y] == (int)MapGenerator.STATE.ENEMY) { return(false); } else if (mapGenerator.MapStatusType[x - 1, y] == (int)MapGenerator.STATE.TRAP_POISON) { state = STATE.POISON; return(true); } return(true); case DIRECTION.RIGHT: direction = DIRECTION.RIGHT; if (mapGenerator.MapStatusType[x + 1, y] == (int)MapGenerator.STATE.WALL || mapGenerator.MapStatusType[x + 1, y] == (int)MapGenerator.STATE.ENEMY) { return(false); } else if (mapGenerator.MapStatusType[x + 1, y] == (int)MapGenerator.STATE.TRAP_POISON) { state = STATE.POISON; return(true); } return(true); default: return(false); } }
public bool IsTwoPiecesAligned(int column, int line, short[] directionPiece) { STATE playerState = GetCurrentPlayerState(); bool isFinishedLeft = false; bool isFinishedRight = false; bool isFinishedUp = false; bool isFinishedDown = false; bool isFinishedUpLeft = false; bool isFinishedUpRight = false; bool isFinishedDownLeft = false; bool isFinishedDownRight = false; for (short i = 1; i < 8; i++) { //left if (IsInTheGrid(column - i, line) && board[column - i, line] != STATE.EMPTY && !isFinishedLeft) { if (board[column - i, line] == playerState) { directionPiece[(int)DIRECTION.LEFT] = i; isFinishedLeft = true; } } else { isFinishedLeft = true; } //right if (IsInTheGrid(column + i, line) && board[column + i, line] != STATE.EMPTY && !isFinishedRight) { if (board[column + i, line] == playerState) { directionPiece[(int)DIRECTION.RIGHT] = i; isFinishedRight = true; } } else { isFinishedRight = true; } //up if (IsInTheGrid(column, line - i) && board[column, line - i] != STATE.EMPTY && !isFinishedUp) { if (board[column, line - i] == playerState) { directionPiece[(int)DIRECTION.UP] = i; isFinishedUp = true; } } else { isFinishedUp = true; } //down if (IsInTheGrid(column, line + i) && board[column, line + i] != STATE.EMPTY && !isFinishedDown) { if (board[column, line + i] == playerState) { directionPiece[(int)DIRECTION.DOWN] = i; isFinishedDown = true; } } else { isFinishedDown = true; } //UpLeft if (IsInTheGrid(column - i, line - i) && board[column - i, line - i] != STATE.EMPTY && !isFinishedUpLeft) { if (board[column - i, line - i] == playerState) { directionPiece[(int)DIRECTION.UPLEFT] = i; isFinishedUpLeft = true; } } else { isFinishedUpLeft = true; } //UpRight if (IsInTheGrid(column + i, line - i) && board[column + i, line - i] != STATE.EMPTY && !isFinishedUpRight) { if (board[column + i, line - i] == playerState) { directionPiece[(int)DIRECTION.UPRIGHT] = i; isFinishedUpRight = true; } } else { isFinishedUpRight = true; } //DownLeft if (IsInTheGrid(column - i, line + i) && board[column - i, line + i] != STATE.EMPTY && !isFinishedDownLeft) { if (board[column - i, line + i] == playerState) { directionPiece[(int)DIRECTION.DOWNLEFT] = i; isFinishedDownLeft = true; } } else { isFinishedDownLeft = true; } //downRight if (IsInTheGrid(column + i, line + i) && board[column + i, line + i] != STATE.EMPTY && !isFinishedDownRight) { if (board[column + i, line + i] == playerState) { directionPiece[(int)DIRECTION.DOWNRIGHT] = i; isFinishedDownRight = true; } } else { isFinishedDownRight = true; } } if (directionPiece[(int)DIRECTION.DOWN] != -1 || directionPiece[(int)DIRECTION.RIGHT] != -1 || directionPiece[(int)DIRECTION.UP] != -1 || directionPiece[(int)DIRECTION.LEFT] != -1 || directionPiece[(int)DIRECTION.UPLEFT] != -1 || directionPiece[(int)DIRECTION.UPRIGHT] != -1 || directionPiece[(int)DIRECTION.DOWNLEFT] != -1 || directionPiece[(int)DIRECTION.DOWNRIGHT] != -1) { return(true); } return(false); }
// set state public static void Set(STATE s) { state = s; stsflg = true; }
// Update is called once per frame void Update() { // if (Input.GetKeyDown(KeyCode.T)) // { // if (Random.Range(0, 10) < 5) // { // GameObject rb = Instantiate(ragdoll, this.transform.position, this.transform.rotation); // rb.transform.Find("Hips").GetComponent<Rigidbody>().AddForce(Camera.main.transform.forward * 10000); // Destroy(this.gameObject); // } // else // { // TurnOffTriggers(); // anim.SetBool("isDeath", true); // state = STATE.DEAD; // } // return; // } if (target == null && GameStats.gameOver == false) { target = GameObject.FindWithTag("Player"); return; } switch (state) { case STATE.IDLE: if (CanSeePlayer()) { state = STATE.CHASE; } else if (Random.Range(0, 5000) < 5) { state = STATE.WANDER; } break; case STATE.WANDER: if (!agent.hasPath) { float newX = this.transform.position.x + Random.Range(-5, 5); float newZ = this.transform.position.z + Random.Range(-5, 5); float newY = Terrain.activeTerrain.SampleHeight(new Vector3(newX, 0, newZ)); Vector3 dest = new Vector3(newX, newY, newZ); agent.SetDestination(dest); agent.stoppingDistance = 0; TurnOffTriggers(); agent.speed = walkingSpeed; anim.SetBool("isWalking", true); } if (CanSeePlayer()) { state = STATE.CHASE; } else if (Random.Range(0, 5000) < 5) { state = STATE.IDLE; TurnOffTriggers(); agent.ResetPath(); } break; case STATE.CHASE: if (GameStats.gameOver) { TurnOffTriggers(); state = STATE.WANDER; return; } agent.SetDestination(target.transform.position); agent.stoppingDistance = 5; TurnOffTriggers(); agent.speed = runningSpeed; anim.SetBool("isRunning", true); if (agent.remainingDistance <= agent.stoppingDistance && !agent.pathPending) { state = STATE.ATTACK; } if (ForgetPlayer()) { state = STATE.WANDER; agent.ResetPath(); } break; case STATE.ATTACK: if (GameStats.gameOver) { TurnOffTriggers(); state = STATE.WANDER; return; } TurnOffTriggers(); anim.SetBool("isAttack", true); //this.transform.LookAt(target.transform.position); Vector3 targetPosition = new Vector3(target.transform.position.x, this.transform.position.y, target.transform.position.z); this.transform.LookAt(targetPosition); if (DistanceToPlayer() > agent.stoppingDistance + 2) { state = STATE.CHASE; } break; case STATE.DEAD: // TurnOffTriggers(); // anim.SetBool("isDead", true); Destroy(agent); AudioSource[] sound = this.GetComponents <AudioSource>(); foreach (AudioSource s in sound) { s.volume = 0; } this.GetComponent <Sink>().StartSink(); break; } }
// Use this for initialization void Start() { pc = GetComponent <PC>(); packetPrefab = GetComponent <Ping>().packetprefab; dhcpState = 0; }
public void KillZombie() { TurnOffTriggers(); anim.SetBool("isDeath", true); state = STATE.DEAD; }
private void 道岔空闲ToolStripMenuItem_Click(object sender, EventArgs e) { state_up = STATE.空闲; Drawpic(DF_flag_up, DF_flag_down, state_up, state_down); }
void Update() { PazzleControl.DrawBounds(this.GetBounds(Vector3.zero)); Color color = this.origin_color; switch (this.state) { case STATE.NONE: { this.next_state = STATE.RESTART; } break; case STATE.IDLE: { if (this.is_now_dragging) { this.next_state = STATE.DRAGING; } } break; case STATE.DRAGING: { // 鼠标放开时 if (!this.is_now_dragging) { // 在吸附范围内 if (this.is_in_snap_range()) { this.next_state = STATE.SNAPPING; this.snap_target = this.finished_position; this.next_state_snap = STATE.FINISHED; } // 在吸附范围外 else { this.next_state = STATE.IDLE; } } } break; case STATE.SNAPPING: { if ((this.transform.position - this.snap_target).magnitude < 0.0001f) { this.next_state = this.next_state_snap; } } break; } if (this.next_state != STATE.NONE) { switch (this.next_state) { //case STATE.IDLE: // { // // this.SetHeightOffset(this.height_offset); // } // break; case STATE.RESTART: { this.transform.position = this.start_position; // this.SetHeightOffset(this.height_offset); this.next_state = STATE.IDLE; } break; case STATE.DRAGING: { this.begin_dragging(); this.pazzle_control.PickPiece(this); } break; case STATE.FINISHED: { this.transform.position = this.finished_position; this.pazzle_control.FinishPiece(this); } break; } this.state = this.next_state; this.next_state = STATE.NONE; } this.transform.localScale = Vector3.one; switch (this.state) { case STATE.DRAGING: { this.do_dragging(); if (this.is_in_snap_range()) { color = Color.Lerp(color, Color.white, .5f); } this.transform.localScale = Vector3.one * 1.1f; } break; case STATE.SNAPPING: { Vector3 next_position, distance, move; distance = this.snap_target - this.transform.position; distance *= 0.25f * (60.0f * Time.deltaTime); next_position = this.transform.position + distance; move = next_position - this.transform.position; float snap_speed_min = PieceControl.SNAP_SPEED_MIN * Time.deltaTime; float snap_speed_max = PieceControl.SNAP_SPEED_MAX * Time.deltaTime; if (move.magnitude < snap_speed_min) { this.transform.position = this.snap_target; } else { if (move.magnitude > snap_speed_max) { move *= snap_speed_max / move.magnitude; next_position = this.transform.position + move; } this.transform.position = next_position; } } break; } this.GetComponent <Renderer>().material.color = color; }
private void 行道岔占用_Click(object sender, EventArgs e) { state_up = STATE.占用; Drawpic(DF_flag_up, DF_flag_down, state_up, state_down); }
// Use this for initialization void Start() { state = STATE.STAFFROLL; }
void NextPhase() { state = STATE.ALIVE; transform.Rotate(0, 0, 90); }
public void Reset() { transform.localScale = startingSize; myState = STATE.REST; cycleRunning = false; }
public void SetBallState(STATE newState) { switch (newState) { case STATE.PRE_START: if (GetComponent <Renderer>().enabled) { GetComponent <Renderer>().enabled = false; } if (GetComponent <Rigidbody>() != null && !GetComponent <Rigidbody>().isKinematic) { GetComponent <Rigidbody>().isKinematic = true; } if (GetComponent <Rigidbody>() != null && GetComponent <Rigidbody>().useGravity) { GetComponent <Rigidbody>().useGravity = false; } if (GetComponent <TrailRenderer>() != null && GetComponent <TrailRenderer>().enabled) { GetComponent <TrailRenderer>().enabled = false; } break; case STATE.EMERGING: if (!GetComponent <Renderer>().enabled) { GetComponent <Renderer>().enabled = true; } if (GetComponent <Rigidbody>() != null && GetComponent <Rigidbody>().isKinematic) { GetComponent <Rigidbody>().isKinematic = false; } if (GetComponent <Rigidbody>() != null && GetComponent <Rigidbody>().useGravity) { GetComponent <Rigidbody>().useGravity = false; } if (GetComponent <TrailRenderer>() != null && GetComponent <TrailRenderer>().enabled) { GetComponent <TrailRenderer>().enabled = false; } break; case STATE.IN_PLAY: if (!GetComponent <Renderer>().enabled) { GetComponent <Renderer>().enabled = true; } if (GetComponent <Rigidbody>() != null && GetComponent <Rigidbody>().isKinematic) { GetComponent <Rigidbody>().isKinematic = false; } if (GetComponent <Rigidbody>() != null && !GetComponent <Rigidbody>().useGravity) { GetComponent <Rigidbody>().useGravity = true; } if (GetComponent <TrailRenderer>() != null && !GetComponent <TrailRenderer>().enabled) { GetComponent <TrailRenderer>().enabled = true; } break; default: break; } ballState = newState; }
private void deviceThread() { STATE state = STATE.IDLE; COMMAND com = COMMAND.NONE; byte[] image = null; byte[][] resultFeat = null; byte[][] imageStack = null; byte[][] FingerFeat = null; int firstEnrollCount = 0, secondEnrollCount = 0; int status = 0; BioNetACSDLL._AlgoInit(); Thread.Sleep(1000); var error = BioNetACSDLL._OpenNetAccessDeviceByUSN(name); if (error != 1) { throw new Exception("Can't open device"); } int uniqueUsbKey = BioNetACSDLL._GetUSBKey(); int imageSize = BioNetACSDLL._GetImgSize(); int imageWidth = BioNetACSDLL._GetImgWidth(); int imageHeight = BioNetACSDLL._GetImgSize() / BioNetACSDLL._GetImgWidth(); FingerFeat = new byte[MAX_FEATURE][]; for (int i = 0; i < MAX_FEATURE; i++) { FingerFeat[i] = new byte[BioNetACSDLL._GetFeatSize()]; } try { while (true) { cancelToken.Token.ThrowIfCancellationRequested(); if (state == STATE.IDLE) { com = queue.Take(cancelToken.Token); } else { // non blocking take if (queue.Count > 0) { com = queue.Take(); } } switch (com) { case COMMAND.LIVECAPTURE_START: state = STATE.TEST; break; case COMMAND.SINGLECAPTURE_START: state = STATE.GETSINGLE; break; case COMMAND.ENROLLMENT_START: state = STATE.GETFINGER_1; resultFeat = new byte[2][]; for (int i = 0; i < 2; i++) { resultFeat[i] = new byte[BioNetACSDLL._GetFeatSize()]; } imageStack = new byte[ENROLL_IMAGES * 2][]; for (int i = 0; i < ENROLL_IMAGES * 2; i++) { imageStack[i] = new byte[imageSize]; } firstEnrollCount = 0; secondEnrollCount = 0; resultBios.Clear(); break; case COMMAND.LIVECAPTURE_STOP: case COMMAND.SINGLECAPTURE_STOP: case COMMAND.ENROLLMENT_STOP: state = STATE.IDLE; break; } com = COMMAND.NONE; if (uniqueUsbKey != BioNetACSDLL._GetUSBKey()) { if (state != STATE.OFFLINE) { state = STATE.OFFLINE; Ambassador.AddMessage(new MSignal(this, MSignal.SIGNAL.DEVICE_FAILURE)); } } switch (state) { case STATE.TEST: image = new byte[imageSize]; status = BioNetACSDLL._GetNetAccessImage(image); switch (status) { // not connected case -1: state = STATE.OFFLINE; SendBaseMessage("Scanner is not connected"); break; case 0: SendBaseMessage("Please, touch the scanner"); break; default: break; } OnBiometricsCaptured(new FingerImageIB(image,imageWidth,imageHeight)); break; case STATE.GETSINGLE: SendBaseMessage("Please, touch the scanner"); image = new byte[imageSize]; status = BioNetACSDLL._GetNetAccessImage(image); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: break; case 1: int qual = BioNetACSDLL._GetIBQualityScore(image); if (qual > NEEDED_QUALITY) { goto default; } SendPopUpMessage("Image quality " + qual + " not enough, keep finger on scanner"); OnBiometricsCaptured(new FingerImageIB(image,imageWidth,imageHeight)); break; default: OnSingleCaptured(new FingerImageIB(image,imageWidth,imageHeight)); state = STATE.LIFTSINGLE; break; } break; case STATE.LIFTSINGLE: image = new byte[imageSize]; status = BioNetACSDLL._GetNetAccessImage(image); BioNetACSDLL._ControlTOUCH(false); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: state = STATE.GETSINGLE; break; default: //SendPopUpMessage("Please, remove finger from the scanner"); break; } break; case STATE.GETFINGER_1: image = new byte[imageSize]; state = STATE.GETIMAGE_1; BioNetACSDLL._ChangeGain(0); break; case STATE.GETIMAGE_1: status = BioNetACSDLL._GetNetAccessImageByManual(image); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: SendBaseMessage("Please, touch the scanner"); break; case 1: int qual = BioNetACSDLL._GetIBQualityScore(image); if (qual > NEEDED_QUALITY) { goto default; } SendPopUpMessage("Image quality " + qual + " not enough, keep finger on scanner"); OnBiometricsCaptured(new FingerImageIB(image,imageWidth,imageHeight)); break; default: Array.Copy(image,imageStack[firstEnrollCount],imageSize); OnBiometricsCaptured(new FingerImageIB(image,imageWidth,imageHeight)); firstEnrollCount++; OnSendProgressMessage((firstEnrollCount) * 22); state = STATE.GETEMPTY_1; break; } break; case STATE.GETEMPTY_1: image = new byte[imageSize]; status = BioNetACSDLL._GetNetAccessImage(image); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: if (firstEnrollCount < 3) { state = STATE.GETFINGER_1; } else { int singeEnrolResult = BioNetACSDLL._Enroll_SingleTemplate( (byte[])imageStack[0],(byte[])imageStack[1],(byte[])imageStack[2], (byte[])FingerFeat[0],(byte[])FingerFeat[1],(byte[])FingerFeat[2], resultFeat[0]); if (singeEnrolResult < 1) { state = STATE.GETEMPTY_2; } else { state = STATE.IDLE; resultBios.Add(new TemplateIB(resultFeat[0])); SendPopUpMessage("Successfully registered"); OnBiometricsEnrolled(resultBios.ToList()); } } break; default: SendPopUpMessage("Please, remove finger from the scanner"); break; } break; case STATE.GETFINGER_2: image = new byte[imageSize]; state = STATE.GETIMAGE_2; break; case STATE.GETIMAGE_2: status = BioNetACSDLL._GetNetAccessImageByManual(image); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: SendBaseMessage("Please, touch the scanner"); break; case 1: int qual = BioNetACSDLL._GetIBQualityScore(image); if (qual > NEEDED_QUALITY) { goto default; } SendPopUpMessage("Image quality " + qual + " not enough, keep finger on scanner"); OnBiometricsCaptured(new FingerImageIB(image, imageWidth, imageHeight)); break; default: Array.Copy(image, imageStack[secondEnrollCount], imageSize); OnBiometricsCaptured(new FingerImageIB(image, imageWidth, imageHeight)); secondEnrollCount++; OnSendProgressMessage(66 + (secondEnrollCount) * 11); state = STATE.GETEMPTY_2; break; } break; case STATE.GETEMPTY_2: image = new byte[imageSize]; status = BioNetACSDLL._GetNetAccessImage(image); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: if (secondEnrollCount < 3) { state = STATE.GETFINGER_2; } else { int multiEnrollResult = BioNetACSDLL._Enroll_MultiTemplate( (byte[])FingerFeat[0], (byte[])FingerFeat[1], (byte[])FingerFeat[2], (byte[])imageStack[3], (byte[])imageStack[4], (byte[])imageStack[5], resultFeat[0], resultFeat[1]); if (multiEnrollResult > 0) { state = STATE.IDLE; resultBios.Add(new TemplateIB(resultFeat[0])); resultBios.Add(new TemplateIB(resultFeat[1])); SendPopUpMessage("Successfully registered"); OnBiometricsEnrolled(resultBios.ToList()); } else { state = STATE.IDLE; SendPopUpMessage("Can't create template, please repeat"); OnBiometricsEnrolled(null); } } break; default: SendPopUpMessage("Please, remove finger from the scanner"); break; } break; case STATE.OFFLINE: break; } } } catch { BioNetACSDLL._CloseNetAccessDevice(); } }
// Update is called once per frame void Update() { switch (state) { case STATE.SELECT_START: { if (!Input.GetMouseButtonDown(0)) { return; } var _ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit _hit = new RaycastHit(); if (Physics.Raycast(_ray, out _hit, 1000.0f, 1 << LayerMask.NameToLayer("Grid"))) { Grid _grid = _hit.collider.GetComponentInParent <Grid> (); if (_grid) { startGrid = _grid; state = STATE.SELECT_END; startGrid.GetComponentInChildren <MeshRenderer> ().material.color = Color.green; } } } break; case STATE.SELECT_END: { if (!Input.GetMouseButtonDown(0)) { return; } Ray _ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit _hit = new RaycastHit(); if (Physics.Raycast(_ray, out _hit, 1000.0f, 1 << LayerMask.NameToLayer("Grid"))) { Grid _grid = _hit.collider.GetComponentInParent <Grid> (); if (_grid) { endGrid = _grid; state = STATE.SELECT_RESULT; endGrid.GetComponentInChildren <MeshRenderer> ().material.color = Color.red; } } } break; case STATE.SELECT_RESULT: AStarFun(); state = STATE.SELECT_RESET; break; case STATE.SELECT_RESET: if (Input.GetKeyDown(KeyCode.Space)) { map.ResetColor(); startGrid = null; endGrid = null; state = STATE.SELECT_START; } break; default: throw new System.ArgumentOutOfRangeException(); } }
void GetImgBytes() { nowState = "加载图片地址,第一次加载需要5到8秒。"; if (items.Count == 0) { string uri = "http://pic.sogou.com/pics/channel/getAllRecomPicByTag.jsp?category=%E7%BE%8E%E5%A5%B3&tag="; uri += "%E5%85%A8%E9%83%A8&tag=&start=0&len=10000"; string jsonDataStr = GetRomoteString(uri); if (jsonDataStr != null && jsonDataStr.Length > 0) { nowState = "解析图片地址,大概需要5秒,请稍等。"; jsonDataStr = jsonDataStr.Replace("\r", "").Replace("\n", ""); Dictionary <string, object> jsonResult = MiniJSON.Json.Deserialize(jsonDataStr) as Dictionary <string, object>; List <System.Object> temp = jsonResult["all_items"] as List <System.Object>; for (int i = 0; i < temp.Count; i++) { if (temp[i] is List <System.Object> ) { var temp1 = temp[i] as List <System.Object>; for (int j = 0; j < temp1.Count; j++) { var oo = temp1[j] as Dictionary <string, System.Object>; if (oo == null) { break; } items.Add(oo["pic_url"] as string); } } else { var oo = temp[i] as Dictionary <string, System.Object>; if (oo == null) { break; } items.Add(oo["pic_url"] as string); } } } } if (items.Count == 0) { errorString = "图片地址加载失败 =.=,没福利了"; return; } maxCount = items.Count; random = -1; while (random == -1) { //wait.... } string o = items[random]; items.RemoveAt(random); if (items.Count == 0) { GetImgBytes(); return; } nowState = "加载图片..."; textureBytes = GetRomoteByte(o); state = STATE.LoadComplete; nowState = "加载完成,点击可切换。"; }
// Update is called once per frame void Update() { switch (m_state) { case STATE.Spawning: gameObject.transform.position += Vector3.down * m_fallSpeed * Time.deltaTime; if (gameObject.transform.position.y <= m_targetSpawnPos.y) { gameObject.transform.position = m_targetSpawnPos; m_state = STATE.Walking; } m_blobShadow.transform.position = m_targetSpawnPos; animator.SetInteger("TrollState", 0); break; case STATE.Walking: { m_changeDirectionTimer -= Time.deltaTime; if (m_changeDirectionTimer <= 0) { RandomiseDirection(); } Vector3 directionVector = Vector3.zero; switch (m_directionComponent.m_direction) { case Direction.DIRECTION_ENUM.NORTH: directionVector = Vector3.up; break; case Direction.DIRECTION_ENUM.EAST: directionVector = Vector3.right; break; case Direction.DIRECTION_ENUM.SOUTH: directionVector = Vector3.down; break; case Direction.DIRECTION_ENUM.WEST: directionVector = Vector3.left; break; } // Move gameObject.transform.position += directionVector * Time.deltaTime * m_speed; // Clamp if (gameObject.transform.position.x < m_targetSpawnPos.x - m_roamDistance) { gameObject.transform.position = new Vector3(m_targetSpawnPos.x - m_roamDistance, gameObject.transform.position.y, gameObject.transform.position.z); RandomiseDirection(); } else if (gameObject.transform.position.x > m_targetSpawnPos.x + m_roamDistance) { gameObject.transform.position = new Vector3(m_targetSpawnPos.x + m_roamDistance, gameObject.transform.position.y, gameObject.transform.position.z); RandomiseDirection(); } if (gameObject.transform.position.y < m_targetSpawnPos.y - m_roamDistance) { gameObject.transform.position = new Vector3(gameObject.transform.position.x, m_targetSpawnPos.y - m_roamDistance, gameObject.transform.position.z); RandomiseDirection(); } else if (gameObject.transform.position.y > m_targetSpawnPos.y + m_roamDistance) { gameObject.transform.position = new Vector3(gameObject.transform.position.x, m_targetSpawnPos.y + m_roamDistance, gameObject.transform.position.z); RandomiseDirection(); } if (m_directionComponent.m_direction == Direction.DIRECTION_ENUM.EAST) { spriter.flipX = false; } if (m_directionComponent.m_direction == Direction.DIRECTION_ENUM.WEST) { spriter.flipX = true; } animator.SetInteger("TrollState", 1); } break; case STATE.Dying: { m_deathTimer -= Time.deltaTime; if (m_deathTimer <= 0) { GameObject.Destroy(gameObject); return; } animator.SetInteger("TrollState", 2); } break; } // Force Z depth gameObject.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, -1.0f); }
// Update is called once per frame void Update() { if (target.transform.position.x > this.transform.position.x) { direction = 1; //direita } else { direction = -1; //esquerda } bossScale = new Vector3(direction * 2, 2f, 2f); transform.localScale = bossScale; if (bossState == STATE.idel) { //permiter boss atkar waveInstance = false; rockInstance = false; totalTime += Time.deltaTime; if (totalTime >= idelTime) { anim.SetInteger("bossState", 1); bossState = STATE.move; } } else if (bossState == STATE.move) { //seguir player this.transform.Translate(direction * velocity * Time.deltaTime, 0f, 0f); if (Mathf.Abs(this.transform.position.x - target.transform.position.x) < distAtk) { anim.SetInteger("bossState", 2); totalTime = 0; if (target.transform.position.y <= playerHeight) { bossState = STATE.atk; } else { bossState = STATE.specialAtk; } } } else if (bossState == STATE.atk) { totalTime += Time.deltaTime; if (totalTime >= 0.45f && waveInstance == false) { GetComponent <MeleeAttack>().Attack(); wave.transform.localScale = new Vector3(direction * 4, 8f, 1f); Instantiate(wave, new Vector3(this.transform.position.x + (direction * 7f), this.transform.position.y, transform.position.z), wave.transform.rotation); waveInstance = true; } if (totalTime >= atkingTime) { anim.SetInteger("bossState", 0); totalTime = 0f; bossState = STATE.idel; } } else if (bossState == STATE.specialAtk) { totalTime += Time.deltaTime; if (totalTime >= 0.6f && rockInstance == false) { Instantiate(rock, new Vector3(target.transform.position.x, player.transform.position.y + 5f, rock.transform.position.z), rock.transform.rotation); rockInstance = true; } if (totalTime >= atkingTime) { anim.SetInteger("bossState", 0); totalTime = 0f; bossState = STATE.idel; } } }
private static void timer_test_EvtKeyPress(object obj) { if (((ConsoleKeyInfo)obj).Key == ConsoleKey.Spacebar) { if (iActived == STATE.ON) { iActived = STATE.PAUSED; } else if (iActived == STATE.PAUSED) { iActived = STATE.ON; } else if (iActived == STATE.OFF) { iActived = STATE.EXIT; return; } else { ; //??? throw } if (iActived == STATE.ON) { lock (lockTimer) { if (!(timer == null)) { //Активация... timer.Change(0, System.Threading.Timeout.Infinite); } else { ; } } Console.WriteLine(); } else if (iActived == STATE.PAUSED) { lock (lockTimer) { if (!(timer == null)) { //Деактивация... timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); } else { ; } } Console.WriteLine(); Console.WriteLine(@"Для продолжения нажмите 'Spacebar'..."); } else { ; } if (Data.IsStarted == true) { if ((Data.Actived == true) && (iActived == STATE.PAUSED)) { //Деактивация... Data.Activate(false); } else if ((Data.Actived == false) && (iActived == STATE.ON)) { //Деактивация... Data.Activate(true); } else { ; } } } else { ; } }
// costructor public StateM() { state = STATE.CHECK_ERR; stsflg = true; }
public Zombie(Ecosystem ecosystem, int speed, Position position, STATE state = STATE.Alive) : base(ecosystem, speed, position, state) { this.Color = Color.Black; }