當前位置: 首頁>>代碼示例>>C#>>正文


C# Ability.GenerateTargetGrid方法代碼示例

本文整理匯總了C#中Ability.GenerateTargetGrid方法的典型用法代碼示例。如果您正苦於以下問題:C# Ability.GenerateTargetGrid方法的具體用法?C# Ability.GenerateTargetGrid怎麽用?C# Ability.GenerateTargetGrid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ability的用法示例。


在下文中一共展示了Ability.GenerateTargetGrid方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SelectAbilityTarget

        /// <summary>
        /// Create a callback function to process if the player chooses to have a character attack. This callback will display the targetting grid
        /// and bind _aimAbility to a function that queues an attack command from the character onto the target.
        /// </summary>
        /// <param name="character">The character whose attack is being chosen.</param>
        /// <param name="ability">The ability currently being aimed.</param>
        /// <returns></returns>
        private void SelectAbilityTarget(Combatant character, Ability ability)
        {
            _state = BattleState.AimingAbility;
            Gui.Screen.Desktop.Children.Remove(_radialMenuControl);

            _battleBoardLayer.SetTargettingGrid(
                ability.Name == "Move" ?
                    character.GetMovementGrid(BattleBoard.GetAccessibleGrid(character.Faction)) :
                    ability.GenerateTargetGrid(BattleBoard.Sandbag.Clone()),
                ability.GenerateImpactGrid()
            );

            _battleBoardLayer.AbilityAim = true;

            _aimAbility = (x, y) =>
                {
                    // only target enemies with angry spells and allies with friendly spells
                    if (!ability.CanTarget(BattleBoard.IsOccupied(new Point(x, y))))
                        return false;

                    character.Avatar.UpdateVelocity(x - character.Avatar.Location.X, y - character.Avatar.Location.Y);
                    character.Avatar.UpdateVelocity(0, 0);

                    // make sure the ability knows who is casting it. this probably shouldn't
                    // be done here, but there are issues doing it elsewhere.
                    ability.Character = character;

                    var command = new Command
                        {
                            Character = character,
                            Target = new Point(x, y),
                            Ability = ability
                        };

                    if(ability.Name == "Move")
                    {
                        ExecuteCommand(command);
                        return true;
                    }

                    character.CanAct = false;
                    QueuedCommands.Add(command);
                    _queuedCommands.UpdateControls();
                    _state = BattleState.Delay;
                    _delayState = BattleState.PlayerTurn;
                    _delayTimer = 0.05F;
                    ResetState();

                    return true;
                };
        }
開發者ID:HaKDMoDz,項目名稱:armadillo,代碼行數:58,代碼來源:BattleScene.cs

示例2: PreviewAbility

 /// <summary>
 /// Show a stats panel indicating the name, mana and description of an ability
 /// </summary>
 /// <param name="ability"></param>
 private void PreviewAbility(Ability ability)
 {
     _abilityStatLayer.SetAbility(ability);
     ShowGui(_abilityStatLayer);
     _battleBoardLayer.SetTargettingGrid(
         ability.GenerateTargetGrid(BattleBoard.Sandbag.Clone()),
         new Grid(1, 1)
     );
 }
開發者ID:HaKDMoDz,項目名稱:armadillo,代碼行數:13,代碼來源:BattleScene.cs


注:本文中的Ability.GenerateTargetGrid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。