當前位置: 首頁>>代碼示例>>C#>>正文


C# Actor.IsAtGroundLevel方法代碼示例

本文整理匯總了C#中Actor.IsAtGroundLevel方法的典型用法代碼示例。如果您正苦於以下問題:C# Actor.IsAtGroundLevel方法的具體用法?C# Actor.IsAtGroundLevel怎麽用?C# Actor.IsAtGroundLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Actor的用法示例。


在下文中一共展示了Actor.IsAtGroundLevel方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Killed

		public void Killed(Actor self, AttackInfo e)
		{
			if (self.Owner.WinState == WinState.Lost || !self.World.Map.Contains(self.Location))
				return;

			foreach (var condition in self.TraitsImplementing<IPreventsEjectOnDeath>())
				if (condition.PreventsEjectOnDeath(self))
					return;

			var r = self.World.SharedRandom.Next(1, 100);

			if (r <= 100 - info.SuccessRate)
				return;

			var cp = self.CenterPosition;
			var inAir = !self.IsAtGroundLevel();
			if ((inAir && !info.EjectInAir) || (!inAir && !info.EjectOnGround))
				return;

			var ge = self.TraitOrDefault<GainsExperience>();
			if ((ge == null || ge.Level == 0) && info.SpawnOnlyWhenPromoted)
				return;

			var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(),
				new TypeDictionary { new OwnerInit(self.Owner), new LocationInit(self.Location) });

			if (ge != null)
			{
				var pge = pilot.TraitOrDefault<GainsExperience>();
				if (pge != null)
				{
					pge.GiveLevels(ge.Level, true);
				}
			}

			if (info.AllowUnsuitableCell || IsSuitableCell(self, pilot))
			{
				if (inAir)
				{
					self.World.AddFrameEndTask(w =>
					{
						w.Add(pilot);
						pilot.QueueActivity(new Parachute(pilot, cp));
					});
					Game.Sound.Play(info.ChuteSound, cp);
				}
				else
				{
					self.World.AddFrameEndTask(w => w.Add(pilot));
					var pilotMobile = pilot.TraitOrDefault<Mobile>();
					if (pilotMobile != null)
						pilotMobile.Nudge(pilot, pilot, true);
				}
			}
			else
				pilot.Dispose();
		}
開發者ID:GraionDilach,項目名稱:OpenRA.Mods.AS,代碼行數:57,代碼來源:EjectOnDeathAS.cs

示例2: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled || !target.IsValidFor(self))
                return NextActivity;

            if (!playedSound && helicopter.Info.TakeoffSound != null && self.IsAtGroundLevel())
            {
                Game.Sound.Play(helicopter.Info.TakeoffSound);
                playedSound = true;
            }

            if (AdjustAltitude(self, helicopter, helicopter.Info.CruiseAltitude))
                return this;

            var pos = target.CenterPosition;

            // Rotate towards the target
            var dist = pos - self.CenterPosition;
            var desiredFacing = dist.HorizontalLengthSquared != 0 ? dist.Yaw.Facing : helicopter.Facing;
            helicopter.Facing = Util.TickFacing(helicopter.Facing, desiredFacing, helicopter.TurnSpeed);
            var move = helicopter.FlyStep(desiredFacing);

            // Inside the minimum range, so reverse
            if (minRange.Length > 0 && target.IsInRange(helicopter.CenterPosition, minRange))
            {
                helicopter.SetPosition(self, helicopter.CenterPosition - move);
                return this;
            }

            // Inside the maximum range, so we're done
            if (maxRange.Length > 0 && target.IsInRange(helicopter.CenterPosition, maxRange))
                return NextActivity;

            // The next move would overshoot, so just set the final position
            if (dist.HorizontalLengthSquared < move.HorizontalLengthSquared)
            {
                var targetAltitude = helicopter.CenterPosition.Z + helicopter.Info.CruiseAltitude.Length - self.World.Map.DistanceAboveTerrain(helicopter.CenterPosition).Length;
                helicopter.SetPosition(self, pos + new WVec(0, 0, targetAltitude - pos.Z));
                return NextActivity;
            }

            helicopter.SetPosition(self, helicopter.CenterPosition + move);

            return this;
        }
開發者ID:CH4Code,項目名稱:OpenRA,代碼行數:45,代碼來源:HeliFly.cs

示例3: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled)
                return NextActivity;

            if (requireSpace && !helicopter.CanLand(self.Location))
                return this;

            if (!playedSound && helicopter.Info.LandingSound != null && !self.IsAtGroundLevel())
            {
                Game.Sound.Play(helicopter.Info.LandingSound);
                playedSound = true;
            }

            if (HeliFly.AdjustAltitude(self, helicopter, helicopter.Info.LandAltitude))
                return this;

            return NextActivity;
        }
開發者ID:CH4Code,項目名稱:OpenRA,代碼行數:19,代碼來源:HeliLand.cs


注:本文中的Actor.IsAtGroundLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。