Esempio n. 1
0
        public Team(string[] args)
        {
            foreach (var arg in args)
            {
                if (arg.ToLower().StartsWith("teamname="))
                {
                    var results = arg.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    m_teamName = results[1];
                }

                if (arg.ToLower().StartsWith("strategy="))
                {
                    var results = arg.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    m_stratgey = (Strategies)Enum.Parse(typeof(Strategies), results[1]);
                }
            }

            if (m_teamName is null)
            {
                m_teamName = SoccerParams.m_teamName;
            }

            m_coach         = new Coach();
            m_teamFormation = new Formation_4_4_2();
            m_playerList    = m_teamFormation.InitTeam(m_stratgey, this, m_coach);
        }
Esempio n. 2
0
        public void ThrowFormationAction(IPlayer specifiedPlayer, IFormation formation)
        {
            EndCountDown();

            var cardBoxes = formation.Cards.Select(p => new CardBox()
            {
                CardCode = p.Code, ImageLocation = GetImgLocation(p.Code)
            }).ToList();

            if (specifiedPlayer == this.Player)
            {
                this.pnlCurrentDesk.CardBoxes = cardBoxes;
                this.pnlRightDesk.RemoveCardBoxes(c => true);
                this.lblCurrentState.Hide();
                this.lblRightPass.Hide();
                this.pnlCurrent.RemoveCardBoxes(c => formation.Cards.Any(p => p.Code == c.CardCode));

                this.btnCurrentTakeOut.Enabled = false;
                this.btnCurrentPassby.Enabled  = false;
            }
            else if (specifiedPlayer == this.PlayerLeft)
            {
                this.pnlLeftDesk.CardBoxes = cardBoxes;
                this.pnlCurrentDesk.RemoveCardBoxes(c => true);
                this.lblCurrentState.Hide();
                this.lblLeftPass.Hide();
            }
            else if (specifiedPlayer == this.PlayerRight)
            {
                this.pnlRightDesk.CardBoxes = cardBoxes;
                this.pnlLeftDesk.RemoveCardBoxes(c => true);
                this.lblRightPass.Hide();
                this.lblLeftPass.Hide();
            }
        }
Esempio n. 3
0
 private void OnUserTakeoutFormation(CircularlyLinkedNode <IPlayer> player, IFormation formation)
 {
     if (UserPrepared != null)
     {
         PlayerTakeoutFormation(this, new PlayerTakeoutFormationEventArgs(player, formation));
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Transfers the formation from an old group to a new one (used only in Portalling).
        /// </summary>
        /// <param name="formation">The formation to transfer.</param>
        /// <param name="expectedCount">The expected group member count.</param>
        /// <param name="oldGroup">The old group to transfer from.</param>
        public void TransferFormation(IFormation formation, int expectedCount, DefaultSteeringTransientUnitGroup oldGroup)
        {
            if (this.count == 0 || expectedCount == 0 || formation == null || oldGroup == null)
            {
                return;
            }

            if (_formationPositions == null)
            {
                // if the formation positions list is null, then make it now
                _formationPositions = new DynamicArray <Vector3>(expectedCount);
            }
            else
            {
                // if the formation positions list is not null, just clear it
                _formationPositions.Clear();
            }

            // set formation reference
            _currentFormation = formation;

            // populate formation positions list with formation positions
            for (int i = 0; i < expectedCount; i++)
            {
                _formationPositions.Add(formation.GetFormationPosition(expectedCount, i, oldGroup[i]));
            }
        }
Esempio n. 5
0
 private void OnUserTakeoutFormation(IFormation formation)
 {
     if (PlayerPrepared != null)
     {
         var e = new GameViewTakeoutFormationEventArgs(this, formation);
         PlayerTakeoutFormation(this, e);
     }
 }
Esempio n. 6
0
        public ActiveFormation(IFormation formation, ICellPosition formationPosition, IToolBox toolBox)
        {
            this.Formation = formation;

            this.Position = formationPosition;
            this.ToolBox  = toolBox;
            this.InitializeInstructions();
        }
Esempio n. 7
0
 public void UpdateTarget(IFormation formation)
 {
     if (CachedAi.DurationNotFollowingTarget > standFor)
     {
         // set a new target
         formation.UpdateBreadcrumbs(CachedAi);
     }
 }
Esempio n. 8
0
        public void Add(IFormation formation)
        {
            foreach (var kvp in formation)
            {
                Add(kvp.Key, kvp.Value);
            }

            OnUnitUpdated();
        }
Esempio n. 9
0
        /// <summary>
        /// Sets a formation for all groups in a grouping.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="grouping">The grouping.</param>
        /// <param name="formation">The formation.</param>
        public static void SetFormation <T>(this IGrouping <T> grouping, IFormation formation) where T : IGroupable <T>
        {
            var groupCount = grouping.groupCount;

            for (int i = 0; i < groupCount; i++)
            {
                grouping[i].SetFormation(formation);
            }
        }
Esempio n. 10
0
        private IFormation GetRandomFormation(IFormation skip)
        {
            var form = skip;

            do
            {
                var idx = Random.Range(0, 6);
                form = GetFormation(idx);
            }while (form.GetType() == skip.GetType());

            return(form);
        }
Esempio n. 11
0
        public void RemoveFromFormation_WhenDoesntHaveFormation_ReturnsFailureAndDoesNotModifyTroop(
            IFormation sourceFormation,
            SimpleStub unitsToRemove,
            SimpleStub troopStub)
        {
            troopStub.AddUnit(FormationType.Normal, 100, 200);

            unitsToRemove.AddUnit(FormationType.Attack, 100, 10);

            troopStub.RemoveFromFormation(FormationType.Attack, unitsToRemove).Should().BeFalse();
            troopStub.TotalCount.Should().Be(200);
        }
Esempio n. 12
0
        public void RemoveFromFormation_WhenTroopHasUnitsButNotInSpecifiedFormation_ReturnsFalseAndDoesNotModifyTroop(
            IFormation sourceFormation,
            SimpleStub unitsToRemove,
            SimpleStub troopStub)
        {
            troopStub.AddUnit(FormationType.Defense, 100, 200);

            unitsToRemove.AddUnit(FormationType.Attack, 100, 150);

            troopStub.RemoveFromFormation(FormationType.Normal, unitsToRemove).Should().BeFalse();
            troopStub[FormationType.Defense][100].Should().Be(200);
        }
Esempio n. 13
0
        private void SetFormation(IFormation formation)
        {
            var selected = GameServices.gameStateManager.unitSelection.selected;

            if (formation != null)
            {
                selected.SetFormation(formation);
            }
            else
            {
                selected.ClearFormation();
            }
        }
Esempio n. 14
0
        public void RemoveFromFormation_WhenSourceHasSameUnitsInDifferentFormationsAndTroopDoesNotHaveEnough_ReturnsFalseAndDoesNotModifyTroop(
            IFormation sourceFormation,
            SimpleStub unitsToRemove,
            SimpleStub troopStub)
        {
            troopStub.AddUnit(FormationType.Normal, 100, 200);

            unitsToRemove.AddUnit(FormationType.Attack, 100, 150);
            unitsToRemove.AddUnit(FormationType.Defense, 100, 150);

            troopStub.RemoveFromFormation(FormationType.Normal, unitsToRemove).Should().BeFalse();
            troopStub[FormationType.Normal][100].Should().Be(200);
        }
Esempio n. 15
0
        public void RemoveFromFormation_WhenSourceHasSameUnitsInDifferentFormationsAndTroopDoesHasEnough_ReturnsTrueAndRemovesUnits(
            IFormation sourceFormation,
            SimpleStub unitsToRemove,
            SimpleStub troopStub)
        {
            troopStub.AddUnit(FormationType.Normal, 100, 310);

            unitsToRemove.AddUnit(FormationType.Attack, 100, 150);
            unitsToRemove.AddUnit(FormationType.Defense, 100, 150);

            troopStub.RemoveFromFormation(FormationType.Normal, unitsToRemove).Should().BeTrue();
            troopStub[FormationType.Normal][100].Should().Be(10);
        }
Esempio n. 16
0
        public void RemoveFromFormation_WhenHasEnoughUnits_ReturnsTrueAndRemovesUnitsFromCorrectFormation(
            IFormation sourceFormation,
            SimpleStub unitsToRemove,
            SimpleStub troopStub)
        {
            troopStub.AddUnit(FormationType.Normal, 100, 200);
            troopStub.AddUnit(FormationType.Normal, 101, 100);

            unitsToRemove.AddUnit(FormationType.Attack, 100, 10);
            unitsToRemove.AddUnit(FormationType.Defense, 101, 10);

            troopStub.RemoveFromFormation(FormationType.Normal, unitsToRemove).Should().BeTrue();
            troopStub[FormationType.Normal][100].Should().Be(190);
            troopStub[FormationType.Normal][101].Should().Be(90);
        }
Esempio n. 17
0
        public Team(string[] args)
        {
            foreach (var arg in args)
            {
                if (arg.ToLower().StartsWith("teamname="))
                {
                    var results = arg.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    m_teamName = results[1];
                }
            }

            if (m_teamName is null)
            {
                m_teamName = SoccerParams.m_teamName;
            }

            m_coach         = new Coach();
            m_teamFormation = new EnglandFormation();
            m_playerList    = m_teamFormation.InitTeam(this, m_coach);
        }
Esempio n. 18
0
        /// <summary>
        /// Sets the currently active formation.
        /// </summary>
        /// <param name="formation">The desired formation.</param>
        public override void SetFormation(IFormation formation)
        {
            if (this.count == 0)
            {
                // no group members, exit early
                return;
            }

            if (_formationPositions == null)
            {
                // if the formation positions list is null, then make it now
                _formationPositions = new DynamicArray <Vector3>(count);
            }
            else
            {
                // if the formation positions list is not null, just clear it
                _formationPositions.Clear();
            }

            if (formation == null)
            {
                // if formation passed was null, treat it as a formation clearing
                _currentFormation = null;
                return;
            }

            // set formation reference
            _currentFormation = formation;

            // prepare the group for movement
            PrepareForAction();

            // populate formation positions list with formation positions
            for (int i = 0; i < count; i++)
            {
                this[i].hasArrivedAtDestination = false;
                _formationPositions.Add(formation.GetFormationPosition(count, i, this[i]));
            }

            SetupFormationIndices();
        }
        private void SetFormation(IFormation formation)
        {
            var selected = GameServices.gameStateManager.unitSelection.selected;

            for (int i = 0; i < selected.groupCount; i++)
            {
                var selectedGroup = selected[i];
                if (selectedGroup == null)
                {
                    continue;
                }

                if (formation != null)
                {
                    selectedGroup.SetFormation(formation);
                }
                else
                {
                    selectedGroup.ClearFormation();
                }
            }
        }
Esempio n. 20
0
 /// <summary>
 /// Sets the currently active formation.
 /// </summary>
 /// <param name="formation">The desired formation.</param>
 public virtual void SetFormation(IFormation formation)
 {
     /* NOOP by default */
 }
        /// <summary>
        /// Transfers the formation from an old group to a new one (used only in Portalling).
        /// </summary>
        /// <param name="formation">The formation to transfer.</param>
        /// <param name="expectedCount">The expected group member count.</param>
        /// <param name="oldGroup">The old group to transfer from.</param>
        public void TransferFormation(IFormation formation, int expectedCount, DefaultSteeringTransientUnitGroup oldGroup)
        {
            if (this.count == 0 || expectedCount == 0 || formation == null || oldGroup == null)
            {
                return;
            }

            if (_formationPositions == null)
            {
                // if the formation positions list is null, then make it now
                _formationPositions = new DynamicArray<Vector3>(expectedCount);
            }
            else
            {
                // if the formation positions list is not null, just clear it
                _formationPositions.Clear();
            }

            // set formation reference
            _currentFormation = formation;

            // populate formation positions list with formation positions
            for (int i = 0; i < expectedCount; i++)
            {
                _formationPositions.Add(formation.GetFormationPosition(expectedCount, i, oldGroup[i]));
            }
        }
Esempio n. 22
0
 public void ExpelFormation(IFormation formation)
 {
     _cards.RemoveAll(p => formation.Cards.Any(f => f.Code == p.Code));
 }
        /// <summary>
        /// Sets the currently active formation.
        /// </summary>
        /// <param name="formation">The desired formation.</param>
        public override void SetFormation(IFormation formation)
        {
            if (this.count == 0)
            {
                // no group members, exit early
                return;
            }

            if (_formationPositions == null)
            {
                // if the formation positions list is null, then make it now
                _formationPositions = new DynamicArray<Vector3>(count);
            }
            else
            {
                // if the formation positions list is not null, just clear it
                _formationPositions.Clear();
            }

            if (formation == null)
            {
                // if formation passed was null, treat it as a formation clearing
                _currentFormation = null;
                return;
            }

            // set formation reference
            _currentFormation = formation;

            // prepare the group for movement
            PrepareForAction();

            // populate formation positions list with formation positions
            for (int i = 0; i < count; i++)
            {
                this[i].hasArrivedAtDestination = false;
                _formationPositions.Add(formation.GetFormationPosition(count, i, this[i]));
            }

            SetupFormationIndices();
        }
Esempio n. 24
0
 public WedgeFormation(IFormation owner)
     : base(owner)
 {
 }
Esempio n. 25
0
 public void UpdateScriptReferences()
 {
     StartPointScript = GetComponent <IStartPoint>();
     SpawnerScript    = GetComponent <ISpawner>();
     FormationScript  = GetComponent <IFormation>();
 }
Esempio n. 26
0
 public RoundInfo(IPlayer player, IFormation formation)
 {
     _player    = player;
     _formation = formation;
 }
Esempio n. 27
0
        private void InitFormation()
        {
 	        switch( _data.Formation )
            {
                case "3er":
                    _formation = new Formation3();
                    break;
                case "10er":
                    _formation = new Formation3();
                    break;
                default:
                    throw new Exception("No formation named " + _data.Formation + " defined");
            }
        }
Esempio n. 28
0
 public override IFormationArrangement Clone(IFormation formation) => (IFormationArrangement) new WedgeFormation(formation);
 public TransposedLineFormation(IFormation owner)
     : base(owner)
 {
     this.IsStaggered    = false;
     this.IsTransforming = true;
 }
Esempio n. 30
0
 private bool TryGetValue(FormationType formationType, out IFormation formation)
 {
     return(Data.TryGetValue(formationType, out formation));
 }
 public override IFormationArrangement Clone(IFormation formation) => (IFormationArrangement) new TransposedLineFormation(formation);
Esempio n. 32
0
        public static void Add(IPlayer player, IFormation formation)
        {
            var round = new RoundInfo(player, formation);

            Add(round);
        }
Esempio n. 33
0
 private static void Clone(ref IFormationArrangement __result, IFormation formation)
 {
     __result = new SkeinFormation(formation);
 }