示例#1
0
        public override bool IsAllowedForSquadBuilderPostCheck(SquadList squadList)
        {
            int sameUpgradesInstalled = 0;

            foreach (var ship in squadList.GetShips())
            {
                foreach (var upgrade in ship.Instance.UpgradeBar.GetUpgradesOnlyFaceup())
                {
                    if (upgrade.GetType() == this.GetType())
                    {
                        sameUpgradesInstalled++;
                    }
                }
            }
            ;
            if (sameUpgradesInstalled > 2)
            {
                Messages.ShowError("Cannot have more than 2 Attanni Mindlinks");
            }
            return(sameUpgradesInstalled < 3);
        }
示例#2
0
        public override bool IsAllowedForSquadBuilderPostCheck(SquadList squadList)
        {
            if (squadList.SquadFaction == Faction.Scum)
            {
                return(true);
            }

            if (squadList.SquadFaction == Faction.Rebel)
            {
                if (squadList.HasPilot("Ezra Bridger") || squadList.HasUpgrade("Ezra Bridger"))
                {
                    return(true);
                }
                else
                {
                    Messages.ShowError("Maul cannot be in a Rebel squad that does not contain Ezra Bridger");
                    return(false);
                }
            }

            return(false);
        }
示例#3
0
        public override bool IsAllowedForSquadBuilderPostCheck(SquadList squadList)
        {
            if (squadList.SquadFaction == Faction.Scum)
            {
                return(true);
            }

            if (squadList.SquadFaction == Faction.Imperial)
            {
                if (squadList.HasUpgrade("Darth Vader") || squadList.HasPilot("Darth Vader"))
                {
                    return(true);
                }
                else
                {
                    Messages.ShowError("0-0-0 cannot be in an Imperial squad without Darth Vader");
                    return(false);
                }
            }

            return(false);
        }
示例#4
0
 public virtual bool IsAllowedForSquadBuilderPostCheck(SquadList squadList)
 {
     return(true);
 }
示例#5
0
        public void Changed(ChangeArgs args)
        {
            #region Substitution
            if (args is SubstitutionArgs)
            {
                var subArgs   = (SubstitutionArgs)args;
                var firstSub  = subArgs.FirstSub;
                var secondSub = subArgs.SecondSub;

                switch (args.Type)
                {
                case ChangeType.SubSelected:
                    if (_firstSubstitute == null)
                    {
                        _firstSubstitute = Team.Squad.Find(p => p.Id == firstSub.Id);
                    }
                    else if (firstSub.Id == _firstSubstitute.Id && secondSub == null)
                    {
                        return;
                    }

                    if (secondSub != null)
                    {
                        if (_secondSubstitute == null)
                        {
                            _secondSubstitute = Team.Squad.Find(p => p.Id == secondSub.Id);
                        }
                        else if (secondSub.Id == _secondSubstitute.Id)
                        {
                            return;
                        }
                    }
                    break;

                case ChangeType.SubDeselect:
                    if (firstSub != null)
                    {
                        _firstSubstitute = null;
                    }
                    else if (secondSub != null)
                    {
                        _secondSubstitute = null;
                    }
                    break;

                case ChangeType.SubConfirmed:
                    _firstSubstitute.RotationTeam.Value  = firstSub.Rotation;
                    _secondSubstitute.RotationTeam.Value = secondSub.Rotation;

                    var firstSubIndex  = Substitutions.Contains(_firstSubstitute) ? Substitutions.IndexOf(_firstSubstitute) : Reserves.IndexOf(_firstSubstitute);
                    var secondSubIndex = Substitutions.Contains(_secondSubstitute) ? Substitutions.IndexOf(_secondSubstitute) : Reserves.IndexOf(_secondSubstitute);

                    var firstSubX  = subArgs.secondSubX;
                    var firstSubY  = subArgs.secondSubY;
                    var secondSubX = subArgs.firstSubX;
                    var secondSubY = subArgs.firstSubY;

                    // sub inside 'lineup details'
                    if ((RotationTeam)_firstSubstitute.RotationTeam.Value != RotationTeam.Lineup && (RotationTeam)_secondSubstitute.RotationTeam.Value != RotationTeam.Lineup)
                    {
                        // sub inside same rotation team
                        if ((RotationTeam)_firstSubstitute.RotationTeam.Value == (RotationTeam)_secondSubstitute.RotationTeam.Value)
                        {
                            if (Substitutions.Contains(_firstSubstitute))
                            {
                                Substitutions.RemoveAt(firstSubIndex);
                                Substitutions.Insert(firstSubIndex, _secondSubstitute);
                                Substitutions.RemoveAt(secondSubIndex);
                                Substitutions.Insert(secondSubIndex, _firstSubstitute);
                            }
                            else if (Reserves.Contains(_firstSubstitute))
                            {
                                Reserves.RemoveAt(firstSubIndex);
                                Reserves.Insert(firstSubIndex, _secondSubstitute);
                                Reserves.RemoveAt(secondSubIndex);
                                Reserves.Insert(secondSubIndex, _firstSubstitute);
                            }
                        }
                        // sub between differant rotaion team
                        else if ((RotationTeam)_firstSubstitute.RotationTeam.Value != (RotationTeam)_secondSubstitute.RotationTeam.Value)
                        {
                            if (Substitutions.Contains(_firstSubstitute))
                            {
                                Substitutions.RemoveAt(firstSubIndex);
                                Substitutions.Insert(firstSubIndex, _secondSubstitute);

                                Reserves.RemoveAt(secondSubIndex);
                                Reserves.Insert(secondSubIndex, _firstSubstitute);
                            }
                            else if (Reserves.Contains(_firstSubstitute))
                            {
                                Reserves.RemoveAt(firstSubIndex);
                                Reserves.Insert(firstSubIndex, _secondSubstitute);

                                Substitutions.RemoveAt(secondSubIndex);
                                Substitutions.Insert(secondSubIndex, _firstSubstitute);
                            }
                        }
                    }
                    // sub first sub from 'field details' to second sub in 'lineup details'
                    else if ((RotationTeam)_firstSubstitute.RotationTeam.Value == RotationTeam.Lineup && (RotationTeam)_secondSubstitute.RotationTeam.Value != RotationTeam.Lineup)
                    {
                        if (Substitutions.Contains(_secondSubstitute))
                        {
                            Substitutions.Remove(_secondSubstitute);
                            _firstSubstitute.RotationTeam.Value = RotationTeam.Substitute;
                            Substitutions.Insert(secondSubIndex, _firstSubstitute);
                        }
                        else if (Reserves.Contains(_secondSubstitute))
                        {
                            Reserves.Remove(_secondSubstitute);
                            _firstSubstitute.RotationTeam.Value = RotationTeam.Reserves;
                            Reserves.Insert(secondSubIndex, _firstSubstitute);
                        }

                        _secondSubstitute.X = firstSubX;
                        _secondSubstitute.Y = firstSubY;
                        _firstSubstitute.X  = secondSubX;
                        _firstSubstitute.Y  = secondSubY;
                    }
                    // sub first sub from 'lineup details' to second sub in 'field details'
                    else if ((RotationTeam)_firstSubstitute.RotationTeam.Value != RotationTeam.Lineup && (RotationTeam)_secondSubstitute.RotationTeam.Value == RotationTeam.Lineup)
                    {
                        if (Substitutions.Contains(_firstSubstitute))
                        {
                            Substitutions.Remove(_firstSubstitute);
                            _secondSubstitute.RotationTeam.Value = RotationTeam.Substitute;
                            Substitutions.Insert(firstSubIndex, _secondSubstitute);
                        }
                        else if (Reserves.Contains(_firstSubstitute))
                        {
                            Reserves.Remove(_firstSubstitute);
                            _secondSubstitute.RotationTeam.Value = RotationTeam.Reserves;
                            Reserves.Insert(firstSubIndex, _secondSubstitute);
                        }

                        _firstSubstitute.X  = secondSubX;
                        _firstSubstitute.Y  = secondSubY;
                        _secondSubstitute.X = firstSubX;
                        _secondSubstitute.Y = firstSubY;
                    }

                    Substitutions.RemoveFirstNames();
                    Substitutions.ArrangePositionRoleAsec();
                    Substitutions = new SquadList <SoccerPlayerViewModel>(Substitutions);

                    Reserves.RemoveFirstNames();
                    Reserves.ArrangePositionRoleAsec();
                    Reserves = new SquadList <SoccerPlayerViewModel>(Reserves);

                    // reset subs VM
                    _firstSubstitute.SetIsSelectedBinding(false);
                    _secondSubstitute.SetIsSelectedBinding(false);
                    _firstSubstitute  = null;
                    _secondSubstitute = null;

                    // Also:
                    // recreate TeamDetails & PlayerDetails
                    break;
                }
            }
            #endregion

            #region EditFormation
            if (args is EditFormationArgs)
            {
                var editArgs = (EditFormationArgs)args;
                Substitutions.ForEach(p => p.IsEnabled = !editArgs.IsEditMode);
                Reserves.ForEach(p => p.IsEnabled      = !editArgs.IsEditMode);

                switch (editArgs.Type)
                {
                //case ChangeType.EditFormationModeEnabled:
                //    break;

                case ChangeType.EditFormationModeDisabled:
                    break;
                }
            }
            #endregion
        }