private void UpdateStand(PlayerNumber _pl) { CharaSelectorSet set = new CharaSelectorSet(); SelecterStates state = null; Images images = null; Sprite sprite = null; if (_pl == PlayerNumber.player1) { state = this.pl1States; set = this.charaSelectorSets[state.NowIndex]; images = this.pl1Images; sprite = set.StandPL1; } if (_pl == PlayerNumber.player2) { state = this.pl2States; set = this.charaSelectorSets[state.NowIndex]; images = this.pl2Images; sprite = set.StandPL2; } if (set.PlayerCharacter == PlayerCharacterEnum.length_empty) { images.StandFront.sprite = null; images.StandFront.enabled = false; } else { images.StandFront.enabled = true; images.StandFront.sprite = sprite; } }
private void UpdateNames(PlayerNumber _pl) { SelecterStates state = null; CharaSelectorSet set = new CharaSelectorSet(); Images images = null; if (_pl == PlayerNumber.player1) { state = this.pl1States; set = this.charaSelectorSets[state.NowIndex]; images = this.pl1Images; } if (_pl == PlayerNumber.player2) { state = this.pl2States; set = this.charaSelectorSets[state.NowIndex]; images = this.pl2Images; } if (set.PlayerCharacter == PlayerCharacterEnum.length_empty) { images.SetNameImages(null, null); images.Kana.enabled = false; images.Alp.enabled = false; } else { images.Kana.enabled = true; images.Alp.enabled = true; images.SetNameImages(set.KanaName, set.AlpName); } }
private bool CancelFunc(PlayerNumber _pl) { SelecterStates state = null; Images images = null; Sprite sprite = null; if (_pl == PlayerNumber.player1) { state = this.pl1States; images = this.pl1Images; sprite = this.sprites.StandBackNormal1; } if (_pl == PlayerNumber.player2) { state = this.pl2States; images = this.pl2Images; sprite = this.sprites.StandBackNormal2; } state.PlayerCharacter = PlayerCharacterEnum.length_empty; state.IsSelected = false; images.StandBack.sprite = sprite; UpdateCursor(state.NowIndex); return(true); }
/// <summary> /// カーソルを_advanceだけ進める /// </summary> /// <param name="_pl">操作したプレイヤー</param> /// <param name="_advance">進める数</param> private void NextContent(PlayerNumber _pl, int _advance) { SelecterStates state = (_pl == PlayerNumber.player1) ? this.pl1States : (_pl == PlayerNumber.player2) ? this.pl2States : null; var prevIndex = state.NowIndex; state.NowIndex = (state.NowIndex + _advance) % this.charaSelectorSets.Length; UpdateCursor(prevIndex); UpdateCursor(state.NowIndex); UpdateStand(_pl); UpdateNames(_pl); // SE: AudioManager.Instance.PlaySe(SoundEffectEnum.cursor); }
protected override void OnInit() { this.elapsedTime = 0; // private fields this.pl1States = new SelecterStates(); this.pl1States.NowIndex = this.pl1FirstIndex; this.pl1States.KeyIntervalStartTime = 0f; this.pl1States.RapidKeyWaitStartTime = 0f; this.pl1States.IsFirstCursorMove = false; this.pl1States.IsSelected = false; this.pl1States.PlayerCharacter = PlayerCharacterEnum.length_empty; this.pl2States = new SelecterStates(); this.pl2States.NowIndex = this.pl2FirstIndex; this.pl2States.KeyIntervalStartTime = 0f; this.pl2States.RapidKeyWaitStartTime = 0f; this.pl2States.IsFirstCursorMove = false; this.pl2States.IsSelected = false; this.pl2States.PlayerCharacter = PlayerCharacterEnum.length_empty; this.nextToStageSelectImage.enabled = false; this.prevToTitleImage.enabled = false; this.allSelectedTime = 0; // selectorの初期化 for (int i = 0; i < this.charaSelectorSets.Length; ++i) { var set = this.charaSelectorSets[i]; set.SelectorImage.sprite = set.Selector; set.CursorImage.sprite = this.sprites.Normal; UpdateCursor(i); } UpdateStand(PlayerNumber.player1); UpdateStand(PlayerNumber.player2); UpdateNames(PlayerNumber.player1); UpdateNames(PlayerNumber.player2); }
private bool ReturnFunc(PlayerNumber _pl) { SelecterStates state = null; PlayerCharacterEnum pc = PlayerCharacterEnum.length_empty; Images images = null; Sprite sprite = null; if (_pl == PlayerNumber.player1) { state = this.pl1States; pc = this.charaSelectorSets[this.pl1States.NowIndex].PlayerCharacter; images = this.pl1Images; sprite = this.sprites.StandBackActive1; } if (_pl == PlayerNumber.player2) { state = this.pl2States; pc = this.charaSelectorSets[this.pl2States.NowIndex].PlayerCharacter; images = this.pl2Images; sprite = this.sprites.StandBackActive2; } if (state.IsSelected) { return(true); } if (pc == PlayerCharacterEnum.length_empty || pc == PlayerCharacterEnum.emilia || pc == PlayerCharacterEnum.laxa || pc == PlayerCharacterEnum.vega_al) { // SE: AudioManager.Instance.PlaySe(SoundEffectEnum.error); return(false); } else if (pc == PlayerCharacterEnum.random) { var random = new Random(); int index; while (true) { index = random.Next(0, (int)PlayerCharacterEnum.length_empty); pc = this.charaSelectorSets[index].PlayerCharacter; if (pc != PlayerCharacterEnum.random && pc != PlayerCharacterEnum.emilia && pc != PlayerCharacterEnum.laxa && pc != PlayerCharacterEnum.vega_al && pc != PlayerCharacterEnum.length_empty) { break; } } state.PlayerCharacter = pc; state.IsSelected = true; images.StandBack.sprite = sprite; var tmp = state.NowIndex; state.NowIndex = index; UpdateCursor(tmp); UpdateCursor(state.NowIndex); UpdateStand(_pl); UpdateNames(_pl); // SE: AudioManager.Instance.PlaySe(SoundEffectEnum.decision); return(true); } else { state.PlayerCharacter = pc; state.IsSelected = true; images.StandBack.sprite = sprite; UpdateCursor(state.NowIndex); // SE: AudioManager.Instance.PlaySe(SoundEffectEnum.decision); return(true); } }
private void MoveCursorFunc(PlayerNumber _pl) { SelecterStates states = (_pl == PlayerNumber.player1) ? this.pl1States : (_pl == PlayerNumber.player2) ? this.pl2States : null; // PlayerKey key = (_pl == PlayerNumber.player1) ? this.pl1key : // (_pl == PlayerNumber.player2) ? this.pl2key : new PlayerKey(); // いずれの方向キーも押されていない // if (!Input.GetKey(key.UpKey) && !Input.GetKey(key.DownKey) && !Input.GetKey(key.RightKey) && !Input.GetKey(key.LeftKey)) if (!RiaInput.Instance.GetPush(RiaInput.KeyType.Up, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Down, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Right, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Left, _pl)) { states.KeyIntervalStartTime = -1; states.RapidKeyWaitStartTime = -1; states.IsFirstCursorMove = false; return; } // いずれかの方向キーがいずれも押されていない状態からKeyDownした else if (states.KeyIntervalStartTime == -1) { states.KeyIntervalStartTime = this.elapsedTime; states.RapidKeyWaitStartTime = this.elapsedTime; return; } // キー入力のインターバル時間に達していない if (this.elapsedTime - states.KeyIntervalStartTime < this.pressedReactionIntervalTime) { return; } // キーの連射入力時間に達しておらず、連射扱いとなる場合 if (this.elapsedTime - states.RapidKeyWaitStartTime < this.pressedWaitTime && states.IsFirstCursorMove) { return; } // キーの連射速度時間に達していない場合 if (this.elapsedTime - states.KeyIntervalStartTime < this.pressedRapidIntervalTime && states.IsFirstCursorMove) { return; } if (!states.IsFirstCursorMove) { states.IsFirstCursorMove = true; } // var isUp = Input.GetKey(key.UpKey) && // !Input.GetKey(key.DownKey) && !Input.GetKey(key.RightKey) && !Input.GetKey(key.LeftKey); // // var isDown = Input.GetKey(key.DownKey) && // !Input.GetKey(key.UpKey) && !Input.GetKey(key.RightKey) && !Input.GetKey(key.LeftKey); // // var isRight = Input.GetKey(key.RightKey) && // !Input.GetKey(key.UpKey) && !Input.GetKey(key.DownKey) && !Input.GetKey(key.LeftKey); // // var isLeft = Input.GetKey(key.LeftKey) && // !Input.GetKey(key.UpKey) && !Input.GetKey(key.DownKey) && !Input.GetKey(key.RightKey); // // var isUpLeft = Input.GetKey(key.UpKey) && Input.GetKey(key.LeftKey) && // !Input.GetKey(key.DownKey) && !Input.GetKey(key.RightKey); // // var isUpRight = Input.GetKey(key.UpKey) && Input.GetKey(key.RightKey) && // !Input.GetKey(key.DownKey) && !Input.GetKey(key.LeftKey); // // var isDownLeft = Input.GetKey(key.DownKey) && Input.GetKey(key.LeftKey) && // !Input.GetKey(key.UpKey) && !Input.GetKey(key.RightKey); // // var isDownRight = Input.GetKey(key.DownKey) && Input.GetKey(key.RightKey) && // !Input.GetKey(key.UpKey) && !Input.GetKey(key.LeftKey); // todo: ビットマスクでもっとスマートに書ける by flanny7 var isUp = RiaInput.Instance.GetPush(RiaInput.KeyType.Up, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Down, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Right, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Left, _pl); var isDown = !RiaInput.Instance.GetPush(RiaInput.KeyType.Up, _pl) && RiaInput.Instance.GetPush(RiaInput.KeyType.Down, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Right, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Left, _pl); var isRight = !RiaInput.Instance.GetPush(RiaInput.KeyType.Up, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Down, _pl) && RiaInput.Instance.GetPush(RiaInput.KeyType.Right, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Left, _pl); var isLeft = !RiaInput.Instance.GetPush(RiaInput.KeyType.Up, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Down, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Right, _pl) && RiaInput.Instance.GetPush(RiaInput.KeyType.Left, _pl); var isUpRight = RiaInput.Instance.GetPush(RiaInput.KeyType.Up, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Down, _pl) && RiaInput.Instance.GetPush(RiaInput.KeyType.Right, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Left, _pl); var isUpLeft = RiaInput.Instance.GetPush(RiaInput.KeyType.Up, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Down, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Right, _pl) && RiaInput.Instance.GetPush(RiaInput.KeyType.Left, _pl); var isDownRight = !RiaInput.Instance.GetPush(RiaInput.KeyType.Up, _pl) && RiaInput.Instance.GetPush(RiaInput.KeyType.Down, _pl) && RiaInput.Instance.GetPush(RiaInput.KeyType.Right, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Left, _pl); var isDownLeft = !RiaInput.Instance.GetPush(RiaInput.KeyType.Up, _pl) && RiaInput.Instance.GetPush(RiaInput.KeyType.Down, _pl) && !RiaInput.Instance.GetPush(RiaInput.KeyType.Right, _pl) && RiaInput.Instance.GetPush(RiaInput.KeyType.Left, _pl); var index = states.NowIndex; if (isUp) { if (index == 0 || index == 1 || index == 2) { this.PrevContent(_pl, 3); } else if (index == 3 || index == 4) { this.PrevContent(_pl, 8); } else { this.PrevContent(_pl, 5); } states.KeyIntervalStartTime = this.elapsedTime; } if (isDown) { if (index == 12 || index == 11 || index == 10) { this.NextContent(_pl, 3); } else if (index == 9 || index == 8) { this.NextContent(_pl, 8); } else { this.NextContent(_pl, 5); } states.KeyIntervalStartTime = this.elapsedTime; } if (isRight) { if (index == 2 || index == 7 || index == 12) { this.PrevContent(_pl, 2); } else if (index == 4 || index == 9) { this.PrevContent(_pl, 1); } else { this.NextContent(_pl); } states.KeyIntervalStartTime = this.elapsedTime; } if (isLeft) { if (index == 0 || index == 5 || index == 10) { this.NextContent(_pl, 2); } else if (index == 3 || index == 8) { this.NextContent(_pl, 1); } else { this.PrevContent(_pl); } states.KeyIntervalStartTime = this.elapsedTime; } if (isUpLeft) { if (index == 2 || index == 10) { this.PrevContent(_pl, 0); } else if (index == 1 || index == 5) { this.NextContent(_pl, 6); } else if (index == 0) { this.PrevContent(_pl, 1); } else { this.PrevContent(_pl, 3); } states.KeyIntervalStartTime = this.elapsedTime; } if (isUpRight) { if (index == 0 || index == 12) { this.PrevContent(_pl, 0); } else if (index == 1 || index == 7) { this.NextContent(_pl, 4); } else if (index == 2) { this.PrevContent(_pl, 5); } else { this.PrevContent(_pl, 2); } states.KeyIntervalStartTime = this.elapsedTime; } if (isDownLeft) { if (index == 0 || index == 12) { this.NextContent(_pl, 0); } else if (index == 5 || index == 11) { this.PrevContent(_pl, 4); } else if (index == 10) { this.NextContent(_pl, 5); } else { this.NextContent(_pl, 2); } states.KeyIntervalStartTime = this.elapsedTime; } if (isDownRight) { if (index == 2 || index == 10) { this.NextContent(_pl, 0); } else if (index == 7 || index == 11) { this.PrevContent(_pl, 6); } else if (index == 12) { this.NextContent(_pl, 1); } else { this.NextContent(_pl, 3); } states.KeyIntervalStartTime = this.elapsedTime; } }