コード例 #1
0
        /// <summary>
        /// create new squadron
        /// </summary>
        /// <param name="Colonel">unit that will be formation leader</param>
        /// <param name="game">game</param>
        /// <param name="FormationType">formation type to set</param>
        public Squadron(UnitPilot Colonel,IGame game,FormationTypes FormationType)
        {
            isOrdered = true;
            state = States.Nothing;
            neededState = States.Nothing;
            stateChangingTimer = new Timer(0.5f);
            behaviour = Behaviours.Waiting;
            reSortingTimer = new Timer(2);

            List<UnitPilot>  pilots = new List<UnitPilot>();
            switch (FormationType)
            {
                case FormationTypes.Line: formation = new LineFormation(Colonel, pilots, 100, AngleClass.pi * 0.0f); break;
                case FormationTypes.Bar: formation = new BarFormation(Colonel, pilots, 5, 200, 150, 0); break;
                case FormationTypes.Stagger: formation = new StaggerFormation(Colonel, pilots, 90, 120); break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Sets formation type to parametrized stagger
        /// </summary>
        /// <param name="WidthBetweenUnits">Width between two neirbours</param>
        /// <param name="DepthBetweenUnits">Depth between two neirbours</param>
        public void SetFormationTypeStagger(float WidthBetweenUnits, float DepthBetweenUnits)
        {
            isOrdered = true;
            state = States.Nothing;
            neededState = States.Nothing;
            behaviour = Behaviours.Waiting;

            UnitPilot Colonel = formation.Leader;
            List<UnitPilot> pilots = new List<UnitPilot>();
            foreach(UnitPilot pilot in formation)
            { pilots.Add(pilot); }
            formation = new StaggerFormation(Colonel, pilots,WidthBetweenUnits, DepthBetweenUnits);
            //formation.SetAngle(Angle);
        }
コード例 #3
0
        /// <summary>
        /// sets a new formation type
        /// </summary>
        /// <param name="NewType">new formation type</param>
        public void SetFormationType(FormationTypes NewType)
        {
            isOrdered = NewType!= FormationTypes.Swarm;
            state = States.Nothing;
            neededState = States.Nothing;
            behaviour = Behaviours.Waiting;

            UnitPilot Colonel = formation.Leader;
            List<UnitPilot> pilots =new List<UnitPilot>();
            foreach (UnitPilot pilot in formation)
            {                pilots.Add(pilot);            }
            switch (NewType)
            {
                case FormationTypes.Line: formation = new LineFormation(Colonel, pilots, 100, AngleClass.pi * 0.0f); break;
                case FormationTypes.Bar: formation = new BarFormation(Colonel, pilots, 5, 200, 150, 0); break;
                case FormationTypes.Stagger: formation = new StaggerFormation(Colonel, pilots, 90, 120); break;
                case FormationTypes.Swarm: formation = new SwarmFormation(pilots); break;
                //case FormationTypes.Custom: formation = new CustomFormation(pilots,0); break;
            }
        }