当前位置: 首页>>代码示例>>C#>>正文


C# TileData.IsDefended方法代码示例

本文整理汇总了C#中TileData.IsDefended方法的典型用法代码示例。如果您正苦于以下问题:C# TileData.IsDefended方法的具体用法?C# TileData.IsDefended怎么用?C# TileData.IsDefended使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TileData的用法示例。


在下文中一共展示了TileData.IsDefended方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleTileEvent

    void HandleTileEvent(TileData tile)
    {
        _OverworldUI.Disable();
        _GameStateHolder._ActivePlayer.HasMoved = true;
        if (_GameStateHolder._ActivePlayer.IsScouting) {
            _GameStateHolder._ActivePlayer.IsScouting = false;
            endTurn ();
        } else {
            ModalPanel p = ModalPanel.Instance ();
            switch (tile.Building) {
            case BuildingType.Armoury:
                if (!_GameStateHolder._ActivePlayer.LandedArmoury) {
                    _GameStateHolder._ActivePlayer.LandedArmoury = true;
                    TutorialPanel.Instance().Tutor(_GameStateHolder._ActivePlayer.Type,
                       "Armoury",
                       "Welcome to the Armoury!\n" +
                        "You can use resources that you have earned to expand your army or purchase upgrades.",
                       false);
                }
                _OverworldUI._ArmouryUI.Show(_GameStateHolder._ActivePlayer);
                break;
            case BuildingType.Camp:
                if (!_GameStateHolder._ActivePlayer.LandedCamp) {
                    _GameStateHolder._ActivePlayer.LandedCamp = true;
                    TutorialPanel.Instance().Tutor(_GameStateHolder._ActivePlayer.Type,
                        "Camp",
                        "You just landed on a camp. You can add it to your empire if you defeat the enemies lurking there.",
                       false);
                }
                if (tile.Owner != _GameStateHolder._ActivePlayer.Type) {
                    if (tile.Owner == PlayerType.None) {
                        // MONSTER BATTLE
                        p.ShowOK ("Camp", "You see a camp and enter it. Monsters attack!", () => {
                            startBattle (BattleType.Monster);
                        });
                    } else {

                        if (tile.IsDefended()) {
                            p.ShowOK("Camp", "You see a camp, there appears to be an enemy unit defending. The enemy attacks you!", () => {
                                startBattle(BattleType.PvP);
                            });
                        } else {
                            _Board.SetTileOwner(tile, _GameStateHolder._ActivePlayer.Type);
                            Unit prisoner = _GameStateHolder._ActivePlayer.PlayerArmy.GetDefendingUnit(tile);
                            if (prisoner != null) {
                                _Board.UnsetTilePrisoner(tile);
                                PromptForReturnPrisoner(_GameStateHolder._ActivePlayer, prisoner, tile, p, endTurn);
                            } else if (_GameStateHolder._ActivePlayer.PlayerArmy.GetActiveUnits().Count > 1) {
                                StartCoroutine(PromptForDefendingUnit("You enter the camp, it's been abandoned. Leave a unit to defend this camp?", _GameStateHolder._ActivePlayer, p, endTurn));
                            } else {
                                //TODO: Add some text here to give the player some info
                                endTurn();
                            }
                        }
                    }
                    break;
                }
                if (tile.IsDefended ()) {
                    Unit defendingUnit = _GameStateHolder._ActivePlayer.PlayerArmy.GetDefendingUnit (tile);
                    p.ShowOKCancel("Take back unit", "Should this " + defendingUnit.Type + " stop defending this area?", () =>
                        StartCoroutine(PromptToReplaceDefendingUnit (_GameStateHolder._ActivePlayer, defendingUnit, p, endTurn)),
                        endTurn);
                } else {
                    if (_GameStateHolder._ActivePlayer.PlayerArmy.GetActiveUnits().Count > 1) {
                            StartCoroutine(PromptForDefendingUnit ("Your land is undefended. Would you like to leave a unit to defend this camp?", _GameStateHolder._ActivePlayer, p, endTurn));
                    } else {
                        endTurn ();
                    }
                }
                break;
            case BuildingType.Cave:
                if (tile.Owner != _GameStateHolder._ActivePlayer.Type) {
                    if (tile.Owner != PlayerType.None && tile.IsDefended()) {
                        p.ShowOK("Cave", "You enter the cave to explore. An enemy unit ambushes you!", () => {
                            startBattle(BattleType.PvP);
                        });
                        return;
                    }

                    if(!_GameStateHolder._ActivePlayer.LandedCave) {
                        _GameStateHolder._ActivePlayer.LandedCave = true;
                        TutorialPanel.Instance().Tutor(_GameStateHolder._ActivePlayer.Type,
                            "Cave",
                            "There's a decent stash of treasure in this cave.",
                            true);
                    }
                    if(!_GameStateHolder._ActivePlayer.HasCaptured) {
                        _GameStateHolder._ActivePlayer.HasCaptured = true;
                        TutorialPanel.Instance().Tutor(_GameStateHolder._ActivePlayer.Type,
                            "Cave",
                            "You captured the cave and made it part of your empire!",
                            true);
                    }
                    CardData c =_CardSystem.GetRandomCard(_AvailableCaveCards.cards);
                    _GameStateHolder._ActivePlayer.AddCard(c);
                    _Board.SetTileOwner(tile, _GameStateHolder._ActivePlayer.Type);

                    Unit prisoner = _GameStateHolder._ActivePlayer.PlayerArmy.GetDefendingUnit(tile);
                    if (prisoner != null) {
                        _Board.UnsetTilePrisoner(tile);
//.........这里部分代码省略.........
开发者ID:EpicPants90,项目名称:ELB,代码行数:101,代码来源:OverworldManager.cs


注:本文中的TileData.IsDefended方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。