Пример #1
0
        public ManeuverTemplate(ManeuverBearing bearing, ManeuverDirection direction, ManeuverSpeed speed, bool isBombTemplate = false, bool isSideTemplate = false)
        {
            Bearing        = bearing;
            Direction      = direction;
            Speed          = speed;
            IsSideTemplate = isSideTemplate;

            string bearingString = bearing.ToString();
            string speedString   = speed.ToString().Replace("Speed", "");

            if (isBombTemplate)
            {
                if (direction == ManeuverDirection.Left)
                {
                    direction = ManeuverDirection.Right;
                }
                else if (direction == ManeuverDirection.Right)
                {
                    direction = ManeuverDirection.Left;
                }
            }

            TemplatePrefabName = bearingString + speedString + ((IsSideTemplate) ? "Alt" : "");

            NameNoDirection = bearingString + " " + speedString;
            string directionString = (direction == ManeuverDirection.Forward) ? "" : " " + direction.ToString();

            Name = NameNoDirection + directionString;
        }
Пример #2
0
        private ManeuverSpeed GetManeuverSpeed(int speed)
        {
            ManeuverSpeed maneuverSpeed = ManeuverSpeed.Speed1;

            switch (speed)
            {
            case 0:
                maneuverSpeed = ManeuverSpeed.Speed0;
                break;

            case 1:
                maneuverSpeed = ManeuverSpeed.Speed1;
                break;

            case 2:
                maneuverSpeed = ManeuverSpeed.Speed2;
                break;

            case 3:
                maneuverSpeed = ManeuverSpeed.Speed3;
                break;

            case 4:
                maneuverSpeed = ManeuverSpeed.Speed4;
                break;

            case 5:
                maneuverSpeed = ManeuverSpeed.Speed5;
                break;
            }

            return(maneuverSpeed);
        }
Пример #3
0
        protected virtual void SkilledBombardierTemplate(List <ManeuverTemplate> availableTemplates, GenericUpgrade upgrade)
        {
            List <ManeuverTemplate> AddedTemplates = new List <ManeuverTemplate>();

            foreach (ManeuverTemplate availableTemplate in availableTemplates)
            {
                ManeuverSpeed    reducedSpeed         = availableTemplate.Speed - 1;
                ManeuverTemplate reducedSpeedTemplate = new ManeuverTemplate(availableTemplate.Bearing, availableTemplate.Direction, reducedSpeed, isBombTemplate: true);
                if (reducedSpeedTemplate.IsValidTemplate() &&
                    !availableTemplates.Any(t => t.Name == reducedSpeedTemplate.Name) &&
                    !AddedTemplates.Any(t => t.Name == reducedSpeedTemplate.Name)
                    )
                {
                    AddedTemplates.Add(reducedSpeedTemplate);
                }

                ManeuverSpeed    increasedSpeed         = availableTemplate.Speed + 1;
                ManeuverTemplate increasedSpeedTemplate = new ManeuverTemplate(availableTemplate.Bearing, availableTemplate.Direction, increasedSpeed, isBombTemplate: true);
                if (increasedSpeedTemplate.IsValidTemplate() &&
                    !availableTemplates.Any(t => t.Name == increasedSpeedTemplate.Name) &&
                    !AddedTemplates.Any(t => t.Name == increasedSpeedTemplate.Name)
                    )
                {
                    AddedTemplates.Add(increasedSpeedTemplate);
                }
            }

            availableTemplates.AddRange(AddedTemplates);
        }
Пример #4
0
        public AfterManeuver(
            ManeuverSpeed minSpeed              = ManeuverSpeed.Speed0,
            ManeuverSpeed maxSpeed              = ManeuverSpeed.Speed5,
            MovementComplexity complexity       = MovementComplexity.None,
            bool onlyIfFullyExecuted            = false,
            bool onlyIfPartialExecuted          = false,
            bool onlyIfMovedThroughFriendlyShip = false,
            ManeuverBearing onlyIfBearing       = ManeuverBearing.None,
            Type hasToken = null
            )
        {
            ManeuverHolder minSpeedHolder = new ManeuverHolder()
            {
                Speed = minSpeed
            };

            MinSpeed = minSpeedHolder.SpeedIntSigned;

            ManeuverHolder maxSpeedHolder = new ManeuverHolder()
            {
                Speed = maxSpeed
            };

            MaxSpeed                       = maxSpeedHolder.SpeedIntSigned;
            Complexity                     = complexity;
            OnlyIfFullyExecuted            = onlyIfFullyExecuted;
            OnlyIfPartialExecuted          = onlyIfPartialExecuted;
            OnlyIfMovedThroughFriendlyShip = onlyIfMovedThroughFriendlyShip;
            OnlyIfBearing                  = onlyIfBearing;
            HasToken                       = hasToken;
        }
Пример #5
0
        public ManeuverHolder(ManeuverSpeed speed, ManeuverDirection direction, ManeuverBearing bearing, MovementComplexity complexity = MovementComplexity.None)
        {
            Speed           = speed;
            Direction       = direction;
            Bearing         = bearing;
            ColorComplexity = complexity;

            shipTag = null;
        }
Пример #6
0
        private void ManeuverDataIsEntered(ManeuverBearing bearing, ManeuverSpeed speed)
        {
            if (TargetShip.AssignedManeuver != null)
            {
                Roster.ToggleManeuverVisibility(TargetShip, true);
            }

            if (TargetShip.AssignedManeuver != null && TargetShip.AssignedManeuver.Bearing == bearing && TargetShip.AssignedManeuver.ManeuverSpeed == speed)
            {
                Messages.ShowInfo("Maneuver is match your guess, you can change own manevuer");
                HostShip.Owner.ChangeManeuver(
                    AfterManeuverIsChanged,
                    Triggers.FinishTrigger,
                    delegate { return(true); }
                    );
            }
            else
            {
                Messages.ShowInfo("Chosen ship has another maneuver");
                Triggers.FinishTrigger();
            }
        }
Пример #7
0
        public MovementStruct(string parameters)
        {
            string[] arrParameters = parameters.Split('.');

            ManeuverSpeed speed = ManeuverSpeed.Speed1;

            switch (arrParameters[0])
            {
            case "0":
                speed = ManeuverSpeed.Speed0;
                break;

            case "1":
                speed = ManeuverSpeed.Speed1;
                break;

            case "2":
                speed = ManeuverSpeed.Speed2;
                break;

            case "3":
                speed = ManeuverSpeed.Speed3;
                break;

            case "4":
                speed = ManeuverSpeed.Speed4;
                break;

            case "5":
                speed = ManeuverSpeed.Speed5;
                break;
            }

            ManeuverDirection direction = ManeuverDirection.Forward;

            switch (arrParameters[1])
            {
            case "F":
                direction = ManeuverDirection.Forward;
                break;

            case "L":
                direction = ManeuverDirection.Left;
                break;

            case "R":
                direction = ManeuverDirection.Right;
                break;
            }

            ManeuverBearing bearing = ManeuverBearing.Straight;

            switch (arrParameters[2])
            {
            case "S":
                bearing = (speed != ManeuverSpeed.Speed0) ? ManeuverBearing.Straight : ManeuverBearing.Stationary;
                break;

            case "R":
                bearing = (direction == ManeuverDirection.Forward) ? ManeuverBearing.KoiogranTurn : ManeuverBearing.SegnorsLoop;
                break;

            case "E":
                bearing = ManeuverBearing.TallonRoll;
                break;

            case "B":
                bearing = ManeuverBearing.Bank;
                break;

            case "T":
                bearing = ManeuverBearing.Turn;
                break;
            }

            Speed     = speed;
            Direction = direction;
            Bearing   = bearing;

            if (!Selection.ThisShip.Maneuvers.ContainsKey(parameters))
            {
                Debug.Log("ERROR: Ship doesn't have required maneuver. Seems that AI maneuver table is wrong.");
            }
            ColorComplexity = Selection.ThisShip.Maneuvers[parameters];
            ColorComplexity = Selection.ThisShip.GetColorComplexityOfManeuver(this);
        }
Пример #8
0
        public MovementStruct(string parameters, Ship.GenericShip ship = null)
        {
            string[] arrParameters = parameters.Split('.');

            ManeuverSpeed speed = ManeuverSpeed.Speed1;

            switch (arrParameters[0])
            {
            case "0":
                speed = ManeuverSpeed.Speed0;
                break;

            case "1":
                speed = ManeuverSpeed.Speed1;
                break;

            case "2":
                speed = ManeuverSpeed.Speed2;
                break;

            case "3":
                speed = ManeuverSpeed.Speed3;
                break;

            case "4":
                speed = ManeuverSpeed.Speed4;
                break;

            case "5":
                speed = ManeuverSpeed.Speed5;
                break;
            }

            ManeuverDirection direction = ManeuverDirection.Forward;

            switch (arrParameters[1])
            {
            case "F":
                direction = ManeuverDirection.Forward;
                break;

            case "L":
                direction = ManeuverDirection.Left;
                break;

            case "R":
                direction = ManeuverDirection.Right;
                break;
            }

            ManeuverBearing bearing = ManeuverBearing.Straight;

            switch (arrParameters[2])
            {
            case "S":
                bearing = (speed != ManeuverSpeed.Speed0) ? ManeuverBearing.Straight : ManeuverBearing.Stationary;
                break;

            case "R":
                bearing = (direction == ManeuverDirection.Forward) ? ManeuverBearing.KoiogranTurn : ManeuverBearing.SegnorsLoop;
                break;

            case "E":
                bearing = ManeuverBearing.TallonRoll;
                break;

            case "B":
                bearing = ManeuverBearing.Bank;
                break;

            case "T":
                bearing = ManeuverBearing.Turn;
                break;
            }

            Speed     = speed;
            Direction = direction;
            Bearing   = bearing;

            ship    = ship ?? Selection.ThisShip;
            shipTag = ship.GetTag();

            if (!ship.Maneuvers.ContainsKey(parameters))
            {
                Console.Write("<b>Ship " + ship.Type + " doesn't have maneuver " + parameters + "</b>", LogTypes.Errors, true, "red");
            }
            ColorComplexity = ship.Maneuvers[parameters];
            ColorComplexity = ship.GetColorComplexityOfManeuver(this);
        }
Пример #9
0
 public ManeuverInfo(ManeuverSpeed speed, ManeuverDirection direction, ManeuverBearing bearing, MovementComplexity complexity)
 {
     Movement   = new ManeuverHolder(speed, direction, bearing);
     Complexity = complexity;
 }
Пример #10
0
        public ManeuverHolder(string parameters, Ship.GenericShip ship = null)
        {
            string[] arrParameters = parameters.Split('.');
            if (arrParameters.Length < 3)
            {
                Messages.ShowError($"Error: maneuverCode is invalid, only {arrParameters.Length} blocks. String: \"{parameters}\"");
            }

            ManeuverSpeed speed = ManeuverSpeed.Speed1;

            switch (arrParameters[0])
            {
            case "0":
                speed = ManeuverSpeed.Speed0;
                break;

            case "1":
                speed = ManeuverSpeed.Speed1;
                break;

            case "2":
                speed = ManeuverSpeed.Speed2;
                break;

            case "3":
                speed = ManeuverSpeed.Speed3;
                break;

            case "4":
                speed = ManeuverSpeed.Speed4;
                break;

            case "5":
                speed = ManeuverSpeed.Speed5;
                break;

            default:
                Messages.ShowError($"Error: Speed in maneuverCode is invalid, \"{arrParameters[0]}\"");
                break;
            }

            ManeuverDirection direction = ManeuverDirection.Forward;

            switch (arrParameters[1])
            {
            case "F":
                direction = ManeuverDirection.Forward;
                break;

            case "L":
                direction = ManeuverDirection.Left;
                break;

            case "R":
                direction = ManeuverDirection.Right;
                break;

            case "S":
                direction = ManeuverDirection.Stationary;
                break;

            default:
                Messages.ShowError($"Error: Direction in maneuverCode is invalid, \"{arrParameters[1]}\"");
                break;
            }

            ManeuverBearing bearing = ManeuverBearing.Straight;

            switch (arrParameters[2])
            {
            case "S":
                bearing = (speed != ManeuverSpeed.Speed0) ? ManeuverBearing.Straight : ManeuverBearing.Stationary;
                break;

            case "R":
                bearing = (direction == ManeuverDirection.Forward) ? ManeuverBearing.KoiogranTurn : ManeuverBearing.SegnorsLoop;
                break;

            case "r":
                bearing = ManeuverBearing.SegnorsLoopUsingTurnTemplate;
                break;

            case "E":
                bearing = ManeuverBearing.TallonRoll;
                break;

            case "B":
                bearing = ManeuverBearing.Bank;
                break;

            case "b":
                bearing = ManeuverBearing.SideslipBank;
                break;

            case "T":
                bearing = ManeuverBearing.Turn;
                break;

            case "t":
                bearing = ManeuverBearing.SideslipTurn;
                break;

            case "V":
                bearing = ManeuverBearing.ReverseStraight;
                break;

            default:
                Messages.ShowError($"Error: Bearing in maneuverCode is invalid, \"{arrParameters[2]}\"");
                break;
            }

            Speed     = speed;
            Direction = direction;
            Bearing   = bearing;

            ship    = ship ?? Selection.ThisShip;
            shipTag = ship.GetTag();

            if (!ship.Maneuvers.ContainsKey(parameters))
            {
                //
            }
            ColorComplexity = ship.Maneuvers[parameters];
            ColorComplexity = ship.GetColorComplexityOfManeuver(this);
        }