コード例 #1
0
ファイル: Highlight.cs プロジェクト: ronaldme/Triumph
 /// <summary>
 /// Clears only the highlights.
 /// </summary>
 public void ClearHighlights()
 {
     foreach (HighlightObject item in HighlightObjects)
     {
         UnitSelected.SelectionBox.enabled = false;
         item.ChangeHighlight(HighlightTypes.highlight_none);
     }
     HighlightObjects.Clear();
     IsHighlightOn = false;
 }
コード例 #2
0
ファイル: Highlight.cs プロジェクト: ronaldme/Triumph
        /// <summary>
        /// Gets called whenever an OnUnitClick event is fired.
        /// </summary>
        /// <param Name="evt"></param>
        public void ShowHighlight(OnUnitClick evt)
        {
            if (evt.unit != null)
            {
                if (!IsHighlightOn && !movement.NeedsMoving && !animInfo.IsAnimateFight)
                {
                    UnitSelected  = evt.unit;
                    IsHighlightOn = true;

                    if (!UnitSelected.UnitGame.HasMoved)
                    {
                        UnitSelected.UnitGame.PlaySound(UnitSoundType.Select);
                        UnitSelected.SelectionBox.enabled = true;

                        var movementListt = TileHelper.GetAllTilesWithinRange(UnitSelected.Tile.Coordinate,
                                                                              UnitSelected.UnitGame.MoveRange);
                        foreach (var item in movementListt)
                        {
                            foreach (KeyValuePair <int, Tile> tile in item.Value)
                            {
                                if (!tile.Value.HasUnit() && tile.Value.environmentGameObject.EnvironmentGame.IsWalkable)
                                {
                                    List <Node> path = movement.CalculateShortestPath(UnitSelected.Tile,
                                                                                      tile.Value, false);

                                    if (path != null && path.Count <= UnitSelected.UnitGame.MoveRange)
                                    {
                                        tile.Value.Highlight.ChangeHighlight(HighlightTypes.highlight_move);
                                        HighlightObjects.Add(tile.Value.Highlight);
                                    }
                                }
                            }
                        }
                        attack.ShowAttackHighlights(UnitSelected, UnitSelected.UnitGame.GetAttackMoveRange);
                    }
                    else if (UnitSelected.UnitGame.CanAttackAfterMove && !UnitSelected.UnitGame.HasAttacked)
                    {
                        attack.ShowAttackHighlights(UnitSelected, UnitSelected.UnitGame.AttackRange);
                    }
                }
            }
        }
コード例 #3
0
 // Use this for initialization
 void Start()
 {
     highlightObjects = Camera.main.GetComponent <HighlightObjects>();
 }