コード例 #1
0
        public override Activity Tick(Actor self)
        {
            if (IsCanceled || limitedAmmo == null)
            {
                return(NextActivity);
            }

            if (--remainingTicks == 0)
            {
                if (!limitedAmmo.GiveAmmo())
                {
                    return(NextActivity);
                }

                var hostBuilding = self.World.ActorMap.GetUnitsAt(self.Location)
                                   .FirstOrDefault(a => a.HasTrait <RenderBuilding>());

                if (hostBuilding != null)
                {
                    hostBuilding.Trait <RenderBuilding>().PlayCustomAnim(hostBuilding, "active");
                }

                remainingTicks = limitedAmmo.ReloadTimePerAmmo();
            }

            return(this);
        }
コード例 #2
0
ファイル: Rearm.cs プロジェクト: philipbutkiewicz/OpenRA
        public override Activity Tick(Actor self)
        {
            if (IsCanceled || limitedAmmo == null)
            {
                return(NextActivity);
            }

            if (--remainingTicks == 0)
            {
                var hostBuilding = self.World.ActorMap.GetUnitsAt(self.Location)
                                   .FirstOrDefault(a => a.HasTrait <RenderBuilding>());

                if (!limitedAmmo.GiveAmmo())
                {
                    var helicopter = self.TraitOrDefault <Helicopter>();
                    if (helicopter != null)
                    {
                        if (helicopter.Info.RepairBuildings.Contains(hostBuilding.Info.Name) && self.HasTrait <Health>())
                        {
                            if (self.Trait <Health>().DamageState != DamageState.Undamaged)
                            {
                                return(NextActivity);
                            }
                        }

                        return(helicopter.TakeOff(hostBuilding));
                    }

                    return(NextActivity);
                }

                if (hostBuilding != null)
                {
                    hostBuilding.Trait <RenderBuilding>().PlayCustomAnim(hostBuilding, "active");
                }

                remainingTicks = limitedAmmo.ReloadTimePerAmmo();
            }

            return(this);
        }