public async Task Custom(string customTestName)
        {
            CustomTest    test;
            SelectedRange?selection;


            test = Definition.Tests.CreateUrl.Misc.First((x) => x.Name == customTestName);

            if (test.Selection is not null)
            {
                selection = new SelectedRange(
                    test.Selection.StartLine,
                    test.Selection.StartColumn,
                    test.Selection.EndLine,
                    test.Selection.EndColumn
                    );
            }
            else
            {
                selection = null;
            }

            await RunTestAsync(
                test.Remote,
                test.Settings,
                test.Result,
                new TestOptions {
                Branch    = test.Branch,
                FileName  = test.FileName,
                Selection = selection,
                Type      = test.LinkType
            }
                );
        }
        /// <summary>
        /// Overridden from <see cref="PhaseLogic.OnMouseLeftClick(Vector3)"/>.
        /// </summary>
        protected override void OnMouseLeftClick(Vector3 position)
        {
            Coord?fetchCoord = GetSectorAtScreen(position);

            if (!fetchCoord.HasValue) // if the player clicked off-screen, clear selection
            {
                DoUnitSelection(null, s => 0);
            }
            else if (ContainsUnit(fetchCoord.Value, true)) // if player clicked on owned unit, shift selection to that one
            {
                DoUnitSelection(fetchCoord.Value, s =>
                                s.OccupyingUnit.HasAttacked || s.OccupyingUnit.ManaAttackCost > s.OccupyingUnit.Owner.Mana ?
                                0 : s.OccupyingUnit.AttackRange);
                if (SelectedUnit != null) // if the player was able to select the unit
                {                         // this should pass anyway, but it's good to double check
                  // unit just selected
                }
                else
                {
                    Debug.Log("Owned unit selection failed");
                }
            }
            else if (SelectedUnit != null) // if player has clicked a unit before, and has now clicked on a separate space, we need to prepare to move
            {
                SelectSector(fetchCoord);  // try to select the clicked sector
                // only consider an attack selection if it wasn't traversable and if an enemy was on it
                if (SelectedSector != null && SelectedSectorContainsUnit(true))
                {
                    if (SelectedRange.Contains(SelectedSector)) // only attack the unit if it was in range
                    {
                        AttackUnit();
                    }
                }
            }
        }
        private void AddDefaultSession(DayEntry activity)
        {
            // Clear the sessions from the previously selected row, and show a blank row
            Sessions.SetCurrentActivity(activity.Activity, 0);

            dev1_session session = new dev1_session();

            session.Account                           = activity.Account;
            session.dev1_ActivityId                   = activity.Activity.Id.ToString();
            session.dev1_ActivityTypeName             = activity.Activity.LogicalName;
            session.dev1_ActivityId                   = activity.Activity.Id.ToString();
            session.dev1_StartTime                    = Sessions.WeekStart;
            session.activitypointer_subject           = activity.Activity.Name;
            session.activitypointer_regardingobjectid = activity.RegardingObjectId;
            Sessions.SelectedActivity                 = activity.Activity;
            session.dev1_Row                          = this.Sessions.GetCurrentWeek().Count;
            // Has the account been set - if not we need to look it up from the selected activity
            if (session.Account == null || session.activitypointer_regardingobjectid == null)
            {
                SetAccountAndRegardingFromActivity(session);
            }


            Sessions.AddItem(session);
            _selectedRows = new SelectedRange[1] {
                new SelectedRange()
            };
            _selectedRows[0].FromRow = rows.Count + 1;
            _selectedRows[0].ToRow   = rows.Count + 1;
        }
 /// <summary>
 /// Selects the range around the given coordinate, exlcuding the given one.
 /// </summary>
 /// <param name="coord">The starting coordinate. If null, will deselect.</param>
 /// <param name="range">The size of the range.</param>
 protected void SelectRangeAround(Coord?coord, int range)
 {
     SelectedRange.Clear();
     if (coord.HasValue)
     {
         HashSet <Coord> coordRange = Gc.Map.Grid.GetRange(coord.Value, range);
         coordRange.Remove(coord.Value);
         foreach (Coord c in coordRange)
         {
             if (Gc.Map.Grid.IsTraversable(c))
             {
                 SelectedRange.Add(Gc.Map.Grid[c]);
             }
         }
     }
 }
Example #5
0
        public Action NewCommand()
        {
            if (_newCommand == null)
            {
                _newCommand = delegate()
                {
                    // Remove selected rows
                    SelectedRange[] rows = new SelectedRange[0];
                    this.JobsViewModel.RaiseOnSelectedRowsChanged(rows);

                    // Create new schedule
                    ScheduledJob job = SelectedJob.GetValue();
                    job.Reset();
                };
            }
            return(_newCommand);
        }
Example #6
0
        public override void AddItem(object item)
        {
            dev1_session session  = new dev1_session();
            DayEntry     activity = (DayEntry)item;

            if ((activity.Activity != null) && (activity.Activity.Id != null))
            {
                session.dev1_ActivityId       = activity.Activity.Id.ToString();
                session.dev1_ActivityTypeName = activity.Activity.LogicalName;
                //session.activityName = activity.Activity.Name;
                session.dev1_ActivityId   = activity.Activity.Id.ToString();
                session.dev1_StartTime    = sessions.WeekStart;
                sessions.SelectedActivity = activity.Activity;
                sessions.AddItem(session);
                _selectedRows = new SelectedRange[1] {
                    new SelectedRange()
                };
                _selectedRows[0].FromRow = rows.Count + 1;
                _selectedRows[0].ToRow   = rows.Count + 1;
                Refresh();
            }
        }
        public Action SaveSelectedContact()
        {
            if (_saveSelectedContact == null)
            {
                _saveSelectedContact = delegate()
                {
                    if (((IValidatedObservable)SelectedContact).IsValid())
                    {
                        Contact           contact         = SelectedContact.GetValue().Commit();
                        ObservableContact selectedContact = SelectedContact.GetValue();

                        if (selectedContact.EntityState.GetValue() == EntityStates.Created)
                        {
                            this.Contacts.AddItem(contact);

                            // Move to the last page
                            PagingInfo paging = this.Contacts.GetPagingInfo();

                            SelectedRange[] newRow = new SelectedRange[1];
                            newRow[0]         = new SelectedRange();
                            newRow[0].FromRow = paging.TotalRows - ((paging.TotalPages - 1) * paging.PageSize) - 1;
                            this.Contacts.RaiseOnSelectedRowsChanged(newRow);
                            selectedContact.EntityState.SetValue(EntityStates.Changed);
                        }
                        else
                        {
                            Contacts.Refresh();
                        }
                    }
                    else
                    {
                        Script.Literal("{0}.errors.showAllMessages()", SelectedContact);
                    }
                };
            }
            return(_saveSelectedContact);
        }
        protected override void Update()
        {
            base.Update();

            Coord?fetchCoord = GetSectorAtScreen(Input.mousePosition);

            // build unit highlighting
            if (_currentSecondaryHighlightedSectors.Count > 0)
            {
                foreach (Sector sector in _currentSecondaryHighlightedSectors)
                {
                    if (sector.Highlight == HighlightLevel.Bright)
                    {
                        sector.Highlight = HighlightLevel.Dimmed;
                    }
                }
                _currentSecondaryHighlightedSectors.Clear();
            }
            if (SelectedUnit != null && fetchCoord.HasValue && Gc.Map.Grid.IsTraversable(fetchCoord.Value) && SelectedRange.Contains(Gc.Map.Grid[fetchCoord.Value]))
            {
                _currentSecondaryHighlightedSectors.Add(Gc.Map.Grid[fetchCoord.Value]);
                Gc.Map.Grid[fetchCoord.Value].Highlight = HighlightLevel.Bright;
            }
        }
Example #9
0
        /// <summary>
        /// Overridden from <see cref="PhaseLogic.OnMouseLeftClick(Vector3)"/>.
        /// </summary>
        protected override void OnMouseLeftClick(Vector3 position)
        {
            Coord? fetchCoord     = GetSectorAtScreen(position);
            Sector prevUnitSector = SelectedUnit;

            // if we are attempting to build a unit, handle either creation or cancellation
            if (_isBuildingUnit)
            {
                SelectSector(fetchCoord); // we need to know where the player clicked
                if (SelectedSector != null && SelectedRange.Contains(SelectedSector) && SelectedSector.OccupyingUnit == null)
                {                         // if the player clicked a valid build spot, then build the unit
                    IUnit newUnit = Instantiate(Gc.UnitPrefabs[_unitToBuild]).GetComponent <IUnit>();
                    newUnit.Init(Gc.Map.SectorMaterials, SelectedUnit.OccupyingUnit.Owner, SelectedUnit.OccupyingUnit.College);
                    SelectedSector.OccupyingUnit = newUnit;
                    Gc.CurrentPlayer.Mana       -= newUnit.Cost;
                    UpdateMana();
                }
                // we are no longer building
                SetUnitBuildingState(false);
            }
            else
            {
                if (!fetchCoord.HasValue) // if the player clicked off-screen, clear selection
                {
                    DoUnitSelection(null, s => 0);
                }
                else if (ContainsUnit(fetchCoord.Value, true)) // if player clicked on owned unit, shift selection to that one
                {
                    DoUnitSelection(fetchCoord.Value, s => (int)Mathf.Clamp(Mathf.Floor(s.OccupyingUnit.Owner.Mana / s.OccupyingUnit.ManaMoveRatio), 0, s.OccupyingUnit.AvailableMove));
                    if (SelectedUnit != null) // if the player was able to select the unit
                    {                         // this should pass anyway, but it's good to double check
                        _selectedUnitLocation = fetchCoord.Value;
                    }
                    else
                    {
                        Debug.Log("Owned unit selection failed");
                    }
                }
                else if (SelectedUnit != null) // if player has clicked a unit before, and has now clicked on a separate space, we need to prepare to move
                {
                    SelectSector(fetchCoord);  // try to select the clicked sector
                                               // if it wasn't traversable, or it contains an enemy unit, then we won't bother moving
                    if (SelectedSector != null && !SelectedSectorContainsUnit(true) && !BuildMenuState)
                    {                          // only move the unit if we are allowed, and are actually looking to move
                        if (SelectedRange.Contains(SelectedSector))
                        {
                            MoveUnit();
                        }
                    }
                }

                if (SelectedUnit != null && SelectedUnit.OccupyingUnit.BuildRange > 0) // if this is a builder unit
                {
                    // if player selected a new builder unit, make sure the build menu is close and give the option to open it
                    if (!BuildMenuState || prevUnitSector != SelectedUnit)
                    {
                        buildMenuButton.SetActive(true);
                        BuildMenuState = false;
                    }
                }
                else // if not on a builder unit, then make sure the build menu and open button are hidden
                {
                    buildMenuButton.SetActive(false);
                    BuildMenuState = false;
                }
            }
        }
Example #10
0
        protected override void Update()
        {
            base.Update();

            Coord?fetchCoord = GetSectorAtScreen(Input.mousePosition);

            // build unit highlighting
            if (_currentSecondaryHighlightedSectors.Count > 0)
            {
                foreach (Sector sector in _currentSecondaryHighlightedSectors)
                {
                    if (sector.Highlight == HighlightLevel.Bright)
                    {
                        sector.Highlight = HighlightLevel.Dimmed;
                    }
                }
                _currentSecondaryHighlightedSectors.Clear();
            }
            if (_isBuildingUnit)
            {
                if (fetchCoord.HasValue && Gc.Map.Grid.IsTraversable(fetchCoord.Value) && SelectedRange.Contains(Gc.Map.Grid[fetchCoord.Value]))
                {
                    _currentSecondaryHighlightedSectors.Add(Gc.Map.Grid[fetchCoord.Value]);
                    Gc.Map.Grid[fetchCoord.Value].Highlight = HighlightLevel.Bright;
                }
            }
            else if (SelectedUnit != null)
            {
                if (fetchCoord.HasValue && _selectedUnitLocation.DistanceTo(fetchCoord.Value) <= SelectedUnit.OccupyingUnit.AvailableMove &&
                    Gc.Map.Grid.IsTraversable(fetchCoord.Value))
                {
                    Stack <Coord> path = Gc.Map.Grid.PathFind(_selectedUnitLocation, fetchCoord.Value);
                    Coord         item;
                    int           count = 0;
                    while (count < SelectedUnit.OccupyingUnit.AvailableMove && path.Count > 0)
                    {
                        item = path.Pop();
                        Gc.Map.Grid[item].Highlight = HighlightLevel.Bright;
                        _currentSecondaryHighlightedSectors.Add(Gc.Map.Grid[item]);
                        count++;
                    }
                }
            }
        }