public void CreateResourceBall(Player owner, City city, RBallType type) { RBall ball = new RBall(owner, city, type); resBalls.Add(ball); if (ResourceBallChanged != null) { ResourceBallChanged(this, new ResourceBallEventArg(true, ball)); } }
public override void UpdateInteract(Apoc3D.GameTime time) { if (state == State.Opened) { selectedIndex = -1; for (int i = 0; i < 3; i++) { Vector2 size = transformedItemBR[i] - transformedItemTL[i]; Rectangle rect = new Rectangle((int)transformedItemTL[i].X, (int)transformedItemTL[i].Y, (int)size.X + 1, (int)size.Y + 1); if (Control.IsInBounds(MouseInput.X, MouseInput.Y, ref rect)) { selectedIndex = i; } } if (MouseInput.IsMouseUpLeft) { if (selectedIndex != -1) { if (resBallItemSelectedCount[selectedIndex] != 0) { selectedBallType = resBallsItemType[selectedIndex]; if (resBallItemSelectedCount[selectedIndex] != resBallItemCount[selectedIndex]) { selectedCount = resBallItemSelectedCount[selectedIndex]; isCountedThrow = true; } isCancelled = false; } } Close(); } } else if (state == State.Opening) { if (MouseInput.IsMouseDownRight) { isOpeningClicked = true; } if (MouseInput.IsMouseUpRight && isOpeningClicked) { isAllSelected = true; isCancelled = false; Close(); } } }
public RBall(Player owner, City city, RBallType type) : base(owner) { this.Owner = owner; this.Type = type; switch (type) { case RBallType.Oil: { props.BaseMaxHealth = RulesTable.OilBallBaseHealth; props.MaxHealth = props.BaseMaxHealth * (city.Level / 10.0f + 1); props.Contribution = RulesTable.OilBallContribution; props.Heal = RulesTable.OilBallBaseHeal; props.Damage = RulesTable.OilBallBaseDamage; break; } case RBallType.Green: { props.BaseMaxHealth = RulesTable.GreenBallBaseHealth; props.MaxHealth = props.BaseMaxHealth * (city.Level / 10.0f + 1); props.Contribution = RulesTable.GreenBallContribution; props.Heal = RulesTable.GreenBallBaseHeal; props.Damage = RulesTable.GreenBallBaseDamage; break; } case RBallType.Disease: { props.BaseMaxHealth = RulesTable.DiseaseBallBaseHealth; props.MaxHealth = props.BaseMaxHealth * (city.Level / 10.0f + 1); props.Contribution = RulesTable.DiseaseBallContribution; props.Heal = RulesTable.DiseaseBallBaseHeal; props.Damage = RulesTable.DiseaseBallBaseDamage; props.HealthIncr = 0.0015f; break; } case RBallType.Health: { props.BaseMaxHealth = RulesTable.DiseaseBallBaseHealth; props.MaxHealth = props.BaseMaxHealth * (city.Level / 10.0f + 1); props.Contribution = RulesTable.HealthBallContribution; props.Heal = RulesTable.HealthBallBaseHeal; props.Damage = RulesTable.HealthBallBaseDamage; props.HealthIncr = 0.0015f; break; } case RBallType.Education: { props.BaseMaxHealth = RulesTable.EducationBallBaseHealth; props.MaxHealth = props.BaseMaxHealth * (city.Level / 10.0f + 1); props.Contribution = RulesTable.EducationBallContribution; props.Heal = RulesTable.EducationBallBaseHeal; props.Damage = RulesTable.EducationBallBaseDamage; break; } case RBallType.Volience: { props.BaseMaxHealth = RulesTable.VolienceBallBaseHealth; props.MaxHealth = props.BaseMaxHealth + city.Development * RulesTable.CityDevRBallHealthRate; props.Contribution = RulesTable.VolienceBallContribution; props.Heal = RulesTable.VolienceBallBaseHeal; props.Damage = RulesTable.VolienceBallBaseDamage; break; } } Health = props.MaxHealth; SetDockCity(city); currentRadius = NextRadius(); currentHeight = NextHeight(); refrenceLinSpeed = Randomizer.GetRandomSingle() * (MaxLinSpeed - MinLinSpeed) + MinLinSpeed; BoundingSphere.Radius = 15; }
private void RenderBallIcon(Sprite sprite) { if (selectCity != null && selectCity.Owner == player) { //Array.Sort(resBallsCount, BallRecordCompare); int left = 0; for (int i = 0; i < resBallsCount.Length; i++) { RBallType ballType = resBallsCount[i].Type; bool overrideDraw = selectCity.CanProduceProduction() ? (ballType == selectCity.GetProductionType()) : false; //resBallsCount[i].Type == selectCity.GetProductionType() switch (ballType) { case RBallType.Green: { if (resBallsCount[i].count != 0 || overrideDraw) { if (selectCity.CanProduceProduction() && selectCity.GetProductionType() == RBallType.Green) { if (selectCity.IsFull()) { sprite.Draw(statusMaxBalls, 651 + 69 * left, 723 - statusMaxBalls.Height, ColorValue.White); } else { int height = (int)(selectCity.GetProductionProgress() * statusProducePrgTex.Height); sprite.Draw(statusProducePrgTex, new Rectangle(651 + 69 * left, 723 - height, statusProducePrgTex.Width, height), new Rectangle(0, statusProducePrgTex.Height - height, statusProducePrgTex.Width, height), ColorValue.White); } } int x = 687 + 69 * left - greenBallTex.Width / 2; int y = 692 - greenBallTex.Height / 2; sprite.Draw(greenBallTex, x, y, ColorValue.White); Matrix trans = Matrix.Scaling(0.8f, 0.8f, 1) * Matrix.Translation(new Vector3(x + 45 - f8.MeasureString(resBallsCount[i].count.ToString()).Width, y + 18, 0)); sprite.SetTransform(trans); f8.DrawString(sprite, resBallsCount[i].count.ToString(), 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); left++; } } break; case RBallType.Education: { if (resBallsCount[i].count != 0 || overrideDraw) { if (selectCity.CanProduceProduction() && selectCity.GetProductionType() == RBallType.Education) { if (selectCity.IsFull()) { sprite.Draw(statusMaxBalls, 651 + 69 * left, 723 - statusMaxBalls.Height, ColorValue.White); } else { int height = (int)(selectCity.GetProductionProgress() * statusProducePrgTex.Height); sprite.Draw(statusProducePrgTex, new Rectangle(651 + 69 * left, 723 - height, statusProducePrgTex.Width, height), new Rectangle(0, statusProducePrgTex.Height - height, statusProducePrgTex.Width, height), ColorValue.White); } } int x = 687 + 69 * left - educationBallTex.Width / 2; int y = 692 - educationBallTex.Height / 2; sprite.Draw(educationBallTex, x, y, ColorValue.White); Matrix trans = Matrix.Scaling(0.8f, 0.8f, 1) * Matrix.Translation(new Vector3(x + 45 - f8.MeasureString(resBallsCount[i].count.ToString()).Width, y + 18, 0)); sprite.SetTransform(trans); f8.DrawString(sprite, resBallsCount[i].count.ToString(), 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); left++; } } break; case RBallType.Health: { if (resBallsCount[i].count != 0 || overrideDraw) { if (selectCity.CanProduceProduction() && selectCity.GetProductionType() == RBallType.Health) { if (selectCity.IsFull()) { sprite.Draw(statusMaxBalls, 651 + 69 * left, 723 - statusMaxBalls.Height, ColorValue.White); } else { int height = (int)(selectCity.GetProductionProgress() * statusProducePrgTex.Height); sprite.Draw(statusProducePrgTex, new Rectangle(651 + 69 * left, 723 - height, statusProducePrgTex.Width, height), new Rectangle(0, statusProducePrgTex.Height - height, statusProducePrgTex.Width, height), ColorValue.White); } } int x = 687 + 69 * left - healthBallTex.Width / 2; int y = 692 - healthBallTex.Height / 2; sprite.Draw(healthBallTex, x, y, ColorValue.White); Matrix trans = Matrix.Scaling(0.8f, 0.8f, 1) * Matrix.Translation(new Vector3(x + 45 - f8.MeasureString(resBallsCount[i].count.ToString()).Width, y + 18, 0)); sprite.SetTransform(trans); f8.DrawString(sprite, resBallsCount[i].count.ToString(), 0, 0, ColorValue.White); sprite.SetTransform(Matrix.Identity); left++; } } break; } } } }
private void StatisticRBall() { if (selectCity != null) { resBallsCount[0].count = 0; resBallsCount[1].count = 0; resBallsCount[2].count = 0; isExpBuffer = false; isHPBuffer = false; isDownShow = false; for (int i = 0; i < selectCity.NearbyOwnedBallCount; i++) { RBallType type = selectCity.GetNearbyOwnedBall(i).Type; if (type == RBallType.Green) { resBallsCount[0].count++; } if (type == RBallType.Education) { resBallsCount[1].count++; if (!selectCity.IsDevFull) { isExpBuffer = true; } } if (type == RBallType.Volience) { if (!selectCity.IsDevFull) { isExpBuffer = true; } } if (type == RBallType.Health) { resBallsCount[2].count++; if (!selectCity.IsMaxHealthFull || selectCity.HPRate < 1) { isHPBuffer = true; } } if (type == RBallType.Disease) { if (!selectCity.IsMaxHealthFull || selectCity.HPRate < 1) { isHPBuffer = true; } } } for (int i = 0; i < selectCity.NearbyEnemyBallCount; i++) { RBallType type = selectCity.GetNearbyEnemyBall(i).Type; if (type == RBallType.Education || type == RBallType.Volience) { isDownShow = true; break; } } } }
/// <summary> /// 人类直接命令发球 /// Throw a ball. Just call method when the player asks a city. /// </summary> /// <param name="target"></param> public bool Throw(City target, RBallType type) { //if (!CanHandleCommand()) //return false; for (int i = 0; i < throwQueue.Count; i++) { ThrowTask tt = throwQueue.GetElement(i); if (tt.isTypedThrow && tt.typeToThrow == type && tt.throwPath[tt.throwPath.Count - 1] == target) { return false; } } //CancelCurrentCommand(); //reThrowDelay = 0; //throwRgball = null; battleField.BallPathFinder.Reset(); BallPathFinderResult result = battleField.BallPathFinder.FindPath(this, target); if (result != null) { List<City> throwPath = new List<City>(result.NodeCount); for (int i = 0; i < result.NodeCount; i++) { throwPath.Add(result[i]); } //Quaternion targetRot = GetOrientation(result[0].Position); //RotateTo(targetRot, 0.5f); //SetRotationPurpose(CityRotationPurpose.Throw); ThrowTask tt; tt.isTypedThrow = true; tt.throwPath = throwPath; tt.throwCount = 0; tt.isCountedThrow = false; tt.typeToThrow = type; throwQueue.Enqueue(tt); return true; } return false; }