private void ResolveMove(Pos p1to, Pos p2to) { bool p1Move = p1to != Player1.Gradiator.Position; bool p2Move = p2to != Player2.Gradiator.Position; if (p1Move && p2Move) { // 両方移動するとき // 移動先が同じまたはp1の移動先がp2の位置かつp2の移動先がp1の位置(交差)ならば衝突としてマーク bool isCollide = p1to == p2to || (p1to == Player2.Gradiator.Position && p2to == Player1.Gradiator.Position); // モデル更新 if (!isCollide) { // p1が外に移動しようとするかつp2がp1の位置に移動しようとする→押し出し if (!p1to.IsInboundBoard() && p2to == Player1.Gradiator.Position) { Player1.Life.DealDamage(1); } else if (!p2to.IsInboundBoard() && p1to == Player2.Gradiator.Position) { Player2.Life.DealDamage(1); } else { // 衝突しないとき if (!p1to.IsInboundBoard()) { Player1.Life.DealDamage(1); } else { Player1.Gradiator.Position = p1to; } // 衝突しないとき if (!p2to.IsInboundBoard()) { Player2.Life.DealDamage(1); } else { Player2.Gradiator.Position = p2to; } } } } else if (p1Move) { // p1のみ移動するとき if (p1to == p2to) // P2を押し込む場合 { RelativePos relative = new RelativePos(p1to.X - Player1.Gradiator.Position.X, p1to.Y - Player1.Gradiator.Position.Y); if (new Pos(Player2.Gradiator.Position.X + relative.X, Player2.Gradiator.Position.Y + relative.Y).IsInboundBoard()) // 押し込み可能 // モデル更新 { Player1.Gradiator.Position = p1to; Player2.Gradiator.Position = new Pos(Player2.Gradiator.Position.X + relative.X, Player2.Gradiator.Position.Y + relative.Y); } else // 後が無い // モデル更新 { Player2.Life.DealDamage(1); } } else // 通常移動 // モデル更新 { if (p1to.IsInboundBoard()) { Player1.Gradiator.Position = p1to; } else { Player1.Life.DealDamage(1); } } } else if (p2Move) { // p2のみ移動するとき if (p1to == p2to) // P1を押し込む場合 { RelativePos relative = new RelativePos(p2to.X - Player2.Gradiator.Position.X, p2to.Y - Player2.Gradiator.Position.Y); if (new Pos(Player1.Gradiator.Position.X + relative.X, Player1.Gradiator.Position.Y + relative.Y).IsInboundBoard()) // 押し込み可能 // モデル更新 { Player2.Gradiator.Position = p2to; Player1.Gradiator.Position = new Pos(Player1.Gradiator.Position.X + relative.X, Player1.Gradiator.Position.Y + relative.Y); } else // 後が無い // モデル更新 { Player1.Life.DealDamage(1); } } else // 通常移動 // モデル更新 { if (p2to.IsInboundBoard()) { Player2.Gradiator.Position = p2to; } else { Player2.Life.DealDamage(1); } } } }
private void ResolveMoveAnim(Pos p1to, Pos p2to) { bool p1Move = p1to != Player1.Gradiator.Position; bool p2Move = p2to != Player2.Gradiator.Position; if (p1Move && p2Move) { // 両方移動するとき // 移動先が同じまたはp1の移動先がp2の位置かつp2の移動先がp1の位置(交差)ならば衝突としてマーク bool isCollide = p1to == p2to || (p1to == Player2.Gradiator.Position && p2to == Player1.Gradiator.Position); if (!isCollide) { // p1が外に移動しようとするかつp2がp1の位置に移動しようとする→押し出し if (!p1to.IsInboundBoard() && p2to == Player1.Gradiator.Position) { // 衝突アニメーション P1MoveFailAnimation = true; P2MoveFailAnimation = true; P1MoveTo = p1to; P2MoveTo = p2to; DamageParams.Add(new DamageEffectParam { Pos = Player1.Gradiator.Position, Value = 1 }); } else if (!p2to.IsInboundBoard() && p1to == Player2.Gradiator.Position) { // 衝突アニメーション P1MoveFailAnimation = true; P2MoveFailAnimation = true; P1MoveTo = p1to; P2MoveTo = p2to; DamageParams.Add(new DamageEffectParam { Pos = Player2.Gradiator.Position, Value = 1 }); } else { // 衝突しないとき if (!p1to.IsInboundBoard()) { P1MoveFailAnimation = true; P1MoveTo = p1to; DamageParams.Add(new DamageEffectParam { Pos = Player1.Gradiator.Position, Value = 1 }); } else { P1MoveAnimation = true; P1MoveTo = p1to; } // 衝突しないとき if (!p2to.IsInboundBoard()) { P2MoveFailAnimation = true; P2MoveTo = p2to; DamageParams.Add(new DamageEffectParam { Pos = Player2.Gradiator.Position, Value = 1 }); } else { P2MoveAnimation = true; P2MoveTo = p2to; } } } else { // 衝突アニメーション P1MoveFailAnimation = true; P2MoveFailAnimation = true; P1MoveTo = p1to; P2MoveTo = p2to; } } else if (p1Move) { // p1のみ移動するとき if (p1to == p2to) // P2を押し込む場合 { RelativePos relative = new RelativePos(p1to.X - Player1.Gradiator.Position.X, p1to.Y - Player1.Gradiator.Position.Y); if (new Pos(Player2.Gradiator.Position.X + relative.X, Player2.Gradiator.Position.Y + relative.Y).IsInboundBoard()) // 押し込み可能 // アニメーション { P1MoveAnimation = true; P2MoveAnimation = true; P1MoveTo = p1to; P2MoveTo = new Pos(Player2.Gradiator.Position.X + relative.X, Player2.Gradiator.Position.Y + relative.Y); } else // 後が無い // アニメーション { P1MoveFailAnimation = true; P2MoveFailAnimation = true; P1MoveTo = p1to; P2MoveTo = new Pos(Player2.Gradiator.Position.X + relative.X, Player2.Gradiator.Position.Y + relative.Y); DamageParams.Add(new DamageEffectParam { Pos = Player2.Gradiator.Position, Value = 1 }); } } else // 通常移動 // アニメーション { if (p1to.IsInboundBoard()) { P1MoveAnimation = true; P1MoveTo = p1to; } else { P1MoveFailAnimation = true; P1MoveTo = p1to; DamageParams.Add(new DamageEffectParam { Pos = Player1.Gradiator.Position, Value = 1 }); } } } else if (p2Move) { // p2のみ移動するとき if (p1to == p2to) // P1を押し込む場合 { RelativePos relative = new RelativePos(p2to.X - Player2.Gradiator.Position.X, p2to.Y - Player2.Gradiator.Position.Y); if (new Pos(Player1.Gradiator.Position.X + relative.X, Player1.Gradiator.Position.Y + relative.Y).IsInboundBoard()) // 押し込み可能 // アニメーション { P1MoveAnimation = true; P2MoveAnimation = true; P2MoveTo = p2to; P1MoveTo = new Pos(Player1.Gradiator.Position.X + relative.X, Player1.Gradiator.Position.Y + relative.Y); } else // 後が無い // アニメーション { P1MoveFailAnimation = true; P2MoveFailAnimation = true; P2MoveTo = p2to; P1MoveTo = new Pos(Player1.Gradiator.Position.X + relative.X, Player1.Gradiator.Position.Y + relative.Y); DamageParams.Add(new DamageEffectParam { Pos = Player1.Gradiator.Position, Value = 1 }); } } else // 通常移動 // アニメーション { if (p2to.IsInboundBoard()) { P2MoveAnimation = true; P2MoveTo = p2to; } else { P2MoveFailAnimation = true; P2MoveTo = p2to; DamageParams.Add(new DamageEffectParam { Pos = Player2.Gradiator.Position, Value = 1 }); } } } }