示例#1
0
 public Animation(
     AnimationBase animBase,
     bool loopForever,
     bool autoRotate = false,
     int zDimension  = -1,
     Entity parent   = null
     )
 {
     MyBase  = animBase;
     mParent = parent;
     if (MyBase != null)
     {
         mLowerLoop   = animBase.Lower.LoopCount;
         mUpperLoop   = animBase.Upper.LoopCount;
         mLowerTimer  = Globals.System.GetTimeMs() + animBase.Lower.FrameSpeed;
         mUpperTimer  = Globals.System.GetTimeMs() + animBase.Upper.FrameSpeed;
         InfiniteLoop = loopForever;
         AutoRotate   = autoRotate;
         mZDimension  = zDimension;
         mSound       = Audio.AddMapSound(MyBase.Sound, 0, 0, Guid.Empty, loopForever, 0, 12, parent);
         lock (Graphics.AnimationLock)
         {
             Graphics.LiveAnimations.Add(this);
         }
     }
     else
     {
         Dispose();
     }
 }
示例#2
0
        //Sound Functions
        public void CreateMapSounds()
        {
            ClearAttributeSounds();
            for (var x = 0; x < Options.MapWidth; ++x)
            {
                for (var y = 0; y < Options.MapHeight; ++y)
                {
                    var attribute = Attributes?[x, y];
                    if (attribute?.Type != MapAttributes.Sound)
                    {
                        continue;
                    }

                    if (TextUtils.IsNone(((MapSoundAttribute)attribute).File))
                    {
                        continue;
                    }

                    var sound = Audio.AddMapSound(
                        ((MapSoundAttribute)attribute).File, x, y, Id, true, ((MapSoundAttribute)attribute).Distance
                        );

                    AttributeSounds?.Add(sound);
                }
            }
        }
示例#3
0
        //Updating
        public void Update(bool isLocal)
        {
            if (isLocal)
            {
                mLastUpdateTime = Globals.System.GetTimeMs() + 10000;
                UpdateMapAttributes();
                if (BackgroundSound == null && !TextUtils.IsNone(Sound))
                {
                    BackgroundSound = Audio.AddMapSound(Sound, -1, -1, Id, true, 0, 10);
                }

                foreach (var anim in LocalAnimations)
                {
                    if (anim.Value.Disposed())
                    {
                        LocalAnimations.TryRemove(anim.Key, out MapAnimation removed);
                    }
                    else
                    {
                        anim.Value.Update();
                    }
                }

                foreach (var en in LocalEntities)
                {
                    if (en.Value == null)
                    {
                        continue;
                    }

                    en.Value.Update();
                }

                foreach (var critter in mAttributeCritterInstances)
                {
                    if (critter.Value == null)
                    {
                        continue;
                    }

                    critter.Value.Update();
                }

                for (var i = 0; i < LocalEntitiesToDispose.Count; i++)
                {
                    LocalEntities.Remove(LocalEntitiesToDispose[i]);
                }

                LocalEntitiesToDispose.Clear();
            }
            else
            {
                if (Globals.System.GetTimeMs() > mLastUpdateTime)
                {
                    Dispose();
                }

                HideActiveAnimations();
            }
        }