bool FacingAndTouchingWall() { if (_anim.Facing == 0) { return(false); } //if not pushing into wall via input or velocity, dont walljump if (!(PMath.GetSign(VirtualController.GetAxisHorizontal()) == _anim.Facing) && !(PMath.GetSign(_rigidbody.velocity.x) == _anim.Facing)) { return(false); } Vector3 dir = new Vector3(_anim.Facing, 0); RaycastHit r; Vector3 origin = transform.position; float spd = 0.55f; int gMask = Layers.GetGroundMask(true); if (Physics.Raycast(origin + new Vector3(0, 0.8f, 0), dir, out r, spd, gMask) || Physics.Raycast(origin + new Vector3(0, 0.5f, 0), dir, out r, spd, gMask) || Physics.Raycast(origin + new Vector3(0, 0.2f, 0), dir, out r, spd, gMask) || Physics.Raycast(origin + new Vector3(0, -0.15f, 0), dir, out r, spd, gMask) || Physics.Raycast(origin + new Vector3(0, -0.45f, 0), dir, out r, spd, gMask)) { return(true); } else { return(false); } }
/// <summary> /// 用于交给队友有价值的牌和弃置敌人的高价值牌 /// </summary> /// <param name="Game"></param> /// <param name="Player"></param> /// <param name="TargetPlayer"></param> /// <param name="AllowHandCards"></param> /// <param name="AllowEquipment"></param> /// <param name="AllowAmbush"></param> /// <param name="CanSee"></param> /// <returns></returns> public static KeyValuePair <PCard, int> FindMostValuable(PGame Game, PPlayer Player, PPlayer TargetPlayer, bool AllowHandCards = true, bool AllowEquipment = true, bool AllowAmbush = false, bool CanSee = false) { int Cof = Player.TeamIndex == TargetPlayer.TeamIndex ? 1 : -1; KeyValuePair <PCard, int> HandCardResult = AllowHandCards ? PMath.Max(TargetPlayer.Area.HandCardArea.CardList, (PCard Card) => { if (CanSee) { return(Card.Model.AIInHandExpectation(Game, Player)); } else { return(2000 + PMath.RandInt(-10, 10)); } }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> EquipResult = AllowEquipment ? PMath.Max(TargetPlayer.Area.EquipmentCardArea.CardList, (PCard Card) => { return(Card.Model.AIInEquipExpectation(Game, TargetPlayer) + (TargetPlayer.General is P_HuaMulan ? 3500 * Cof : 0)); }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> AmbushResult = AllowAmbush ? PMath.Max(TargetPlayer.Area.AmbushCardArea.CardList, (PCard Card) => { return(Card.Model.AIInAmbushExpectation(Game, TargetPlayer)); }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> Temp = HandCardResult.Value >= EquipResult.Value ? HandCardResult : EquipResult; Temp = Temp.Value >= AmbushResult.Value ? Temp : AmbushResult; if (Temp.Key == null) { return(new KeyValuePair <PCard, int>(null, 0)); } return(Temp); }
public static KeyValuePair <PCard, int> FindMostValuableToGet(PGame Game, PPlayer Player, PPlayer TargetPlayer, bool AllowHandCards = true, bool AllowEquipment = true, bool AllowAmbush = false, bool CanSee = false) { int Cof = Player.TeamIndex == TargetPlayer.TeamIndex ? -1 : 1; int YangToowCof = TargetPlayer.Traffic != null && TargetPlayer.Traffic.Model is P_HsiYooYangToow && !Player.Age.Equals(TargetPlayer.Age) ? 0 : 1; KeyValuePair <PCard, int> HandCardResult = AllowHandCards ? PMath.Max(TargetPlayer.Area.HandCardArea.CardList, (PCard Card) => { if (CanSee) { return(Card.Model.AIInHandExpectation(Game, Player) * YangToowCof + Cof * Card.Model.AIInHandExpectation(Game, TargetPlayer)); } else { return(Cof < 0 ? 0 : 2000 * YangToowCof + 2000 * Cof + PMath.RandInt(0, 10)); } }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> EquipResult = AllowEquipment ? PMath.Max(TargetPlayer.Area.EquipmentCardArea.CardList, (PCard Card) => { return(Card.Model.AIInHandExpectation(Game, Player) + Cof * Card.Model.AIInEquipExpectation(Game, TargetPlayer) - (TargetPlayer.General is P_HuaMulan ? 3500 * Cof : 0)); }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> AmbushResult = AllowAmbush ? PMath.Max(TargetPlayer.Area.AmbushCardArea.CardList, (PCard Card) => { return(Card.Model.AIInHandExpectation(Game, Player) + Cof * Card.Model.AIInAmbushExpectation(Game, TargetPlayer)); }) : new KeyValuePair <PCard, int>(null, int.MinValue); KeyValuePair <PCard, int> Temp = HandCardResult.Value >= EquipResult.Value ? HandCardResult : EquipResult; Temp = Temp.Value >= AmbushResult.Value ? Temp : AmbushResult; if (Temp.Key == null) { return(new KeyValuePair <PCard, int>(null, 0)); } return(Temp); }
public float Hover(Vector3 PickRayOrigin, Vector3 PickRayDirection) { Vector3 intersect_pt = new Vector3(); bool bIntersected = false; float proximity = -1; switch (m_Mode) { case ArcMode.Pitch: bIntersected = PMath.RayIntersectPlane(PickRayOrigin, PickRayDirection, new Plane(1, 0, 0, 0), out intersect_pt); break; case ArcMode.Roll: bIntersected = PMath.RayIntersectPlane(PickRayOrigin, PickRayDirection, new Plane(0, 1, 0, 0), out intersect_pt); break; case ArcMode.Yaw: bIntersected = PMath.RayIntersectPlane(PickRayOrigin, PickRayDirection, new Plane(0, 0, 1, 0), out intersect_pt); break; } if (bIntersected) { proximity = (float)Math.Abs(RadiusScale - intersect_pt.Length()); } return(proximity); }
/// <summary> /// 牌堆里的牌(未进入弃牌堆或可见区域)的平均收益 /// </summary> /// <param name="Game"></param> /// <param name="Player"></param> /// <returns></returns> public static int Expect(PGame Game, PPlayer Player) { double SingleExpect(PCard Card) { int Base = Card.Model.AIInHandExpectation(Game, Player); return(Base); } double Sum = PMath.Sum(Game.CardManager.CardHeap.CardList.ConvertAll(SingleExpect)); int Count = Game.CardManager.CardHeap.CardNumber; if (Count <= 10) { Sum += PMath.Sum(Game.CardManager.ThrownCardHeap.CardList.ConvertAll(SingleExpect)); Count += Game.CardManager.ThrownCardHeap.CardNumber; } if (Count == 0) { return(0); } else { return((int)Sum / Count); } }
public P_PaiHuaChooon() : base(CardName, PCardType.DefensorCard) { Point = 2; Index = 50; foreach (PTime Time in new PTime[] { PTime.Injure.AcceptInjure }) { MoveInEquipTriggerList.Add((PPlayer Player, PCard Card) => { return(new PTrigger(CardName) { IsLocked = false, Player = Player, Time = Time, AIPriority = 150, Condition = (PGame Game) => { PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); return Player.Equals(InjureTag.ToPlayer) && InjureTag.Injure > 0 && InjureTag.FromPlayer != null && !InjureTag.FromPlayer.Sex.Equals(Player.Sex); }, AICondition = (PGame Game) => { PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); return InjureTag.Injure > 500; }, Effect = (PGame Game ) => { AnnouceUseEquipmentSkill(Player); PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); InjureTag.Injure = PMath.Percent(InjureTag.Injure, 50); } }); }); } }
public P_ChiaChiihPuTien() : base(CardName) { Point = 5; Index = 27; foreach (PTime Time in new PTime[] { PPeriod.FirstFreeTime.During, PPeriod.SecondFreeTime.During }) { MoveInHandTriggerList.Add((PPlayer Player, PCard Card) => { return(new PTrigger(CardName) { IsLocked = false, Player = Player, Time = Time, AIPriority = 10, Condition = (PGame Game) => { int MinMoney = PMath.Min(Game.PlayerList.FindAll((PPlayer _Player) => _Player.IsAlive), (PPlayer _Player) => _Player.Money).Value; return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime()) && Player.Money == MinMoney; }, AICondition = (PGame Game) => { return PAiMapAnalyzer.OutOfGameExpect(Game, Player, true) > 0 && Game.NowPeriod.Equals(PPeriod.FirstFreeTime.During); }, Effect = MakeNormalEffect(Player, Card, AIEmitTargets, AIEmitTargets, (PGame Game, PPlayer User, PPlayer Target) => { Target.Tags.CreateTag(PTag.OutOfGameTag); }) }); }); } }
public P_BaiQi() : base("白起") { Sex = PSex.Male; Age = PAge.Classic; Index = 9; Cost = 25; Tips = "定位:爆发\n" + "难度:简单\n" + "史实:战国时期秦国名将,“战国四大名将”之一,曾在伊阙之战、长平之战中大败三晋军队,歼敌数十万,功封武安君。\n" + "攻略:\n白起是一个强制命中系武将,白起的存在使得对方无法通过【李代桃僵】、【指桑骂槐】一类的牌免除伤害,或通过【八卦阵】、【龙胆】等方式减少伤害,而必须硬吃下伤害的100%(通常这个数字比伤害值高)。随之带来的损失则是收费地的地价永久性减少,很多时候这是不值的,但在必杀一击上,白起一点都不会含糊。"; PSkill CanSha = new PSkill("残杀"); SkillList.Add(CanSha .AddTrigger( (PPlayer Player, PSkill Skill) => { return(new PTrigger(CanSha.Name) { IsLocked = false, Player = Player, Time = PTime.Injure.EmitInjure, AIPriority = 100, Condition = (PGame Game) => { PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); return InjureTag.Injure > 0 && InjureTag.ToPlayer != null && Player.Equals(InjureTag.FromPlayer) && InjureTag.InjureSource is PBlock && ((PBlock)InjureTag.InjureSource).Price >= 1000; }, AICondition = (PGame Game) => { PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); if (InjureTag.ToPlayer.TeamIndex != Player.TeamIndex) { int Benefit = PMath.Percent(InjureTag.Injure, 100); if (Benefit + InjureTag.Injure >= InjureTag.ToPlayer.Money) { // 一击必杀 return true; } if (Benefit >= 2000) { PBlock Source = (PBlock)InjureTag.InjureSource; int Cost = 1000 + PAiMapAnalyzer.HouseValue(Game, Player, Source) * Source.HouseNumber * 1000 / Source.Price; if (Cost < Benefit) { return true; } } } return false; }, Effect = (PGame Game) => { CanSha.AnnouceUseSkill(Player); PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); PBlock Source = (PBlock)InjureTag.InjureSource; Source.Price -= 1000; PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(Source)); Game.LoseMoney(InjureTag.ToPlayer, PMath.Percent(InjureTag.Injure, 100)); } }); })); }
private List <PGeneral> GenerateGenerals(string Config) { string[] Parts = CodeInputField.text.Split(';'); bool Random = Parts[Parts.Length - 2].Equals("Random"); List <PGeneral> GeneralList = new List <PGeneral>(); for (int i = 0; i < PSystem.CurrentMode.PlayerNumber; ++i) { if (i >= Parts.Length - 2) { GeneralList.Add(new P_Soldier()); } else { PGeneral General = ListSubTypeInstances <PGeneral>().Find((PGeneral _General) => _General.Name.Equals(Parts[i])); if (General != null) { GeneralList.Add(General); } else { GeneralList.Add(new P_Soldier()); } } } if (Random) { PMath.Wash(GeneralList); } return(GeneralList); }
public void Setup() { ArrWidth = (Width / Rez) + 1; ArrHeight = (Height / Rez) + 1; Map = new float[ArrWidth, ArrHeight]; for (var y = 0; y < ArrHeight; y++) { for (var x = 0; x < ArrWidth; x++) { //Map[x, y] = (float)r.NextDouble(); Map[x, y] = PMath.Clamp(noise.GetPerlin(x * PMath.PI, y * PMath.PI, z) + 0.5f, 0, 1); } } AddKeyAction("W", (d) => { if (!d) { return; } Thresh *= 1.05f; Thresh = PMath.Clamp(Thresh, 0, 1); }); AddKeyAction("S", (d) => { if (!d) { return; } Thresh *= 0.95f; Thresh = PMath.Clamp(Thresh, 0, 1); }); }
public void Sum_ReturnsSumOfArray() { // prerequisite Approx_Works(); // arrange int[] iArr = new int[] { 0, 1, 2, 3 }; float[] fArr = new float[] { 0.1f, 1.1f, 2.1f, 3.1f }; List <float> fList = new List <float>() { 0.1f, 1.1f, 2.1f, 3.1f }; List <int> iList = new List <int>() { 0, 1, 2, 3 }; // act int iaTotal = iArr.Sum(); float faTotal = fArr.Sum(); float flTotal = fList.Sum(); int ilTotal = iList.Sum(); // assert Assert.IsTrue(PMath.Approx(6, iaTotal)); Assert.IsTrue(PMath.Approx(6.4f, faTotal)); Assert.IsTrue(PMath.Approx(6.4f, flTotal)); Assert.IsTrue(PMath.Approx(6, ilTotal)); }
public void GravitationalAcceleration_DoubleDataReturnsCorrectValue() { // prereq Approx_Works(); Scientific_Works(); // arrange // Earth radius (meters) 6.371 x 10^6 double distance = PMath.Scientific(6.371, 6); // kg double massA = 68; // Earth mass (kg) 5.97237f x 10^24 double massB = PMath.Scientific(5.97237, 24); // m/s/s double expected = 9.80665d; // act double gravity = PMath.GravitationalAcceleration(massA, massB, distance); // assert Assert.AreEqual(expected, gravity, "Gravitational Force: {0} != {1}", expected, gravity); }
public void EscapeVelocity_ReturnsCorrectValue() { // prereq Approx_Works(); Scientific_Works(); GravitationalAcceleration_FloatDataReturnsCorrectValue(); // arrange // mean Earth radius (km => meters) float distance = (float)PMath.Scientific(6.371, 6); // typical person mass (kg) float personMass = 70; // Earth mass (kg) // Ref: https://en.wikipedia.org/wiki/Earth_mass double earthMass = PMath.Scientific(5.97237, 24); // force is m/s/s float force = PMath.GravitationalAcceleration(personMass, (float)earthMass, distance); // escape velocity on earth is 11.2 km/s (km/s => m/s) float expected = 11.2f * 1000; // act (m/s) double velocity = PMath.EscapeVelocity(force, distance); // assert Assert.IsTrue(PMath.Approx(expected, (float)velocity, 1), "Escape Velocity: expected " + expected + " m/s != actual " + velocity + " m/s"); }
public void GetOffscreenEndpoint_ReturnsEndpoint() { // prereq GetEndpointAtDistance_ReturnsEndpoint(); UtilTest.UtilTest util = new UtilTest.UtilTest(); util.IsOnScreen_ReturnsCorrectly(); // clean up TestHelper.ResetAllCameras(); // arrange GameObject gameObject = new GameObject(); gameObject.AddComponent(typeof(Camera)); Camera cam = gameObject.GetComponent <Camera>(); cam.transform.position = Vector3.back * 10; cam.transform.forward = Vector3.forward; // act Vector3 endpointImplied = PMath.GetOffscreenEndpoint(Vector3.zero, Vector3.right); Vector3 endpointExplicit = PMath.GetOffscreenEndpoint(Vector3.zero, Vector3.right, cam); // assert bool onScreenImp = PLib.General.PUtil.IsOnScreen(endpointImplied, cam); bool onScreenExp = PLib.General.PUtil.IsOnScreen(endpointExplicit, cam); Assert.IsFalse(onScreenImp, "endpoint: " + endpointImplied.ToString()); Assert.IsFalse(onScreenExp, "endpoint: " + endpointExplicit.ToString()); }
public void VelocityOfReach_ReturnsCorrectValue() { // prereq Approx_Works(); AngleOfReach_ReturnsCorrectAngles(); // arrange float expectedSpeed = 30; float targetHeight = -20; float distance = 90; // angles (confirmed correct) float lowAngleDeg = 17.63152f; float highAngleDeg = 59.83967f; float lowAngleRad = lowAngleDeg * Mathf.Deg2Rad; float highAngleRad = highAngleDeg * Mathf.Deg2Rad; // act float lowAngleSpeed = PMath.VelocityOfReach(lowAngleRad, distance, targetHeight); float highAngleSpeed = PMath.VelocityOfReach(highAngleRad, distance, targetHeight); // assert string message = "low angle / speed: {0} / {1}, high angle / speed: {2} / {3}"; string output = string.Format(message, lowAngleDeg, lowAngleSpeed, highAngleDeg, highAngleSpeed); Debug.Log(output); Assert.IsTrue(PMath.Approx(expectedSpeed, lowAngleSpeed, 1), "low angle: " + TestHelper.ShowVariables(expectedSpeed, lowAngleSpeed)); Assert.IsTrue(PMath.Approx(expectedSpeed, highAngleSpeed, 1), TestHelper.ShowVariable("high angle: ", highAngleSpeed)); }
public NoiseLoop(float d, float min, float max) { Diameter = d; Min = min; Max = max; CenterX = PMath.Random(1000); CenterY = PMath.Random(1000); }
public List<PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { PPlayer Target = PMath.Max(Game.Enemies(Player).FindAll((PPlayer _Player) => _Player.HasHouse && (_Player.Defensor == null || !(_Player.Defensor.Model is P_ChiiHsingPaao)) && !_Player.Area.AmbushCardArea.CardList.Exists((PCard _Card) => _Card.Model.Name.Equals(CardName)) && !(_Player.General is P_LiuJi)), (PPlayer _Player) => PAiMapAnalyzer.MinValueHouse(Game, _Player).Value + PMath.RandInt(0, 10)).Key; return new List<PPlayer>() { Target}; }
public PCard RandomCard() { if (CardNumber < 1) { return(null); } return(CardList[PMath.RandInt(0, CardList.Count - 1)]); }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = Player.Area.HandCardArea.CardList.Exists((PCard Card) => Card.Type.IsEquipment()) ? 2000 : 0; int Test = 1000 * PMath.Max(Game.Enemies(Player), (PPlayer _Player) => _Player.Area.EquipmentCardArea.CardNumber).Value; Basic = Math.Max(Basic, Test); return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = PAiMapAnalyzer.MaxValueHouse(Game, Player).Value; Basic = Math.Max(1000, PMath.Max(Game.Enemies(Player), (PPlayer _Player) => { return(PAiMapAnalyzer.MaxValueHouse(Game, _Player).Value + Basic); }, true).Value); return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }
public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { return(new List <PPlayer>() { PMath.Max(Game.Enemies(Player), (PPlayer _Player) => { return -PAiMapAnalyzer.OutOfGameExpect(Game, _Player); }, true).Key }); }
// Update is called once per frame void Update() { if (dashPauseTimer > 0) { dashPauseTimer -= Time.deltaTime; _rigidbody.velocity = Vector3.zero; if (dashPauseTimer <= 0) { dashPauseTimer = 0; _anim.StopDashSlashAnim(); } return; } if (wallJumpLockTimer > 0) { wallJumpLockTimer -= Time.deltaTime; if (wallJumpLockTimer <= 0) { wallJumpLockTimer = 0; Vector3 v = _rigidbody.velocity; v.x *= 0.65f; v.y *= 0.75f; _rigidbody.velocity = v; } return; } isGrounded = Grounded(); _anim.SetGrounded(isGrounded); if (controlsLocked || hitstun) { return; } BasicMovement(); if (VirtualController.JumpButtonPressed()) { if (UnlockTable.PowerActive(UnlockID.Jump)) { Jump(); } } else if (!_anim.IsCrouching && VirtualController.ActionButtonPressed()) { if (VirtualController.GetAxisHorizontal() != 0 && UnlockTable.PowerActive(UnlockID.DashSlash)) { DashSlash(PMath.GetSign(VirtualController.GetAxisHorizontal())); } else if (UnlockTable.PowerActive(UnlockID.Slash)) { Slash(); } } if (isGrounded) { numAirJumps = maxAirJumps; } UpdateCoords(); }
/// <summary> /// 返回最低价值的房屋 /// </summary> /// <param name="Game"></param> /// <param name="Player">房屋所有者</param> /// <param name="StartFromZero">是否允许土地上实际没有房屋</param> /// <param name="Concentrate">是否优先选取房屋数量少的土地的房屋</param> /// <returns></returns> public static KeyValuePair <PBlock, int> MinValueHouse(PGame Game, PPlayer Player, bool StartFromZero = false, bool Concentrate = false) { KeyValuePair <PBlock, int> Test = PMath.Min(Game.Map.BlockList.FindAll((PBlock Block) => Player.Equals(Block.Lord) && (StartFromZero || Block.HouseNumber > 0)), (PBlock Block) => { return(HouseValue(Game, Player, Block) * 1000 + (Concentrate ? Block.HouseNumber : 0)); }); return(new KeyValuePair <PBlock, int>(Test.Key, Test.Value / 1000)); }
public void Hover(Vector3 origin, Vector3 dir) { switch (currentState) { case SelectionBoxState.FindPlane: if (PMath.RayIntersectPlane(origin, dir, intersectPlane, out startCorner)) { basePlane.D = startCorner.Z; } Trace.WriteLine(string.Format("findplane: {0} {1} {2}", startCorner.X, startCorner.Y, startCorner.Z)); UpdatePrimitives(); break; case SelectionBoxState.FindStartCorner: if (PMath.RayIntersectPlane(origin, dir, basePlane, out startCorner) == false) { startCorner.X = 0; startCorner.Y = 0; startCorner.Z = 0; } Trace.WriteLine(string.Format("start corner: {0} {1} {2}", startCorner.X, startCorner.Y, startCorner.Z)); UpdatePrimitives(); break; case SelectionBoxState.FindEndCorner: if (PMath.RayIntersectPlane(origin, dir, basePlane, out endCorner) == false) { endCorner.X = 0; endCorner.Y = 0; endCorner.Z = 0; } UpdateBox(startCorner, endCorner, 0.005f); boxOutline.min[0] = startCorner.X; boxOutline.min[1] = startCorner.Y; boxOutline.min[2] = startCorner.Z; boxOutline.max[0] = endCorner.X; boxOutline.max[1] = endCorner.Y; boxOutline.max[2] = endCorner.Z + 0.005f; break; case SelectionBoxState.FindHeight: Vector3 temp = new Vector3(); if (PMath.RayIntersectPlane(origin, dir, intersectPlane, out temp)) { boxHeight = temp.Z - startCorner.Z; } UpdateBox(startCorner, endCorner, boxHeight); boxOutline.min[0] = startCorner.X; boxOutline.min[1] = startCorner.Y; boxOutline.min[2] = startCorner.Z; boxOutline.max[0] = endCorner.X; boxOutline.max[1] = endCorner.Y; boxOutline.max[2] = endCorner.Z + boxHeight; break; } }
private KeyValuePair <PPlayer, int> FindTarget(PGame Game, PPlayer Player) { int Basic = PAiMapAnalyzer.MaxValueHouse(Game, Player).Value; return(PMath.Max(Game.Enemies(Player).FindAll((PPlayer _Player) => _Player.Area.EquipmentCardArea.CardNumber > 0), (PPlayer _Player) => { int HouseValue = _Player.HasHouse ? PAiMapAnalyzer.MaxValueHouse(Game, _Player).Value + Basic : 30000; int EquipValue = PMath.Max(_Player.Area.EquipmentCardArea.CardList, (PCard Card ) => Card.Model.AIInEquipExpectation(Game, _Player) + Card.Model.AIInHandExpectation(Game, Player)).Value; return Math.Min(HouseValue, EquipValue); }, true)); }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = 0; int OutOfGameExpect = PMath.Max(Game.Enemies(Player), (PPlayer _Player) => { return(-PAiMapAnalyzer.OutOfGameExpect(Game, _Player)); }, true).Value; Basic = Math.Max(Basic, OutOfGameExpect); return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }
public override int AIInHandExpectation(PGame Game, PPlayer Player) { int Basic = 2500; int Test = PMath.Max(Game.Map.BlockList.FindAll((PBlock Block) => Block.Lord != null && Block.Lord.TeamIndex == Player.TeamIndex), (PBlock Block) => { return(PAiMapAnalyzer.HouseValue(Game, Block.Lord, Block)); }).Value; Basic = Math.Max(Basic, Test); return(Math.Max(Basic, base.AIInHandExpectation(Game, Player))); }
/// <summary> /// Normalizes the highest component to a value of max, the /// lowest component to a value of min, adjusts the other /// values accordingly. No effect on alpha. /// Color (0.1, 0.8, 0.9) mapped as (0, 1) -> Color (0, 0.96, 1) /// Color (0.1, 0.8, 0.9) mapped as (0.4, 0.6) -> (0.42, 0.56, 0.58) /// </summary> public static Color Normalize(Color color, float min = 0, float max = 1.0f) { float maxRGB = color.Max(); float minRGB = color.Min(); color.r = PMath.Map(color.r, minRGB, maxRGB, min, max); color.g = PMath.Map(color.g, minRGB, maxRGB, min, max); color.b = PMath.Map(color.b, minRGB, maxRGB, min, max); return(color); }
public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player) { PPlayer Target1 = PMath.Min(Game.Enemies(Player).FindAll((PPlayer _Player) => !_Player.HasEquipment <P_YooHsi>() && !(_Player.General is P_LiuJi)), (PPlayer _Player) => _Player.Money).Key; PPlayer Target2 = PMath.Min(Game.Enemies(Player).FindAll((PPlayer _Player) => !_Player.Equals(Target1) && !_Player.HasEquipment <P_YooHsi>() && !(_Player.General is P_LiuJi)), (PPlayer _Player) => _Player.Money).Key; return(new List <PPlayer>() { Target1, Target2 }); }
public P_ToouShihChi() : base(CardName, PCardType.WeaponCard) { Point = 6; Index = 48; AnnouceOnce(CardName); foreach (PTime Time in new PTime[] { PPeriod.FirstFreeTime.During, PPeriod.SecondFreeTime.During }) { MoveInEquipTriggerList.Add((PPlayer Player, PCard Card) => { return(new PTrigger(CardName) { IsLocked = false, Player = Player, Time = Time, CanRepeat = true, Condition = (PGame Game) => { PUsedTag UsedTag = Player.Tags.FindPeekTag <PUsedTag>(PUsedTag.TagNamePrefix + CardName); if (UsedTag == null) { Player.Tags.CreateTag(UsedTag = new PUsedTag(CardName, 1)); } return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime()) && UsedTag != null && UsedTag.Count < UsedTag.Limit && Player.Money > 3000 && Game.Map.BlockList.Exists((PBlock Block ) => Block.HouseNumber > 0); }, AICondition = (PGame Game) => { return Game.Map.BlockList.Exists((PBlock Block) => Block.Lord != null && Block.Lord.TeamIndex != Player.TeamIndex && Block.HouseNumber > 1 && Block.BusinessType.Equals(PBusinessType.Castle)) && Player.Money >= 6000; }, Effect = (PGame Game) => { AnnouceUseEquipmentSkill(Player); PBlock TargetBlock = null; if (Player.IsAI) { TargetBlock = PMath.Max(Game.Map.BlockList.FindAll((PBlock Block) => Block.Lord != null && Block.Lord.TeamIndex != Player.TeamIndex && Block.BusinessType.Equals(PBusinessType.Castle)), (PBlock Block) => Block.HouseNumber).Key; } else { TargetBlock = PNetworkManager.NetworkServer.ChooseManager.AskToChooseBlock(Player, CardName + "之目标", (PBlock Block) => Block.HouseNumber > 0); } if (TargetBlock != null) { Game.LoseMoney(Player, 3000); Game.LoseHouse(TargetBlock, 1); if (TargetBlock.BusinessType.Equals(PBusinessType.Castle)) { Game.LoseHouse(TargetBlock, Game.Judge(Player, 6)); } Player.Tags.FindPeekTag <PUsedTag>(PUsedTag.TagNamePrefix + CardName).Count++; } } }); }); } }