示例#1
0
        public static void PlayVoiceForOrders(this World w, Order[] orders)
        {
            // Find an actor with a phrase to say
            foreach (var o in orders)
            {
                if (o == null)
                {
                    continue;
                }

                if (o.Subject.Destroyed)
                {
                    continue;
                }

                foreach (var v in o.Subject.TraitsImplementing <IOrderVoice>())
                {
                    if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o),
                                        o.Subject, o.Subject.Owner.Country.Race))
                    {
                        return;
                    }
                }
            }
        }
示例#2
0
        public void Combine(World world, IEnumerable <Actor> newSelection, bool isCombine, bool isClick)
        {
            var oldSelection = actors.AsEnumerable();

            if (isClick)
            {
                var adjNewSelection = newSelection.Take(1);                     /* TODO: select BEST, not FIRST */
                actors = (isCombine ? oldSelection.SymmetricDifference(adjNewSelection) : adjNewSelection).ToList();
            }
            else
            {
                actors = (isCombine ? oldSelection.Union(newSelection) : newSelection).ToList();
            }

            var voicedUnit = actors.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.IsInWorld && a.HasVoices());

            if (voicedUnit != null)
            {
                Sound.PlayVoice("Select", voicedUnit, voicedUnit.Owner.Country.Race);
            }

            foreach (var a in newSelection)
            {
                foreach (var sel in a.TraitsImplementing <INotifySelected>())
                {
                    sel.Selected(a);
                }
            }
            foreach (var ns in world.WorldActor.TraitsImplementing <INotifySelection>())
            {
                ns.SelectionChanged();
            }
        }