Ejemplo n.º 1
0
 /// <summary>
 /// Creates a SCVContinueBuildExecution instance.
 /// </summary>
 /// <param name="recipientSCV">The recipient SCV of this command execution.</param>
 /// <param name="targetPosition">The target position.</param>
 /// <param name="targetBuildingID">The ID of the target building whose construction to be continued.</param>
 public SCVContinueBuildExecution(SCV recipientSCV, RCNumVector targetPosition, int targetBuildingID)
     : base(recipientSCV)
 {
     this.targetBuildingID = this.ConstructField <int>("targetBuildingID");
     this.TargetPosition   = targetPosition;
     this.targetBuildingID.Write(targetBuildingID);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a SCVStopBuildExecution instance.
 /// </summary>
 /// <param name="recipientSCV">The recipient SCV of this command execution.</param>
 public SCVStopBuildExecution(SCV recipientSCV)
     : base(new RCSet <Entity> {
     recipientSCV
 })
 {
     this.recipientSCV = this.ConstructField <SCV>("recipientSCV");
     this.recipientSCV.Write(recipientSCV);
 }
 /// <summary>
 /// Creates a SCVStartBuildExecution instance.
 /// </summary>
 /// <param name="recipientSCV">The recipient SCV of this command execution.</param>
 /// <param name="buildingType">The typename of the building.</param>
 /// <param name="topLeftQuadTile">The coordinates of the top-left quadratic tile of the building to be created.</param>
 public SCVStartBuildExecution(SCV recipientSCV, string buildingType, RCIntVector topLeftQuadTile)
     : base(recipientSCV)
 {
     this.topLeftQuadTile = this.ConstructField <RCIntVector>("topLeftQuadTile");
     this.targetArea      = this.ConstructField <RCNumRectangle>("targetArea");
     this.topLeftQuadTile.Write(topLeftQuadTile);
     this.targetArea.Write(RCNumRectangle.Undefined);
     this.buildingTypeName = buildingType;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a player of the Terran race.
        /// </summary>
        /// <param name="player">The player to be initialized.</param>
        private void TerranInitializer(Player player)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            /// Add a Terran Command Center to the position of the start location.
            Scenario scenario = player.StartLocation.Scenario;
            //Starport commandCenter = new Starport();
            CommandCenter commandCenter = new CommandCenter();

            scenario.AddElementToScenario(commandCenter);
            player.AddBuilding(commandCenter);
            commandCenter.AttachToMap(scenario.Map.GetQuadTile(player.QuadraticStartPosition.Location));

            /// TEST: Add a Terran Comsat Station
            //ComsatStation comsatStation = new ComsatStation();
            //scenario.AddElementToScenario(comsatStation);
            //player.AddAddon(comsatStation);
            //comsatStation.AttachToMap(scenario.Map.GetQuadTile(player.QuadraticStartPosition.Location + new RCIntVector(4, 1)));
            /// TEST END

            /// Find place for the given number of SCVs using an EntityNeighbourhoodIterator.
            EntityNeighbourhoodIterator cellIterator   = new EntityNeighbourhoodIterator(commandCenter);
            IEnumerator <ICell>         cellEnumerator = cellIterator.GetEnumerator();

            for (int scvCount = 0; scvCount < NUM_OF_SCVS; scvCount++)
            {
                /// Create the next SCV
                //Wraith scv = new Wraith();
                SCV scv = new SCV();
                //Unit scv = scvCount % 2 == 0 ? (Unit)new SCV() : (Unit)new Marine();
                scenario.AddElementToScenario(scv);
                player.AddUnit(scv);

                /// Search a place for the new SCV on the map.
                bool scvPlacedSuccessfully = false;
                while (cellEnumerator.MoveNext())
                {
                    if (scv.AttachToMap(cellEnumerator.Current.MapCoords))
                    {
                        scvPlacedSuccessfully = true;
                        break;
                    }
                }

                /// Remove the SCV and stop initializing if there is no more place on the map.
                if (!scvPlacedSuccessfully)
                {
                    player.RemoveUnit(scv);
                    scenario.RemoveElementFromScenario(scv);
                    scv.Dispose();
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        ///<summary>
        /// Returns a single repetition of Time Selection Criteria(APR-1).
        /// throws HL7Exception if the repetition number is invalid.
        /// <param name="rep">The repetition number (this is a repeating field)</param>
        ///</summary>
        public SCV GetTimeSelectionCriteria(int rep)
        {
            SCV ret = null;

            try
            {
                IType t = this.GetField(1, rep);
                ret = (SCV)t;
            } catch (System.Exception ex) {
                HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value.  This is a bug.", ex);
                throw new System.Exception("An unexpected error ocurred", ex);
            }
            return(ret);
        }
Ejemplo n.º 6
0
        void SCV_miningNow(SCV obj)
        {
            if (soundActive)
            {
                casetera.Play(obj.miningSound);
            }

            if (netcm != null)
            {
                //netcm.sendData(new NetInformation(GameStatus.ready, GameCommands.playSound, -1, null, null, obj.miningSound));

                netcm.sendSound(obj.miningSound);
            }
        }
Ejemplo n.º 7
0
        /// <summary> Returns a single repetition of Time Selection Criteria (APR-1).</summary>
        /// <param name="rep">the repetition number (this is a repeating field)
        /// </param>
        /// <throws>  HL7Exception if the repetition number is invalid. </throws>
        public virtual SCV getTimeSelectionCriteria(int rep)
        {
            SCV ret = null;

            try
            {
                Type t = this.getField(1, rep);
                ret = (SCV)t;
            }
            catch (System.InvalidCastException)
            {
                throw new Exception();
            }
            return(ret);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Constructs an SCVBuildExecutionBase instance.
        /// </summary>
        /// <param name="recipientSCV">The recipient SCV of this command execution.</param>
        protected SCVBuildExecutionBase(SCV recipientSCV)
            : base(new RCSet <Entity> {
            recipientSCV
        })
        {
            this.targetPosition = this.ConstructField <RCNumVector>("targetPosition");
            this.recipientSCV   = this.ConstructField <SCV>("recipientSCV");
            this.status         = this.ConstructField <byte>("status");
            this.timeToNextScvMoveDuringConstruction = this.ConstructField <int>("timeToNextScvMoveDuringConstruction");
            this.timeSinceLastDistanceCheck          = this.ConstructField <int>("timeSinceLastDistanceCheck");

            this.targetPosition.Write(RCNumVector.Undefined);
            this.recipientSCV.Write(recipientSCV);
            this.Status = SCVBuildExecutionStatusEnum.MovingToTarget;
            this.timeToNextScvMoveDuringConstruction.Write(0);
            this.timeSinceLastDistanceCheck.Write(0);
        }
        /// <summary>
        /// Attaches the given SCV to this construction job.
        /// </summary>
        /// <param name="scv">The SCV to be attached.</param>
        /// <exception cref="InvalidOperationException">
        /// If this construction job has already an SCV attached to it.
        /// If this construction job is not attached to a Terran building.
        /// </exception>
        public void AttachSCV(SCV scv)
        {
            if (scv == null)
            {
                throw new ArgumentNullException("scv");
            }
            if (this.attachedSCV.Read() != null)
            {
                throw new InvalidOperationException("This construction job has already an SCV attached to it!");
            }
            if (this.constructedBuilding.Read() == null)
            {
                throw new InvalidOperationException("This construction job is not attached to a Terran building!");
            }

            this.attachedSCV.Write(scv);
            this.attachedSCV.Read().OnAttachConstructionJob(this);
        }
Ejemplo n.º 10
0
 ///<summary>
 /// Returns all repetitions of Time Selection Criteria (APR-1).
 ///</summary>
 public SCV[] GetTimeSelectionCriteria()
 {
     SCV[] ret = null;
     try {
         IType[] t = this.GetField(1);
         ret = new SCV[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (SCV)t[i];
         }
     } catch (HL7Exception he) {
         HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value.  This is a bug.", he);
         throw new System.Exception("An unexpected error ocurred", he);
     } catch (System.Exception cce) {
         HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value.  This is a bug.", cce);
         throw new System.Exception("An unexpected error ocurred", cce);
     }
     return(ret);
 }
        /// <summary>
        /// Constructs a TerranBuildingConstructionJob instance.
        /// </summary>
        /// <param name="starterSCV">The SCV to attach to this job automatically when its being started.</param>
        /// <param name="buildingProduct">The type of building to be created by this job.</param>
        /// <param name="topLeftQuadTile">The coordinates of the top-left quadratic tile of the building to be created.</param>
        public TerranBuildingConstructionJob(SCV starterSCV, IBuildingType buildingProduct, RCIntVector topLeftQuadTile)
            : base(starterSCV.Owner, buildingProduct, 0)
        {
            if (starterSCV == null)
            {
                throw new ArgumentNullException("starterSCV");
            }
            if (topLeftQuadTile == RCIntVector.Undefined)
            {
                throw new ArgumentNullException("topLeftQuadTile");
            }

            this.buildingProduct     = buildingProduct;
            this.topLeftQuadTile     = this.ConstructField <RCIntVector>("topLeftQuadTile");
            this.constructedBuilding = this.ConstructField <TerranBuilding>("constructedBuilding");
            this.attachedSCV         = this.ConstructField <SCV>("attachedSCV");
            this.starterSCV          = this.ConstructField <SCV>("starterSCV");
            this.topLeftQuadTile.Write(topLeftQuadTile);
            this.constructedBuilding.Write(null);
            this.starterSCV.Write(starterSCV);
        }
Ejemplo n.º 12
0
 /// <summary> Returns all repetitions of Time Selection Criteria (APR-1).</summary>
 public virtual SCV[] getTimeSelectionCriteria()
 {
     SCV[] ret = null;
     try
     {
         Type[] t = this.getField(1);
         ret = new SCV[t.Length];
         for (int i = 0; i < ret.Length; i++)
         {
             ret[i] = (SCV)t[i];
         }
     }
     catch (System.InvalidCastException)
     {
         throw new Exception();
     }
     catch (NuGenHL7Exception)
     {
         throw new Exception();
     }
     return(ret);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Creates an SCVRepairExecution instance.
        /// </summary>
        /// <param name="recipientSCV">The recipient SCV of this command execution.</param>
        /// <param name="targetPosition">The target position.</param>
        /// <param name="targetEntityID">The ID of the entity to repair.</param>
        public SCVRepairExecution(SCV recipientSCV, RCNumVector targetPosition, int targetEntityID)
            : base(new RCSet <Entity> {
            recipientSCV
        })
        {
            if (targetEntityID == -1)
            {
                throw new ArgumentOutOfRangeException("targetEntityID", "Target entity ID cannot be negative!");
            }

            this.targetPosition     = this.ConstructField <RCNumVector>("targetPosition");
            this.targetEntityID     = this.ConstructField <int>("targetEntityID");
            this.recipientSCV       = this.ConstructField <SCV>("recipientSCV");
            this.targetEntity       = this.ConstructField <Entity>("targetEntity");
            this.timeSinceLastCheck = this.ConstructField <int>("timeSinceLastCheck");
            this.isRepairing        = this.ConstructField <byte>("isRepairing");
            this.targetPosition.Write(targetPosition);
            this.targetEntityID.Write(targetEntityID);
            this.recipientSCV.Write(recipientSCV);
            this.targetEntity.Write(null);
            this.timeSinceLastCheck.Write(0);
            this.isRepairing.Write(0x00);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Creates a building for the given player, attaches it to the given position and starts its construction with the given SCV.
        /// </summary>
        /// <typeparam name="T">The type of the building to be created.</typeparam>
        /// <param name="owner">The owner player of the building.</param>
        /// <param name="topLeftQuadTile">The coordinates of the top-left quadratic tile of the building to be created.</param>
        /// <param name="constructorSCV">The SCV that starts the construction of the building.</param>
        /// <returns>True if the building has been created successfully; otherwise false.</returns>
        private bool CreateBuilding <T>(Player owner, RCIntVector topLeftQuadTile, SCV constructorSCV) where T : TerranBuilding, new()
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }
            if (topLeftQuadTile == RCIntVector.Undefined)
            {
                throw new ArgumentNullException("topLeftQuadTile");
            }
            if (constructorSCV == null)
            {
                throw new ArgumentNullException("constructorSCV");
            }

            /// Create the building.
            T building = new T();

            owner.Scenario.AddElementToScenario(building);
            owner.AddBuilding(building);

            /// Try to attach the building onto the map and start its construction.
            bool buildingPlacedSuccessfully = building.AttachToMap(owner.Scenario.Map.GetQuadTile(topLeftQuadTile), constructorSCV);

            if (buildingPlacedSuccessfully)
            {
                building.Biometrics.Construct();
            }
            else
            {
                owner.RemoveBuilding(building);
                owner.Scenario.RemoveElementFromScenario(building);
                building.Dispose();
            }

            return(buildingPlacedSuccessfully);
        }
Ejemplo n.º 15
0
		/// <summary> Returns all repetitions of Time Selection Criteria (APR-1).</summary>
		public virtual SCV[] getTimeSelectionCriteria()
		{
			SCV[] ret = null;
			try
			{
				Type[] t = this.getField(1);
				ret = new SCV[t.Length];
				for (int i = 0; i < ret.Length; i++)
				{
					ret[i] = (SCV) t[i];
				}
			}
			catch (System.InvalidCastException )
			{
				throw new Exception();
			}
			catch (NuGenHL7Exception)
			{
				throw new Exception();
			}
			return ret;
		}