当前位置: 首页>>代码示例>>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;未经允许,请勿转载。