private int Camparision(NaturalResource a, NaturalResource b) { float da = Vector3.DistanceSquared(a.Position, this.Position); float db = Vector3.DistanceSquared(b.Position, this.Position); return(da.CompareTo(db)); }
private int CamparisionForest(NaturalResource a, NaturalResource b) { float da = Vector3.DistanceSquared(((ForestObject)a).ForestCenter, this.Position); float db = Vector3.DistanceSquared(((ForestObject)b).ForestCenter, this.Position); return(da.CompareTo(db)); }
public void Gather(NaturalResource res) { if (!IsCaptured) { return; } int nid = nearResource.IndexOf(res); if (nid == -1) { return; } resourceIndex = nid; NaturalResource exRes = ExResource; if (exRes != null) { harvester.Move(MathEx.Degree2Radian(exRes.Longitude), MathEx.Degree2Radian(exRes.Latitude)); harvester.SetMovePurpose(MovePurpose.Gather); } harvester.ExRes = exRes; }
void Harv_Home(object sender, EventArgs e) { if (!isGatherOnHold) { NaturalResource exRes = ExResource; if (IsCaptured && exRes != null) { harvester.Move(MathEx.Degree2Radian(exRes.Longitude), MathEx.Degree2Radian(exRes.Latitude)); harvester.SetMovePurpose(MovePurpose.Gather); } if (!harvester.IsFullLoaded && sender == harvester) { FindNewNaturalResource(); } harvester.ExRes = exRes; } //harvSendWait = getHarvWaitTime(); }
public bool IsResourceInRange(NaturalResource res) { return nearResource.Contains(res); }
private int Camparision(NaturalResource a, NaturalResource b) { float da = Vector3.DistanceSquared(a.Position, this.Position); float db = Vector3.DistanceSquared(b.Position, this.Position); return da.CompareTo(db); }
private int CamparisionForest(NaturalResource a, NaturalResource b) { float da = Vector3.DistanceSquared(((ForestObject)a).ForestCenter, this.Position); float db = Vector3.DistanceSquared(((ForestObject)b).ForestCenter, this.Position); return da.CompareTo(db); }
//public override void UpdateResource(GameTime gameTime) //{ // //开采资源 // //if (this.nearResource.Count > 0) // //{ // // float take = nearResource[resourceIndex].Exploit(10); // // if (take < 10) // // { // // FindNewNaturalResource(); // // } // // resourceBuffer += take; // //} // harvester.Update(gameTime); //} //public override bool CanProduceRBall() //{ // return this.resourceBuffer > RulesTable.RBallProduceBall; //} ////产生小球 //public override void ProduceBall() //{ // this.battleField.CreateResourceBall(this); // resourceBuffer -= RulesTable.RBallProduceBall; //} //周围资源资源 /// <summary> /// Finds the nearby resources /// </summary> /// <param name="resList"></param> public void FindResources(NaturalResource[] resList) { nearResource.Clear(); for (int i = 0; i < resList.Length; i++) { if (Type == CityType.Green) { if (resList[i].Type == NaturalResourceType.Wood) { ForestObject forest = (ForestObject)resList[i]; float d = Vector3.Distance(forest.ForestCenter, this.Position); if (d < gatherDistance) { nearResource.Add(resList[i]); } } } else if (Type == CityType.Oil) { if (resList[i].Type == NaturalResourceType.Oil) { float d = Vector3.Distance(resList[i].Position, this.Position); if (d < gatherDistance) { nearResource.Add(resList[i]); } } } } if (Type == CityType.Green) { nearResource.Sort(CamparisionForest); } else { nearResource.Sort(Camparision); } }
public void Gather(NaturalResource res) { if (!IsCaptured) return; int nid = nearResource.IndexOf(res); if (nid == -1) return; resourceIndex = nid; NaturalResource exRes = ExResource; if (exRes != null) { harvester.Move(MathEx.Degree2Radian(exRes.Longitude), MathEx.Degree2Radian(exRes.Latitude)); harvester.SetMovePurpose(MovePurpose.Gather); } harvester.ExRes = exRes; }
public bool IsResourceInRange(NaturalResource res) { return(nearResource.Contains(res)); }