/// <summary> /// 感情をセットする /// </summary> /// <param name="MotionCode"></param> /// <returns></returns> public IEnumerator SetExpression(MOTION MotionCode) { foreach (var model in ModelList) { yield return(model.SetExpression(MotionCode)); } }
/// <summary> /// エクスプレッションの設定 /// </summary> /// <param name="ExpressionCode"></param> public IEnumerator SetExpression(MOTION ExpressionCode) { //対照感情のモーション取得 string motionName = GetMotionNameTargetMotionRndam(ExpressionCode); //取得モーションがNULLでなければ実行する。 if (motionName != null) { //モーション実行 Animator.Play(motionName); Animator.Blend(GetExpressionNameTargetMotionRndam(ExpressionCode)); //モーション完了待ち yield return(new WaitForSeconds(Animator.GetClip(motionName).length)); //パラメーター初期化 //InitParamator(); //表情とアイドル設定 Animator.Blend(GetMotionNameTargetIdleMotionRndam()); } else { //様子見中 //一旦停止 //Animator.Stop(); //パラメーター初期化 //InitParamator(); //表情とアイドル設定 Animator.Play(GetExpressionNameTargetMotionRndam(ExpressionCode)); Animator.Blend(GetMotionNameTargetIdleMotionRndam()); } }
/// <summary> /// ランダムモーション /// </summary> /// <param name="MotionCode"></param> public void StartRandomMotion(MOTION MotionCode) { foreach (var model in ModelList) { model.StartRandomMotion(MotionCode); } }
public void updateMotionDetectorDetails(Rectangle[] dA, MOTION procrs, DETECTIONTYPE dtctr, DETECTIONSPEED spd, DETECTIONSENSITIVITY sens) { this.detectionArea = dA; this.detectionMethod = procrs; this.detecionSpeed = spd; this.detectionSensitivity = sens; this.detectionType = dtctr; createMotionDetector(); }
/// <summary> /// 本インスタンスからセットエクスプレッションを呼ぶための目セッド /// </summary> /// <param name="ExpressionCode"></param> public void SetExpressionLocal(MOTION ExpressionCode) { GameObject obj = new GameObject(); // コルーチン実行用オブジェクト作成 obj.name = "GlobalCoroutine"; GlobalCoroutine component = obj.AddComponent <GlobalCoroutine>(); if (component != null) { component.StartCoroutine(SetExpression(ExpressionCode)); } }
/// <summary> /// モーションをランダムに再生する /// </summary> /// <param name="MotionCode"></param> public void StartRandomMotion(MOTION MotionCode) { try { string motionName = GetMotionNameTargetMotionRndam(MotionCode); if (motionName == null) { return; } //Animator.Stop(); Animator.Play(motionName); } catch (Exception ex) { Debug.Log(ex); } }
/// <summary> /// /// </summary> /// <param name="MotionCode"></param> /// <returns></returns> private string GetExpressionNameTargetMotionRndam(MOTION MotionCode) { //対照勘定のリストを取得 List <string> motionList = TableExpression[(int)MotionCode]; if (motionList.Count != 0) { //取得したリストのカウント値から、ランダムでインデクス生成 int targetIdx = UnityEngine.Random.Range(0, motionList.Count); //選択されたモーション名を返す return(motionList[targetIdx]); } else { //設定モーションが無い場合はノーマルを返す return(TableExpression[(int)MOTION.MOTION_NORMAL][0]); } }
//==================================================================== // // モーションテーブル操作 // //==================================================================== #region モーションテーブル操作 /// <summary> /// モーションコードに指定されたモーションに紐づくモーション名を返す。 /// 複数件登録されている場合はランダムで返す。 /// </summary> /// <param name="MotionCode"></param> /// <returns></returns> private string GetMotionNameTargetMotionRndam(MOTION MotionCode) { try { //キーチェック if (!TableMotion.ContainsKey((int)MotionCode)) { Debug.Log("GetMotionNameTargetMotionRndam 存在なし:" + MotionCode); //存在しなければNULLを返す return(null); } //対照感情のリストを取得 List <string> motionList = TableMotion[(int)MotionCode]; if (motionList.Count != 0) { //取得したリストのカウント値から、ランダムでインデクス生成 int targetIdx = UnityEngine.Random.Range(0, motionList.Count); //選択されたモーション名を返す return(motionList[targetIdx]); } else { //設定モーションが無い場合はNULLを返す return(null); } } catch { Debug.Log(MotionCode); return(null); } }
/// <summary> /// 本インスタンスからセットエクスプレッションを呼ぶための目セッド /// </summary> /// <param name="ExpressionCode"></param> public void SetExpressionLocal(MOTION ExpressionCode) { GlobalCoroutine.Go(SetExpression(ExpressionCode)); }
protected override void Moving() { this.neutlal = true; switch (this.state) { case MOTION.Absorbing: this.animationpoint = IdleAnimation(this.waittime); this.invincibility = false; this.invincibilitytime = 0; var totalDamage = this.controller.rawDamageTaken; if (totalDamage >= this.controller.totalHp) { this.state = MOTION.Breaking; this.Hp = 0; this.waittime = 0; } break; case MOTION.Breaking: var deathDelay = (this.deathOrder + 1) * 90; if (this.waittime >= deathDelay) { var fakeDeathPosition = new Vector2((int)this.positionDirect.X + this.Shake.X, (int)this.positionDirect.Y + this.Shake.Y); var fakeDeathRect = new Rectangle(this.animationpoint.X * this.wide, this.animationpoint.Y * this.height, this.wide, this.height); this.parent.effects.Add(new EnemyDeath(this.sound, this.parent, fakeDeathRect, new Rectangle(this.animationpoint.X * this.wide, 0, this.wide, this.height), fakeDeathPosition, this.picturename, this.rebirth, this.position)); this.animationpoint = new Point(this.Random.Next(1, 9 + 1), 1); this.waittime = 0; this.state = MOTION.Broken; } else { this.animationpoint = IdleAnimation(this.waittime); } break; case MOTION.Broken: if (this.waittime % 8 == 0) { var nextBrokenAnimX = ((this.animationpoint.X + 1) % 9) + 1; this.animationpoint = new Point(nextBrokenAnimX, 1); } if (this.controller == this) { if (this.controlledBarriers.All(c => c.state == MOTION.Broken)) { this.controlledBarriers.ForEach(c => { c.state = MOTION.RetaliatingChargeUp; c.waittime = 0; }); this.infoPanel.AllowedToBreak = true; this.infoPanel.Break(); var cancelledElements = this.damageBuildup.ToDictionary(kvp => kvp.Key, kvp => 0); foreach (var typeDamage in this.damageBuildup) { if (typeDamage.Key == ChipBase.ELEMENT.normal || typeDamage.Value <= 0) { continue; } var effectiveTypes = GetEffectiveElements(typeDamage.Key); if (effectiveTypes.All(t => this.damageBuildup[t] - cancelledElements[t] > 0)) { var cancelledElementTypes = effectiveTypes.ToList(); cancelledElementTypes.Add(typeDamage.Key); var cancelledAmount = cancelledElementTypes.Select(t => this.damageBuildup[t] - cancelledElements[t]).Min(); foreach (var cancelledElementType in cancelledElementTypes) { cancelledElements[cancelledElementType] += cancelledAmount; } } } foreach (var kvp in cancelledElements) { this.damageBuildup[kvp.Key] -= kvp.Value; } this.remainingRetaliation = this.damageBuildup.Sum(kvp => kvp.Value); this.isPerfectKill = this.remainingRetaliation == 0; } } break; case MOTION.RetaliatingChargeUp: this.animationpoint = new Point(1, 1); if (this.waittime < 360) { if (this.controller == this) { if (this.waittime > 180 && this.waittime <= 200) { this.sound.PlaySE(SoundEffect.beamlong); } if (this.waittime == 200) { this.sound.BGMFadeStart(90, 25); } if (this.waittime == 290) { this.sound.BGMFadeStart(50, 0); } if (this.waittime == 340) { this.sound.SetBGM("heavenbackground"); this.sound.BGMFadeStart(20, 100); } } if (this.waittime < 300) { var whiteoutProgress = 0.5 * (1 - Math.Cos((Math.Min(500, this.waittime * 1.5) / 500.0 / 2) * 2 * Math.PI)); this.overlayColor = Color.FromArgb((int)(whiteoutProgress * 255), Color.White); var dissolveProgress = Math.Min(200, this.waittime) / 200.0; switch (this.waittime % 3) { case 0: case 1: var initialPosition = new Point((int)this.positionDirect.X + 1, (int)this.positionDirect.Y - 2 + (int)(whiteoutProgress * 34) + this.Random.Next(1, 4)); var lifespan = 300; var t = 0; var randomPhaseShift = this.Random.NextDouble() * 2 * Math.PI; var outerRim = 4 * Math.Min(0.5, 1.0 / (1 + (400 - this.waittime) / 20.0)); var movement = new Action <Sparkle>(s => { t++; var xScale = Math.Min(outerRim, Math.Min(0.5, 1.0 / (1 + t / 20.0))); var x = 20 * xScale * Math.Cos(randomPhaseShift + (t / (400.0 / 5)) * 2 * Math.PI); var y = 20 * -0.0001 * t * t + 0.5 * Math.Sin(randomPhaseShift + (t / (400.0 / 5)) * 2 * Math.PI); s.Position = new Point(initialPosition.X + (int)Math.Round(x), initialPosition.Y + (int)Math.Round(y)); }); var newSparkle = new Sparkle { Lifespan = lifespan, RemainingLife = lifespan, Movement = movement }; movement.Invoke(newSparkle); this.sparkles[this.sparkles.FirstOrDefault(kvp => !this.sparkles.ContainsKey(kvp.Key + 1)).Key + 1] = newSparkle; break; } } else { var whiteoutProgress = (int)Math.Max(0, Math.Min(255, (this.waittime - 300) / 60.0 * 255)); this.overlayColor = Color.FromArgb(255 - whiteoutProgress, Color.White); this.alfha = (byte)(255 - whiteoutProgress); } if (this.controller == this) { if (this.waittime < 225) { var textStrobeTime = 45; if (this.waittime % textStrobeTime == 0) { this.textColor = (this.waittime / textStrobeTime) % 2 == 0 ? Color.Red : Color.Transparent; } } else { this.textColor = Color.Red; } // pre-mark panels for petals if (this.waittime > 200) { if (this.waittime % 8 == 0) { var untargetedPanels = Enumerable.Range(0, 6).SelectMany(c => Enumerable.Range(0, 3).Select(r => new Point(c, r))).Cast <Point?>() .Where(p => !this.parent.attacks.Any(ef => ef is Dummy && ef.position == p) && (!this.isPerfectKill || this.parent.panel[p.Value.X, p.Value.Y].color == this.union)); var untargetedOrRandomPanel = untargetedPanels.ElementAtOrDefault(this.Random.Next(0, untargetedPanels.Count())) ?? new Point(this.Random.Next(!this.isPerfectKill ? 0 : 3, 6), this.Random.Next(0, 3)); this.parent.attacks.Add(new Dummy(this.sound, this.parent, untargetedOrRandomPanel.X, untargetedOrRandomPanel.Y, this.union, new Point(0, 0), 120, true)); } } if (this.waittime == 300) { var petalBreeze = new PetalBreeze(this.sound, Vector2.Zero, Point.Empty); petalBreeze.upprint = true; this.parent.effects.Add(petalBreeze); var enemies = this.parent.AllChara().Where(c => c.union == this.UnionEnemy); foreach (var enemy in enemies) { enemy.barierTime = Math.Min(enemy.barierTime, 60); } } } } else { this.state = MOTION.Retaliating; this.waittime = 0; this.invincibility = true; this.invincibilitytime = Constants.ArbitraryLargeValue; } break; case MOTION.Retaliating: // Prevent fleeing after retaliation starts // this.parent.custom.escapeV = -ArbitraryLargeValue; this.animationpoint = new Point(1, 1); if (this.controller == this) { var retaliationTime = !this.isPerfectKill ? 1000 : 200; if (this.waittime < retaliationTime) { if (this.retaliateTickAction == null) { this.textColor = Color.Red; var fullDamagePerTick = (double)this.remainingRetaliation / retaliationTime; var damagePerTick = (int)fullDamagePerTick; var remainderPerTick = fullDamagePerTick % 1.0; var leftoverDamage = 0.0; this.retaliateTickAction = () => { leftoverDamage += remainderPerTick; var leftoverRemainder = leftoverDamage % 1.0; var wholeLeftoverDamage = (int)(leftoverDamage - leftoverRemainder); leftoverDamage = leftoverRemainder; var damageThisTick = wholeLeftoverDamage + damagePerTick; this.remainingRetaliation -= damageThisTick; var enemies = this.parent.AllHitter().Where(c => c.union == this.UnionEnemy); foreach (var enemy in enemies) { enemy.Hp -= damageThisTick; } }; } this.retaliateTickAction.Invoke(); if (this.waittime % 120 == 0) { var petalBreeze = new PetalBreeze(this.sound, Vector2.Zero, Point.Empty); petalBreeze.upprint = (this.waittime / 120) % 2 == 0; this.parent.effects.Add(petalBreeze); } if (this.waittime % 4 == 0) { var untargetedPanels = Enumerable.Range(0, 6).SelectMany(c => Enumerable.Range(0, 3).Select(r => new Point(c, r))).Cast <Point?>() .Where(p => !this.parent.effects.Any(ef => ef is BadWater && ef.position == p) && (!this.isPerfectKill || this.parent.panel[p.Value.X, p.Value.Y].color == this.union)); var untargetedOrRandomPanel = untargetedPanels.ElementAtOrDefault(this.Random.Next(0, untargetedPanels.Count())) ?? new Point(this.Random.Next(!this.isPerfectKill ? 0 : 3, 6), this.Random.Next(0, 3)); this.parent.effects.Add(new BadWater(this.sound, this.parent, untargetedOrRandomPanel.X, untargetedOrRandomPanel.Y, 2, BadWater.TYPE.Pink)); } if (this.waittime < 1000 - 120) { if (this.waittime % 8 == 0) { var untargetedPanels = Enumerable.Range(0, 6).SelectMany(c => Enumerable.Range(0, 3).Select(r => new Point(c, r))).Cast <Point?>() .Where(p => !this.parent.attacks.Any(ef => ef is Dummy && ef.position == p) && (!this.isPerfectKill || this.parent.panel[p.Value.X, p.Value.Y].color == this.union)); var untargetedOrRandomPanel = untargetedPanels.ElementAtOrDefault(this.Random.Next(0, untargetedPanels.Count())) ?? new Point(this.Random.Next(!this.isPerfectKill ? 0 : 3, 6), this.Random.Next(0, 3)); this.parent.attacks.Add(new Dummy(this.sound, this.parent, untargetedOrRandomPanel.X, untargetedOrRandomPanel.Y, this.union, new Point(0, 0), 120, true)); } } } else if (this.waittime < retaliationTime + 300) { if (this.remainingRetaliation > 0) { var enemies = this.parent.AllChara().Where(c => c.union == this.UnionEnemy); foreach (var enemy in enemies) { enemy.Hp -= this.remainingRetaliation; } this.remainingRetaliation = 0; } // settle this.textColor = Color.Transparent; } else { if (this.controlledBarriers.All(c => c.state == MOTION.Retaliating)) { this.controlledBarriers.ForEach(c => { c.state = MOTION.Ended; c.waittime = 0; }); } } } break; case MOTION.Ended: this.animationpoint = new Point(1, 1); break; } if (this.controller == this) { var barriersSimulHit = this.unprocessedAttacks.Select(a => a.Item1).Concat(this.controlledBarriers.Where(b => b.blackoutBuildupInterrupted)); foreach (var attack in this.unprocessedAttacks) { var hitBarrier = attack.Item1; var hitElement = attack.Item2; var hitAmount = attack.Item3; foreach (var barrier in this.controlledBarriers) { var simulHit = barriersSimulHit.Contains(barrier); if (simulHit) { // do nothing } else { var damageBlob = new BarrierDamageBlob( this.sound, this.parent, hitBarrier.positionDirect, hitBarrier.position, barrier.positionDirect, () => { this.damageBuildup[hitElement] += hitAmount; }); damageBlob.upprint = true; this.parent.effects.Add(damageBlob); } } } this.unprocessedAttacks.Clear(); if (this.rawDamageTakenSinceLastUpdate > 0) { this.rawDamageTaken += this.rawDamageTakenSinceLastUpdate; this.rawDamageTakenSinceLastUpdate = 0; } var panels = Enumerable.Range(0, this.parent.panel.GetLength(0)) .SelectMany(px => Enumerable.Range(0, this.parent.panel.GetLength(1)).Select(py => new Point(px, py))); foreach (var panelPos in panels) { var panel = this.parent.panel[panelPos.X, panelPos.Y]; switch (panel.State) { case Panel.PANEL._sand: case Panel.PANEL._poison: case Panel.PANEL._burner: case Panel.PANEL._thunder: panel.State = Panel.PANEL._nomal; this.parent.effects.Add(new Smoke(this.sound, this.parent, panelPos.X, panelPos.Y, panel.Element)); break; case Panel.PANEL._break: if (this.controlledBarriers.Any(c => c.position == panelPos)) { panel.state = Panel.PANEL._crack; } break; case Panel.PANEL._grass: case Panel.PANEL._ice: case Panel.PANEL._crack: case Panel.PANEL._nomal: case Panel.PANEL._none: case Panel.PANEL._un: break; } } var forbiddenObjects = this.parent.AllObjects().Where(o => o is SuzuranWhite || o is BigSuzuran).Cast <ObjectBase>(); foreach (var forbiddenObject in forbiddenObjects) { forbiddenObject.Break(); this.parent.attacks.Add(new CrackThunder(this.sound, this.parent, forbiddenObject.position.X, forbiddenObject.position.Y, this.union, forbiddenObject.Hp, true)); } if (this.controlledBarriers.Any(c => c.state == MOTION.Absorbing || c.state == MOTION.Breaking || c.state == MOTION.Broken)) { var decrementedElements = new List <ChipBase.ELEMENT>(); foreach (var typeDamage in this.damageBuildup) { if (typeDamage.Key == ChipBase.ELEMENT.normal || typeDamage.Value - decrementedElements.Count(e => e == typeDamage.Key) <= 0) { continue; } var effectiveTypes = GetEffectiveElements(typeDamage.Key); if (effectiveTypes.All(t => this.damageBuildup[t] - decrementedElements.Count(e => e == t) > 0)) { decrementedElements.Add(typeDamage.Key); decrementedElements.AddRange(effectiveTypes); } } foreach (var decrementedElement in decrementedElements) { this.damageBuildup[decrementedElement]--; } this.damageBuildup[ChipBase.ELEMENT.normal] -= Math.Min(decrementedElements.Count, this.damageBuildup[ChipBase.ELEMENT.normal]); if (this.waittime % 2 == 0) { var xOffset = this.Random.Next(0, 50); var yOffset = this.Random.Next(0, 70 - xOffset); var noisePosition = new Vector2(250 - xOffset, -10 + yOffset); var noiseEffect = new Noise(this.sound, noisePosition, Point.Empty); noiseEffect.downprint = true; noiseEffect.blackOutObject = false; this.parent.effects.Insert(0, noiseEffect); } if (this.waittime % 40 == 0) { var xOffset = this.Random.Next(20, 50) + 10; var yOffset = 70 - xOffset; var shieldPosition = new Vector2(250 - xOffset, -10 + yOffset); var shieldEffect = new ReflShield(this.sound, shieldPosition, Point.Empty); shieldEffect.downprint = true; shieldEffect.blackOutObject = false; this.parent.effects.Add(shieldEffect); } if (this.waittime % 100 == 50 && this.Random.NextDouble() < 0.5) { var target = this.RandomPanel(this.UnionEnemy); var xOffset = this.Random.Next(0, 50); var yOffset = this.Random.Next(0, 70 - xOffset); var noisePower = 100; var noisePosition = new Vector2(260 - xOffset, -10 + yOffset); var yVel = -(float)this.Random.NextDouble() * Math.Max(0, noisePosition.Y) / 5; var breakthroughChance = 0.1 + (0.8 * this.rawDamageTaken / this.totalHp); this.parent.attacks.Add( new NoiseBreakout( this.sound, this.parent, target.X, target.Y, this.union, noisePower, 1, noisePosition, yVel, this.Random.NextDouble() >= breakthroughChance)); } } else if (this.controlledBarriers.Any(c => c.state == MOTION.RetaliatingChargeUp)) { var xOffset = this.Random.Next(0, 50); var yOffset = this.Random.Next(0, 70 - xOffset); var noisePosition = new Vector2(250 - xOffset, -10 + yOffset); var noiseExpansion = 1 + (200 - Math.Abs(200 - Math.Min(360, this.waittime))) / 30; var expansionPositions = new[] { noisePosition, new Vector2(220, 20), new Vector2(204, 6), new Vector2(210, 40), new Vector2(180, 18), new Vector2(170, 10), new Vector2(190, 30) }; if (this.waittime % 2 == 0) { for (var i = 0; i < noiseExpansion; i++) { if (i >= expansionPositions.Length) { break; } var newNoisePosition = new Vector2(expansionPositions[i].X + this.Random.Next(-10, 9), expansionPositions[i].Y + this.Random.Next(-10, 9)); var noiseEffect = new Noise(this.sound, newNoisePosition, Point.Empty); noiseEffect.downprint = true; noiseEffect.blackOutObject = false; this.parent.effects.Insert(0, noiseEffect); } } if (this.waittime > 50 && this.waittime < 200) { if (this.waittime % 45 == 0) { this.sound.PlaySE(SoundEffect.noise); } } else if (this.waittime > 200 && this.waittime < 400) { if (this.waittime % 30 == 0) { this.sound.PlaySE(SoundEffect.pikin); } } } } this.waittime++; this.UpdateSparkles(); this.MoveAftar(); }