//空き地に止まった public void stopFreeLand(PlayerStatus aTurnPlayer, Action aCallback) { LandMass tLand = (LandMass)mMaster.mFeild.mMassList[aTurnPlayer.mCurrentMassNumber]; //購入できない if (aTurnPlayer.mMoney < tLand.mPurchaseCost) { aCallback(); return; } //購入できる aTurnPlayer.mAi.purchaseLand(aTurnPlayer, tLand, mMaster, (aAns) => { if (!aAns) { aCallback(); return; } //購入する GameEffector.lostCoin(aTurnPlayer.mComa.position, (-tLand.mPurchaseCost).ToString(), () => { aTurnPlayer.mMoney -= tLand.mPurchaseCost; tLand.changeOrner(aTurnPlayer, () => { tLand.changeIncreaseLevel(tLand.mIncreaseLevel, () => { mMaster.updateStatus(); aCallback(); return; }); }); }); }); }
//自分の土地に止まった public void stopMyLand(PlayerStatus aTurnPlayer, Action aCallback) { LandMass tLand = (LandMass)mMaster.mFeild.mMassList[aTurnPlayer.mCurrentMassNumber]; //最大まで増資済み if (tLand.mIncreaseLevel >= LandMass.mMaxIncreaseLevel) { aCallback(); return; } //増資できない if (aTurnPlayer.mMoney < tLand.mIncreaseCost) { aCallback(); return; } //増資できる aTurnPlayer.mAi.increaseLand(aTurnPlayer, tLand, mMaster, (aAns) => { if (!aAns) { aCallback(); return; } //増資する GameEffector.lostCoin(aTurnPlayer.mComa.position, (-tLand.mIncreaseCost).ToString(), () => { aTurnPlayer.mMoney -= tLand.mIncreaseCost; tLand.changeIncreaseLevel(tLand.mIncreaseLevel + 1, () => { mMaster.updateStatus(); aCallback(); return; }); }); }); }
public override void soldLand(PlayerStatus aMyStatus, GameMaster mMaster, Action <LandMass> aCallback) { mMaster.mCamera.mTarget = null; Subject.addObserver(new Observer("playerAi", (aMessage) => { switch (aMessage.name) { case "gamePadDragged": Vector2 tVec = aMessage.getParameter <Vector2>("vector") / -10; mMaster.mCamera.move(tVec); break; case "gamePadClicked": GameMass tMass = aMessage.getParameter <GameMass>("mass"); if (!(tMass is LandMass)) { break; } LandMass tLand = (LandMass)tMass; if (tLand.mOwner != aMyStatus.mPlayerNumber) { break; } Subject.removeObserver("playerAi"); aCallback(tLand); return; } })); }
//自分以外の土地の料金の平均を求める public int getFeeAverage(PlayerStatus aMyStatus, GameFeild aFeild) { int tTotalFee = 0; int tTotalNum = 0; foreach (GameMass tMass in aFeild.mMassList) { if (!(tMass is LandMass)) { continue; } LandMass tLand = (LandMass)tMass; if (tLand.mOwner == aMyStatus.mPlayerNumber) { continue; } if (tLand.mOwner <= 0) { continue; } tTotalFee += tLand.mFeeCost; tTotalNum++; } if (tTotalFee == 0) { return(0); } return(tTotalFee / tTotalNum); }
//Done on seperate thread private void UpdateCreatingWorld(Object stateInfo) { Tile[,] tileGrid = new Tile[worldWidth, worldHeight]; List <Intersection> intersectionList = new List <Intersection>(); List <Town> townList = new List <Town>(); //Creating Mass LandMass landMass = new LandMass(tileGrid, waterMap, loadingInfo); //Creating Mass LandSmoothing landSmoothing = new LandSmoothing(tileGrid, loadingInfo); //Creating Roads TownsAndRoads townsAndRoads = new TownsAndRoads(tileGrid, intersectionList, townList, loadingInfo); AddingTrees addingTrees = new AddingTrees(tileGrid, treeMap, loadingInfo); //Setting the world WorldController.world = new World(worldWidth, worldHeight, tileGrid, intersectionList, townList); WorldController.world.AddVehicle(); //Faster GC Collection Array.Clear(waterMap, 0, waterMap.Length); Array.Clear(treeMap, 0, treeMap.Length); GC.Collect(); creationState = CreationState.InitMiniMap; }
public LandMassViewModel(LandMass landMass, IValueHolderReadOnly <double> metersPerPixel, IValueHolderReadOnly <double> seaMapSizeInPixels) { _landMass = landMass; _metersPerPixel = metersPerPixel; _seaMapSizeInPixels = seaMapSizeInPixels; _metersPerPixel.PropertyChanged += HandleMetersPerPixelPropertyChanged; HandleMetersPerPixelPropertyChanged(this, new PropertyChangedEventArgs(null)); }
public override void increaseLand(PlayerStatus aMyStatus, LandMass aLand, GameMaster mMaster, Action <bool> aCallback) { MySceneManager.openScene("twoChoicesQuestion", new Arg(new Dictionary <string, object>() { { "text", aLand.mIncreaseCost.ToString() + "金で" + aLand.mNameMesh.text + "を\n増資しますか" } }), null, (aArg) => { aCallback(aArg.get <bool>("answer")); }); }
public override void purchaseLand(PlayerStatus aMyStatus, LandMass aLand, GameMaster mMaster, Action <bool> aCallback) { //手持ちの金が料金の平均を下回らなければ購入する int tAve = getFeeAverage(aMyStatus, mMaster.mFeild); if (aMyStatus.mMoney - aLand.mPurchaseCost < tAve) { aCallback(false); return; } aCallback(true); }
//自分以外の土地に止まった public void stopOtherLand(PlayerStatus aTurnPlayer, Action aCallback) { LandMass tLand = (LandMass)mMaster.mFeild.mMassList[aTurnPlayer.mCurrentMassNumber]; GameEffector.lostCoin(aTurnPlayer.mComa.position, (-tLand.mFeeCost).ToString(), () => { aTurnPlayer.mMoney -= tLand.mFeeCost; PlayerStatus tStatus = mMaster.mPlayerStatus[tLand.mOwner - 1]; GameEffector.getCoin(tStatus.mComa.position, tLand.mFeeCost.ToString(), () => { tStatus.mMoney += tLand.mFeeCost; mMaster.updateStatus(); aCallback(); return; }); }); }
static public void soldLand(LandMass aLand, GameMaster aMaster, Action aCallback) { PlayerStatus tOwner = aMaster.mPlayerStatus[aLand.mOwner - 1]; aLand.changeOrner(null, () => {}); aMaster.mCamera.mTarget = aLand; GameEffector.lostCoin(aLand.worldPosition, "", () => { aMaster.mCamera.mTarget = tOwner.mComa; GameEffector.getCoin(tOwner.mComa.worldPosition, "+" + aLand.mSellCost.ToString(), () => { tOwner.mMoney += aLand.mSellCost; aMaster.updateStatus(); aCallback(); }); }); }
static public GameMass create(Arg aMassData) { switch (aMassData.get <string>("type")) { case "land": LandMass tLand = GameObject.Instantiate(Resources.Load <LandMass>("prefabs/game/mass/landMass")); tLand.mNameMesh.text = aMassData.get <string>("name"); tLand.name = aMassData.get <string>("name"); tLand.worldPosition = vector2ToPosition(aMassData.get <Vector2>("position")); tLand.mBaseValue = aMassData.get <int>("value"); tLand.mBuildingRenderer.sprite = null; //属性 tLand.mAttributes = aMassData.get <List <string> >("attribute"); if (tLand.mAttributes[0] == "none") { tLand.mAttribute1.sprite = null; } else { tLand.mAttribute1.sprite = Resources.Load <Sprite>("sprites/feild/attribute/" + tLand.mAttributes[0]); } if (tLand.mAttributes[1] == "none") { tLand.mAttribute2.sprite = null; } else { tLand.mAttribute2.sprite = Resources.Load <Sprite>("sprites/feild/attribute/" + tLand.mAttributes[1]); } tLand.updateValueDisplay(); return(tLand); case "bat": case "heart": case "god": EventMass tEvent = GameObject.Instantiate(Resources.Load <EventMass>("prefabs/game/mass/" + aMassData.get <string>("type") + "Mass")); tEvent.name = aMassData.get <string>("type"); tEvent.worldPosition = vector2ToPosition(aMassData.get <Vector2>("position")); return(tEvent); case "start": StartMass tStart = GameObject.Instantiate(Resources.Load <StartMass>("prefabs/game/mass/startMass")); tStart.name = "start"; tStart.worldPosition = vector2ToPosition(aMassData.get <Vector2>("position")); return(tStart); } throw new Exception("不明なマスタイプ : " + aMassData.get <string>("type")); }
public void stopLand(PlayerStatus aTurnPlayer, Action aCallback) { LandMass tLand = (LandMass)mMaster.mFeild.mMassList[aTurnPlayer.mCurrentMassNumber]; if (tLand.mOwner <= 0) { stopFreeLand(aTurnPlayer, aCallback); } else if (tLand.mOwner == aTurnPlayer.mPlayerNumber) { stopMyLand(aTurnPlayer, aCallback); } else { stopOtherLand(aTurnPlayer, aCallback); } }
public override void soldLand(PlayerStatus aMyStatus, GameMaster mMaster, Action <LandMass> aCallback) { //価値が最も低い土地を売る LandMass tCheapest = null; foreach (LandMass tLand in mMaster.mFeild.getOwnedLand(aMyStatus.mPlayerNumber)) { if (tCheapest == null) { tCheapest = tLand; continue; } if (tCheapest.mTotalValue > tLand.mTotalValue) { tCheapest = tLand; } } aCallback(tCheapest); }
//指定したプレイヤが所有している土地のリストを返す public List <LandMass> getOwnedLand(int aPlayerNumber) { List <LandMass> tLands = new List <LandMass>(); foreach (GameMass tMass in mMassList) { if (!(tMass is LandMass)) { continue; } LandMass tLand = (LandMass)tMass; if (tLand.mOwner != aPlayerNumber) { continue; } tLands.Add(tLand); } return(tLands); }
//プレイヤの物件,総資産更新 public void updatePropertyValueStatus() { foreach (PlayerStatus tStatus in mTurnOrder) { int tProperty = 0; foreach (GameMass tMass in mFeild.mMassList) { if (!(tMass is LandMass)) { continue; } LandMass tLand = (LandMass)tMass; if (tLand.mOwner != tStatus.mPlayerNumber) { continue; } tProperty += tLand.mTotalValue; } tStatus.mProperty = tProperty; tStatus.mAssets = tStatus.mMoney + tStatus.mProperty; } }
public override void purchaseLand(PlayerStatus aMyStatus, LandMass aLand, GameMaster mMaster, Action <bool> aCallback) { aCallback(true); }
abstract public void purchaseLand(PlayerStatus aMyStatus, LandMass aLand, GameMaster mMaster, Action <bool> aCallback);