Пример #1
0
        private void CreateProductedUnit()
        {
            RTSUnit unit = (RTSUnit)Entities.Instance.Create(productUnitType, Map.Instance);

            RTSCharacter character = unit as RTSCharacter;

            if (character == null)
            {
                Log.Fatal("RTSBuilding: CreateProductedUnit: character == null");
            }

            GridBasedNavigationSystem navigationSystem = GridBasedNavigationSystem.Instances[0];
            Vec2 p = navigationSystem.GetNearestFreePosition(Position.ToVec2(), character.Type.Radius * 2);

            unit.Position = new Vec3(p.X, p.Y, navigationSystem.GetMotionMapHeight(p) + character.Type.Height * .5f);

            if (Intellect != null)
            {
                unit.InitialFaction = Intellect.Faction;
            }

            unit.PostCreate();
        }
Пример #2
0
 /// <summary>
 /// Implements GridBasedNavigationSystem.IOverrideObjectBehavior
 /// </summary>
 /// <param name="navigationSystem"></param>
 /// <param name="obj"></param>
 /// <param name="rectangles"></param>
 public void GetMotionMapRectanglesForObject(GridBasedNavigationSystem navigationSystem, MapObject obj, List <Rect> rectangles)
 {
     rectangles.Add(new Rect(
                        obj.Position.ToVec2() - new Vec2(Type.Radius, Type.Radius),
                        obj.Position.ToVec2() + new Vec2(Type.Radius, Type.Radius)));
 }
		//

		public GridBasedNavigationSystemFunctionalityArea( GridBasedNavigationSystem system,
			GridBasedNavigationSystemExtendedFunctionalityDescriptor extendedFunctionalityDescriptor )
		{
			this.system = system;
			this.extendedFunctionalityDescriptor = extendedFunctionalityDescriptor;
		}
Пример #4
0
		//

		public GridBasedNavigationSystemExtendedFunctionalityDescriptor( Control parentControl, object owner )
			: base( parentControl, owner )
		{
			system = (GridBasedNavigationSystem)owner;

			int width = parentControl.Size.Width - 16;

			Button button;
			//NumericUpDown numericUpDown;
			//Label label;
			CheckBox checkBox;

			int posY = 8;

			//Update button
			button = new Button();
			parentControl.Controls.Add( button );
			button.Location = new System.Drawing.Point( 8, posY );
			button.Size = new System.Drawing.Size( 120, 32 );
			button.Text = Translate( "Update" );
			button.UseVisualStyleBackColor = true;
			button.Click += delegate( object sender, EventArgs e )
			{
				system.UpdateMotionMap();
			};

			//Path test button
			button = new Button();
			parentControl.Controls.Add( button );
			button.Location = new System.Drawing.Point( 120 + 8 * 2, posY );
			button.Size = new System.Drawing.Size( 120, 32 );
			button.Text = Translate( "Test" );
			button.UseVisualStyleBackColor = true;
			button.Click += new EventHandler( buttonTestPathFind_Click );

			posY += 36;

			////numericUpDownMaxFieldsDistance

			//label = new Label();
			//label.Text = "Test: Max fields distance";
			//label.Location = new System.Drawing.Point( 8, posY ); //posY += 20;
			//label.AutoSize = true;
			//parentControl.Controls.Add( label );

			//numericUpDown = new NumericUpDown();
			//numericUpDownMaxFieldsDistance = numericUpDown;
			//parentControl.Controls.Add( numericUpDown );
			//numericUpDown.Location = new System.Drawing.Point( 8 + label.Size.Width + 8, posY ); posY += 24;
			//numericUpDown.Size = new System.Drawing.Size( 75, numericUpDown.Size.Height );
			//numericUpDown.TextAlign = HorizontalAlignment.Right;
			//numericUpDown.Minimum = 1;
			//numericUpDown.Maximum = 10000000;
			//numericUpDown.Value = 10000000;

			////numericUpDownMaxFieldsToCheck

			//label = new Label();
			//label.Text = "Test: Max fields to check";
			//label.Location = new System.Drawing.Point( 8, posY ); //posY += 20;
			//label.AutoSize = true;
			//parentControl.Controls.Add( label );

			//numericUpDown = new NumericUpDown();
			//numericUpDownMaxFieldsToCheck = numericUpDown;
			//parentControl.Controls.Add( numericUpDown );
			//numericUpDown.Location = new System.Drawing.Point( 8 + label.Size.Width + 8, posY ); posY += 24;
			//numericUpDown.Size = new System.Drawing.Size( 75, numericUpDown.Size.Height );
			//numericUpDown.TextAlign = HorizontalAlignment.Right;
			//numericUpDown.Minimum = 1;
			//numericUpDown.Maximum = 10000000;
			//numericUpDown.Value = 10000000;

			//checkBoxSmooth
			checkBox = new CheckBox();
			checkBoxSmooth = checkBox;
			parentControl.Controls.Add( checkBox );
			checkBox.Location = new System.Drawing.Point( 8, posY );
			checkBox.AutoSize = true;
			checkBox.Text = Translate( "Smooth the path in test mode" );
			checkBox.UseVisualStyleBackColor = true;
			checkBox.Checked = true;

			posY += 26;

			//checkBoxVisualize
			checkBox = new CheckBox();
			checkBoxVisualize = checkBox;
			parentControl.Controls.Add( checkBox );
			checkBox.Location = new System.Drawing.Point( 8, posY );
			checkBox.AutoSize = true;
			checkBox.Text = Translate( "Visualize path finding in test mode" );
			checkBox.UseVisualStyleBackColor = true;
		}
        //

        public GridBasedNavigationSystemFunctionalityArea(GridBasedNavigationSystem system,
                                                          GridBasedNavigationSystemExtendedFunctionalityDescriptor extendedFunctionalityDescriptor)
        {
            this.system = system;
            this.extendedFunctionalityDescriptor = extendedFunctionalityDescriptor;
        }