public void updateDisplay(LandMasStatus aStatus) { if (aStatus.mOwnerNumber < 0) { mFree.gameObject.SetActive(true); mOccupy.text = aStatus.mOccupyCost.ToString(); mOccupied.gameObject.SetActive(false); mEdge.color = PlayerStatus.nonePlayerColor; mCrown1.color = PlayerStatus.nonePlayerColor; mCrown2.color = PlayerStatus.nonePlayerColor; mCrown3.color = PlayerStatus.nonePlayerColor; } else { mFree.gameObject.SetActive(false); mOccupied.gameObject.SetActive(true); mLooting.text = aStatus.mLootedCost.ToString(); mExpansion.text = aStatus.mExpansionCost.ToString(); mEdge.color = PlayerStatus.playerColor[aStatus.mOwnerNumber]; mCrown1.color = PlayerStatus.playerColor[aStatus.mOwnerNumber]; mCrown2.color = PlayerStatus.playerColor[aStatus.mOwnerNumber]; mCrown3.color = PlayerStatus.playerColor[aStatus.mOwnerNumber]; } mCrown1.gameObject.SetActive(aStatus.mExpansionLevel == 1); mCrown2.gameObject.SetActive(aStatus.mExpansionLevel == 2); mCrown3.gameObject.SetActive(aStatus.mExpansionLevel == 3); }
public void initDisplay(LandMasStatus aStatus) { mName.text = aStatus.mName; mAttribute1.sprite = LandMasStatus.getLandAttributeImage(aStatus.mAttribute1); mAttribute2.sprite = LandMasStatus.getLandAttributeImage(aStatus.mAttribute2); updateDisplay(aStatus); }
//拡大する private void expandLand(PlayerStatus aPlayer, LandMasStatus aLand) { MySoundPlayer.playSe("decision7"); aPlayer.mFood -= aLand.mExpansionCost; aPlayer.mTerritory += aLand.mExpansionCost; mElement.mPlayerStatusDisplay[aPlayer.mPlayerNumber].updateDisplay(aPlayer); aLand.mExpansionLevel += 1; ((LandMasDisplay)mElement.mMasDisplay[aLand.mMasNumber]).updateDisplay(aLand); }
//占領する private void occupyLand(PlayerStatus aPlayer, LandMasStatus aLand) { MySoundPlayer.playSe("decision7"); aPlayer.mFood -= aLand.mValue; aPlayer.mTerritory += aLand.mValue; mElement.mPlayerStatusDisplay[aPlayer.mPlayerNumber].updateDisplay(aPlayer); aLand.mOwnerNumber = aPlayer.mPlayerNumber; ((LandMasDisplay)mElement.mMasDisplay[aLand.mMasNumber]).updateDisplay(aLand); }
public override void selectOccupyLand(PlayerStatus aMyself, GameElementData aElement, Action <LandMasStatus> aAnser) { aElement.mTable.showOneSelectForm("占領する土地を\n選択してください", "占領しない"); LandMasStatus tSelected = null; //マスタップ監視 Subject.addObserver(new Observer("playerControllerTouchMas", (aMessage) => { if (aMessage.name != "touchMas") { return; //監視外メッセージ } MasStatus tMas = aElement.mMasStatus[aMessage.parameters.get <int>("number")]; if (!(tMas is LandMasStatus)) { return; //土地のマス以外 } LandMasStatus tLand = (LandMasStatus)tMas; if (tLand.mOwnerNumber >= 0) { return; //占領済マス } if (aMyself.mFood < tLand.mOccupyCost) { return; //所持食糧を超えるコストのマス } tSelected = tLand; aElement.mTable.hideMessage(); aElement.mTable.hideOneSelectForm(); aElement.mTable.question(tSelected.mName + "を占領しますか?\n食糧-" + tLand.mOccupyCost); })); //はい,いいえ,占領しない選択監視 Subject.addObserver(new Observer("playerControllerTableQuestion", (aMessage) => { if (aMessage.name == "yes") { Subject.removeObserver("playerControllerTouchMas"); Subject.removeObserver("playerControllerTableQuestion"); aElement.mTable.hideQuestionForm(); aAnser(tSelected); } else if (aMessage.name == "no") { aElement.mTable.hideQuestionForm(); tSelected = null; aElement.mTable.showOneSelectForm("占領する土地を\n選択してください", "占領しない"); } else if (aMessage.name == "oneSelect") { Subject.removeObserver("playerControllerTouchMas"); Subject.removeObserver("playerControllerTableQuestion"); aElement.mTable.hideOneSelectForm(); aAnser(null); } })); }
//解放する private void freeLand(LandMasStatus aLand, Action aCallback) { MySoundPlayer.playSe("cancel1"); PlayerStatus tOwner = mElement.mPlayerStatus[aLand.mOwnerNumber]; tOwner.mFood += aLand.mFreeCost; aLand.mOwnerNumber = -1; tOwner.mTerritory -= aLand.mTotalValue; mElement.mPlayerStatusDisplay[tOwner.mPlayerNumber].updateDisplay(tOwner); ((LandMasDisplay)mElement.mMasDisplay[aLand.mMasNumber]).updateDisplay(aLand); setTimeout(1, aCallback); }
//土地属性に被害 private void damageLandAttribute(int aParcent, LandMasStatus.LandAttribute aAttribute, Action aCallback) { waitTap(() => { int[] tLostFoodList = new int[mElement.mPlayerStatus.Length]; for (int i = 0; i < mElement.mMasStatus.Length; i++) { if (!(mElement.mMasStatus[i] is LandMasStatus)) { continue; } LandMasStatus tLand = (LandMasStatus)mElement.mMasStatus[i]; if (tLand.mOwnerNumber < 0) { continue; } if (!(tLand.mAttribute1 == aAttribute || tLand.mAttribute2 == aAttribute || aAttribute == LandMasStatus.LandAttribute.all)) { continue; } tLostFoodList[tLand.mOwnerNumber] += tLand.mTotalValue * aParcent / 100; } int j = 0; Action tLost = () => { }; tLost = () => { if (j >= mTurn.Length) { mElement.mTable.hideMessage(); aCallback(); return; } PlayerStatus tPlayer = mElement.mPlayerStatus[mTurn[j]]; if (tPlayer.mTotalResource < 0) { j++; tLost(); return; } mElement.mTable.showMessage((tPlayer.mPlayerNumber + 1) + "Pは\n食糧-" + tLostFoodList[tPlayer.mPlayerNumber].ToString() + "の損失"); lostFood(tPlayer, tLostFoodList[tPlayer.mPlayerNumber], () => { j++; tLost(); }); }; tLost(); }); }
/// <summary>占領されていない土地を全て返す</summary> public List <LandMasStatus> getAllFreeLand() { List <LandMasStatus> tFree = new List <LandMasStatus>(); for (int i = 0; i < mMasStatus.Length; i++) { if (!(mMasStatus[i] is LandMasStatus)) { continue; } LandMasStatus tLand = (LandMasStatus)mMasStatus[i]; if (tLand.mOwnerNumber >= 0) { continue; } tFree.Add(tLand); } return(tFree); }
/// <summary>指定したプレイヤが占領している土地を全て返す</summary> public List <LandMasStatus> getAllOccupiedLand(PlayerStatus aPlayer) { List <LandMasStatus> tOccupied = new List <LandMasStatus>(); for (int i = 0; i < mMasStatus.Length; i++) { if (!(mMasStatus[i] is LandMasStatus)) { continue; } LandMasStatus tLand = (LandMasStatus)mMasStatus[i]; if (tLand.mOwnerNumber != aPlayer.mPlayerNumber) { continue; } tOccupied.Add(tLand); } return(tOccupied); }
public override void freeLand(PlayerStatus aMyself, GameElementData aElement, Action <LandMasStatus> aAnser) { aElement.mTable.showMessage("解放する土地を\n選択してください"); LandMasStatus tSelected = null; //マスタップ監視 Subject.addObserver(new Observer("playerControllerTouchMas", (aMessage) => { if (aMessage.name != "touchMas") { return; //監視外メッセージ } MasStatus tMas = aElement.mMasStatus[aMessage.parameters.get <int>("number")]; if (!(tMas is LandMasStatus)) { return; //土地のマス以外 } LandMasStatus tLand = (LandMasStatus)tMas; if (tLand.mOwnerNumber != aMyself.mPlayerNumber) { return; //自分以外の土地 } tSelected = tLand; aElement.mTable.hideMessage(); aElement.mTable.question(tSelected.mName + "を解放しますか?\n食糧+" + tLand.mFreeCost); })); //はい,いいえ選択監視 Subject.addObserver(new Observer("playerControllerTableQuestion", (aMessage) => { if (aMessage.name == "yes") { Subject.removeObserver("playerControllerTouchMas"); Subject.removeObserver("playerControllerTableQuestion"); aElement.mTable.hideQuestionForm(); aAnser(tSelected); } else if (aMessage.name == "no") { aElement.mTable.hideQuestionForm(); tSelected = null; aElement.mTable.showMessage("解放する土地を\n選択してください"); } })); }
public override void expandLand(PlayerStatus aMyself, LandMasStatus aLand, GameElementData aElement, Action <bool> aAnser) { Subject.addObserver(new Observer("playerController", (aMessage) => { if (aMessage.name == "yes") { aAnser(true); } else if (aMessage.name == "no") { aAnser(false); } else { return; } Subject.removeObserver("playerController"); aElement.mTable.hideQuestionForm(); })); aElement.mTable.question("食糧" + aLand.mExpansionCost + "で拡大しますか?"); }
//ステージに含まれる土地属性を全て返す private List <LandMasStatus.LandAttribute> getAllLandAttribute() { List <LandMasStatus.LandAttribute> tList = new List <LandMasStatus.LandAttribute>(); for (int i = 0; i < mElement.mMasStatus.Length; i++) { if (!(mElement.mMasStatus[i] is LandMasStatus)) { continue; } LandMasStatus tLand = (LandMasStatus)mElement.mMasStatus[i]; bool tContain1 = false; bool tContain2 = false; foreach (LandMasStatus.LandAttribute aAttribute in tList) { if (aAttribute == tLand.mAttribute1) { tContain1 = true; } if (aAttribute == tLand.mAttribute2) { tContain2 = true; } } if (!tContain1 && tLand.mAttribute1 != LandMasStatus.LandAttribute.none) { tList.Add(tLand.mAttribute1); } if (!tContain2 && tLand.mAttribute2 != LandMasStatus.LandAttribute.none) { tList.Add(tLand.mAttribute2); } } return(tList); }
private void initStatus() { //player //データ生成 mElement.mPlayerStatus = new PlayerStatus[mElement.mInitData.mPlayerDataList.Length]; for (int i = 0; i < mElement.mInitData.mPlayerDataList.Length; i++) { mElement.mPlayerStatus[i] = new PlayerStatus(); mElement.mPlayerStatus[i].mAnimalName = mElement.mInitData.mPlayerDataList[i].mAnimalName; mElement.mPlayerStatus[i].mPlayerNumber = i; mElement.mPlayerStatus[i].mController = mElement.mInitData.mPlayerDataList[i].mIsPlayer ? (GameController) new PlayerController() : (GameController) new AiController(); mElement.mPlayerStatus[i].mRank = 1; mElement.mPlayerStatus[i].mLap = 0; mElement.mPlayerStatus[i].mReverseLap = 0; mElement.mPlayerStatus[i].mFood = mElement.mStageData.mInitialFood * mElement.mInitData.mInitialFood / 100; mElement.mPlayerStatus[i].mTerritory = 0; mElement.mPlayerStatus[i].mCurrentMasNumber = 0; mElement.mPlayerStatus[i].mTurn = i; } //データ表示 for (int i = 0; i < mElement.mInitData.mPlayerDataList.Length; i++) { mElement.mPlayerStatusDisplay[i].initDisplay(mElement.mPlayerStatus[i]); } //mass //データ生成 List <StageData.Mas> tMasDataList = mElement.mStageData.mMas; mElement.mMasStatus = new MasStatus[tMasDataList.Count]; for (int i = 0; i < tMasDataList.Count; i++) { StageData.Mas tMasData = tMasDataList[i]; MasStatus tMas = null; switch (tMasData.mType) { case MasStatus.MasType.land: StageData.Land tLandData = tMasData as StageData.Land; LandMasStatus tLand = new LandMasStatus(); tLand.mName = tLandData.mName; tLand.mValue = tLandData.mValue; tLand.mAttribute1 = tLandData.mAttribute1; tLand.mAttribute2 = tLandData.mAttribute2; tLand.mOwnerNumber = -1; tLand.mExpansionLevel = 0; tMas = tLand; break; case MasStatus.MasType.start: tMas = new StartMasStatus(); break; case MasStatus.MasType.accident: AccidentMasStatus tAccident = new AccidentMasStatus(); tAccident.mAccidentKey = ((StageData.Accident)tMasData).mAccidentType; tMas = tAccident; break; } tMas.mType = tMasData.mType; tMas.mMasNumber = i; mElement.mMasDisplay[i].mEventListener.mMessage = "touchMas"; mElement.mMasDisplay[i].mEventListener.mArg = new Arg(new Dictionary <string, object>() { { "number", i } }); mElement.mMasStatus[i] = tMas; } //データ表示 for (int i = 0; i < mElement.mMasStatus.Length; i++) { if (mElement.mMasStatus[i].mType == MasStatus.MasType.land) { ((LandMasDisplay)mElement.mMasDisplay[i]).initDisplay((LandMasStatus)mElement.mMasStatus[i]); } } }
//土地に止まった時のイベント private void runLandEventPhase(PlayerStatus aPlayer, LandMasStatus aLand, Action aCallback) { if (aLand.mOwnerNumber < 0) { //未占領だった場合 bool tRuned = false; if (aPlayer.mFood >= aLand.mValue) { //食糧が足りる aPlayer.mController.occupyLand(aPlayer, aLand, mElement, (a) => { if (tRuned) { return; //既に回答済 } tRuned = true; if (!a) //占領しない { setTimeout(0.3f, () => { aCallback(); }); return; } occupyLand(aPlayer, aLand); setTimeout(0.5f, () => { aCallback(); }); }); } else { //食糧が足りない setTimeout(0.3f, () => { aCallback(); }); } } else { PlayerStatus tOwerPlayer = mElement.mPlayerStatus[aLand.mOwnerNumber]; if (aPlayer == tOwerPlayer) { //自分の所有地だった場合 bool tRuned = false; if (aPlayer.mFood >= aLand.mExpansionCost && aLand.mExpansionLevel < 3) { //食糧が足りる aPlayer.mController.expandLand(aPlayer, aLand, mElement, (a) => { if (tRuned) { return; //既に回答済 } tRuned = true; if (!a) //拡大しない { setTimeout(0.3f, () => { aCallback(); }); return; } expandLand(aPlayer, aLand); setTimeout(0.5f, () => { aCallback(); }); }); } else { //食糧が足りない setTimeout(0.3f, () => { aCallback(); }); } } else { //他人の所有地だった場合 moveFood(mElement.mPlayerStatus[aLand.mOwnerNumber], aPlayer, aLand.mLootedCost, aCallback); } } }
public override void expandLand(PlayerStatus aMyself, LandMasStatus aLand, GameElementData aElement, Action <bool> aAnser) { aAnser(true); }
//土地を拡大するか abstract public void expandLand(PlayerStatus aMyself, LandMasStatus aLand, GameElementData aElement, Action <bool> aAnser);