Example #1
0
        //Animations
        public void AddTileAnimation(Guid animId, int tileX, int tileY, int dir = -1, Entity owner = null)
        {
            var animBase = AnimationBase.Get(animId);

            if (animBase == null)
            {
                return;
            }

            var anim = new MapAnimation(animBase, tileX, tileY, dir, owner);

            LocalAnimations.TryAdd(anim.Id, anim);
            anim.SetPosition(
                GetX() + tileX * Options.TileWidth + Options.TileWidth / 2,
                GetY() + tileY * Options.TileHeight + Options.TileHeight / 2, tileX, tileY, Id, dir
                );
        }
Example #2
0
    public void RegisterAnimation(AnimationBase animation)
    {
        animations.Add(animation);

        DelayedStartCallbackGenerator(
            gameEvent: animation.startEvent,
            startAction: animation.StartAnimation,
            persistant: animation.persistant,
            oneShot: animation.oneShot);

        DelayedStopCallbackGenerator(
            animation: animation,
            gameEvent: animation.endEvent,
            stopAction: animation.EndAnimation,
            persistant: animation.persistant,
            oneShot: animation.oneShot);
    }
Example #3
0
        public override void PlayAnimation(AnimationBase animation, int playCenter, Point offset)
        {
            Canvas canvas;

            if (playCenter == 1)
            {
                canvas = animationCenter1;
            }
            else
            {
                canvas = animationCenter2;
            }

            animation.SetValue(Canvas.LeftProperty, -animation.Width / 2 + offset.X);
            animation.SetValue(Canvas.TopProperty, -animation.Height / 2 + offset.Y);
            canvas.Children.Add(animation);
            animation.Start();
        }
        /// <summary>
        /// Applies the specified animation to a dependency property.
        /// </summary>
        /// <param name="dp">A <see cref="DependencyProperty"/> instance which identifies the dependency property to animate.</param>
        /// <param name="animation">The animation to apply to the dependency property, or <see langword="null"/> to cease animating the property.</param>
        /// <param name="clock">The clock which controls the animation's playback.</param>
        public void Animate(DependencyProperty dp, AnimationBase animation, Clock clock)
        {
            Contract.Require(dp, nameof(dp));

            if (dp.IsReadOnly)
            {
                throw new InvalidOperationException(PresentationStrings.DependencyPropertyIsReadOnly.Format(dp.Name));
            }

            if (animation != null)
            {
                Contract.Require(clock, nameof(clock));
            }

            var wrapper = GetDependencyPropertyValue(dp, dp.PropertyType);

            wrapper.Animate(animation, clock);
        }
Example #5
0
        private void UpdateEditor()
        {
            if (mEditorItem != null)
            {
                pnlContainer.Show();

                txtName.Text          = mEditorItem.Name;
                cmbFolder.Text        = mEditorItem.Folder;
                txtDesc.Text          = mEditorItem.Description;
                cmbType.SelectedIndex = (int)mEditorItem.SpellType;

                nudCastDuration.Value     = mEditorItem.CastDuration;
                nudCooldownDuration.Value = mEditorItem.CooldownDuration;

                cmbCastAnimation.SelectedIndex = AnimationBase.ListIndex(mEditorItem.CastAnimationId) + 1;
                cmbHitAnimation.SelectedIndex  = AnimationBase.ListIndex(mEditorItem.HitAnimationId) + 1;

                chkBound.Checked = mEditorItem.Bound;

                cmbSprite.SelectedIndex = cmbSprite.FindString(TextUtils.NullToNone(mEditorItem.Icon));
                picSpell.BackgroundImage?.Dispose();
                picSpell.BackgroundImage = null;
                if (cmbSprite.SelectedIndex > 0)
                {
                    picSpell.BackgroundImage = Image.FromFile("resources/spells/" + cmbSprite.Text);
                }

                nudHPCost.Value = mEditorItem.VitalCost[(int)Vitals.Health];
                nudMpCost.Value = mEditorItem.VitalCost[(int)Vitals.Mana];

                UpdateSpellTypePanels();
                if (mChanged.IndexOf(mEditorItem) == -1)
                {
                    mChanged.Add(mEditorItem);
                    mEditorItem.MakeBackup();
                }
            }
            else
            {
                pnlContainer.Hide();
            }

            UpdateToolStripItems();
        }
Example #6
0
    public virtual void PlaySingleFrame(string animation, bool lockAnimation = false, AnimationMode mode = AnimationMode.Loop)
    {
        _autoPlay = false;

        if (CurrentAnimation == null ||
            CurrentAnimation.Frames.Count == 0)
        {
            if (DebugMode)
            {
                Debug.LogWarning("There is no current animation to play, test, advance against!");
            }

            return;
        }

        if (string.IsNullOrEmpty(animation))
        {
            animation = CurrentAnimation.Name;
        }

        // If the new animation does not match the current animation,
        // and there is no lock asserted, change animations.
        if (animation != CurrentAnimation.Name &&
            !_isLocked)
        {
            if (DebugMode)
            {
                Debug.Log("No lock; setting lock and animation state.");
            }

            _isLocked         = lockAnimation;
            AnimationMode     = mode;
            PreviousAnimation = CurrentAnimation;
            SetAnimation(animation);
        }

        if (DebugMode)
        {
            Debug.Log(String.Format("Advancing animation {0} to frame {1}...", CurrentAnimation.Name, CurrentAnimation.Current));
        }

        AdvanceCurrentAnimationOne();
    }
Example #7
0
        //Weather
        public void DrawWeather()
        {
            if (Globals.Me == null || Lookup.Get(Globals.Me.CurrentMap) == null)
            {
                return;
            }

            var anim = AnimationBase.Get(WeatherAnimationId);

            if (anim == null || WeatherIntensity == 0)
            {
                return;
            }

            _removeParticles.Clear();

            if ((WeatherXSpeed != 0 || WeatherYSpeed != 0) && Globals.Me.MapInstance == this)
            {
                if (Globals.System.GetTimeMs() > _weatherParticleSpawnTime)
                {
                    _weatherParticles.Add(new WeatherParticle(_removeParticles, WeatherXSpeed, WeatherYSpeed, anim));
                    var spawnTime = 25 + (int)(475 * (float)(1f - (float)(WeatherIntensity / 100f)));
                    spawnTime = (int)(spawnTime *
                                      (480000f /
                                       (Graphics.Renderer.GetScreenWidth() * Graphics.Renderer.GetScreenHeight())));

                    _weatherParticleSpawnTime = Globals.System.GetTimeMs() + spawnTime;
                }
            }

            //Process and draw each weather particle
            foreach (var w in _weatherParticles)
            {
                w.Update();
            }

            //Remove all old particles from the weather particles list from the removeparticles list.
            foreach (var r in _removeParticles)
            {
                r.Dispose();
                _weatherParticles.Remove(r);
            }
        }
Example #8
0
        public void SetAnimation(SpriteAnimations animation, float animationTimeInMS = -1)
        {
            if (animation == SpriteAnimations.NONE)
            {
                if (CurrentAnimation != null)
                {
                    CurrentAnimation.Reset();
                }

                CurrentAnimation = null;
                return;
            }

            var animationToSet = Animations.GetAnimation(animation);

            if (animationToSet != CurrentAnimation)
            {
                // if my animation had callbacks i will still wanna run them
                if (CurrentAnimation?.Callbacks.Count > 0)
                {
                    foreach (var animCallback in CurrentAnimation.Callbacks)
                    {
                        var framesUntilCallback = animCallback.PlayOnFrame - CurrentAnimation.CurrentFrame;
                        animCallback.PlayOnFrame = framesUntilCallback;
                        PendingCallbacks.Add(animCallback);
                    }
                }

                CurrentAnimation?.Reset();
                CurrentAnimation = animationToSet;
                CurrentAnimation.Reset();
                if (animationTimeInMS > 0)
                {
                    //  CurrentAnimation.AnimationTimeInSeconds = animationTimeInMS / 1000;
                }

                if (animation == SpriteAnimations.DEAD)
                {
                    CurrentAnimation.Loop(Direction);
                }
            }
        }
Example #9
0
    public void OnLoadObjCallback(Object target, string path)
    {
        EquipType type;

        if (!GetCurTypeByLoadingIndex(out type))
        {
            return;
        }

        if (!modelPartPath.ContainsKey(type) || !modelPartPath[type].Equals(path))
        {
            return;
        }
        GameObject prefab = target as GameObject;

        if (null == prefab)
        {
            Debug.LogError("Model Asset is null!!!:" + path);
            return;
        }
        GameObject go = GameObject.Instantiate(prefab, modelParent);

        if (type == EquipType.Main)
        {
            model    = go;
            animator = AnimationBase.GetAnimationBase(animationType, go);
            OnModelChange(go);
        }
        else
        {
            Transform tempParent = model.transform.Find(CharaDefine.CharaPartParent[type]);
            if (tempParent != null)
            {
                go.transform.SetParent(tempParent);
                go.transform.localPosition    = Vector3.zero;
                go.transform.localEulerAngles = Vector3.zero;
                go.transform.localScale       = Vector3.one;
            }
        }

        SetParObj(type, go);
    }
        public EventMoveRouteAnimationSelector(
            EventMoveRouteDesigner moveRouteDesigner,
            MoveRouteAction action,
            bool newAction = false
            )
        {
            InitializeComponent();
            cmbAnimation.Items.Clear();
            cmbAnimation.Items.Add(Strings.General.none);
            cmbAnimation.Items.AddRange(AnimationBase.Names);
            if (!newAction)
            {
                cmbAnimation.SelectedIndex = AnimationBase.ListIndex(action.AnimationId) + 1;
            }

            mNewAction     = newAction;
            mRouteDesigner = moveRouteDesigner;
            mMyAction      = action;
            InitLocalization();
        }
Example #11
0
    public override void CreateModel(string path, Transform parent, int type)
    {
        if (null != animator)
        {
            model.SetActive(true);
            return;
        }

        AssetManager.LoadAsset(path, (Object target, string comePath) =>
        {
            GameObject prefab = target as GameObject;
            if (null != prefab)
            {
                GameObject go = GameObject.Instantiate(prefab, parent);
                model         = go;
                animator      = AnimationBase.GetAnimationBase(type, go);
                ChangeTranslucence(0);
            }
        });
    }
Example #12
0
        //Attribute References
        private void UpdateMapAttributes()
        {
            var width  = Options.MapWidth;
            var height = Options.MapHeight;

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    var att = Attributes[x, y];
                    if (att == null)
                    {
                        continue;
                    }

                    if (att.Type != MapAttributes.Animation)
                    {
                        continue;
                    }

                    var anim = AnimationBase.Get(((MapAnimationAttribute)att).AnimationId);
                    if (anim == null)
                    {
                        continue;
                    }

                    if (!mAttributeAnimInstances.ContainsKey(att))
                    {
                        var animInstance = new Animation(anim, true);
                        animInstance.SetPosition(
                            GetX() + x * Options.TileWidth + Options.TileWidth / 2,
                            GetY() + y * Options.TileHeight + Options.TileHeight / 2, x, y, Id, 0
                            );

                        mAttributeAnimInstances.Add(att, animInstance);
                    }

                    mAttributeAnimInstances[att].Update();
                }
            }
        }
        private void UpdateEditor()
        {
            if (mEditorItem != null)
            {
                pnlContainer.Show();

                txtName.Text                      = mEditorItem.Name;
                cmbFolder.Text                    = mEditorItem.Folder;
                cmbToolType.SelectedIndex         = mEditorItem.Tool + 1;
                nudSpawnDuration.Value            = mEditorItem.SpawnDuration;
                cmbAnimation.SelectedIndex        = AnimationBase.ListIndex(mEditorItem.AnimationId) + 1;
                nudMinHp.Value                    = mEditorItem.MinHp;
                nudMaxHp.Value                    = mEditorItem.MaxHp;
                chkWalkableBefore.Checked         = mEditorItem.WalkableBefore;
                chkWalkableAfter.Checked          = mEditorItem.WalkableAfter;
                chkInitialFromTileset.Checked     = mEditorItem.Initial.GraphicFromTileset;
                chkExhaustedFromTileset.Checked   = mEditorItem.Exhausted.GraphicFromTileset;
                cmbEvent.SelectedIndex            = EventBase.ListIndex(mEditorItem.EventId) + 1;
                chkInitialBelowEntities.Checked   = mEditorItem.Initial.RenderBelowEntities;
                chkExhaustedBelowEntities.Checked = mEditorItem.Exhausted.RenderBelowEntities;
                txtCannotHarvest.Text             = mEditorItem.CannotHarvestMessage;

                //Regen
                nudHpRegen.Value = mEditorItem.VitalRegen;
                PopulateInitialGraphicList();
                PopulateExhaustedGraphicList();
                UpdateDropValues();
                Render();
                if (mChanged.IndexOf(mEditorItem) == -1)
                {
                    mChanged.Add(mEditorItem);
                    mEditorItem.MakeBackup();
                }
            }
            else
            {
                pnlContainer.Hide();
            }

            UpdateToolStripItems();
        }
Example #14
0
        public static void Animation(this object o, string name, double n, uint frameCount, Action act = null)
        {
            Type          objType  = o.GetType();
            PropertyInfo  property = objType.GetProperty(name);
            AnimationBase ani      = null;

            if (property != null)
            {
                ani = new AnimationBaseProperty <double>(o, property, n, frameCount, AnimationFunc, act);
            }
            else
            {
                FieldInfo filed = objType.GetField(name);
                if (filed != null)
                {
                    ani = new AnimationBaseField <double>(o, filed, n, frameCount, AnimationFunc, act);
                }
            }

            AddAnimationBase(ani);
        }
Example #15
0
        public GridContainer CreateAnimation(string buttonText, Color boxColor, AnimationBase animationBase)
        {
            BoxView box = null;

            var container = new GridContainer()
            {
                Children =
                {
                    new BoxView()
                    {
                        HeightRequest   = 28,
                        WidthRequest    = 28,
                        BackgroundColor = boxColor
                    }.Assign(out box).Row(0).Col(0),
                    new CoreButton()
                    {
                        Text     = buttonText,
                        Style    = CoreStyles.LightOrange,
                        Triggers =
                        {
                            new EventTrigger()
                            {
                                Event   = "Clicked",
                                Actions =
                                {
                                    new CoreTriggerAction()
                                    {
                                        Animation = animationBase,
                                    }.AssignTarget(box)
                                }
                            }
                        }
                    }.Row(0).Col(1)
                }
            };

            return(container);
        }
Example #16
0
    public static AnimationBase GetAnimationBase(int type, GameObject go)
    {
        ZTAnimationType animationType = ZTAnimationType.Animator;
        AnimationBase   baseAction    = null;

        if (System.Enum.IsDefined(typeof(ZTAnimationType), type))
        {
            animationType = (ZTAnimationType)type;
        }

        switch (animationType)
        {
        case ZTAnimationType.Animation:
            baseAction = new AnimationAction(go);
            break;

        case ZTAnimationType.Animator:
            baseAction = new AnimatorAction(go);
            break;
        }

        return(baseAction);
    }
Example #17
0
            /// <inheritdoc/>
            public void Animate(AnimationBase animation, Clock clock)
            {
                Contract.Require(animation, nameof(animation));
                Contract.Require(clock, nameof(clock));

                if (this.animation == animation && this.animationClock == clock)
                {
                    return;
                }

                var oldValue = GetValue();

                ClearAnimation();

                this.animation            = (Animation <T>)animation;
                this.animationClock       = clock;
                this.animatedValue        = GetInitialAnimatedValue(oldValue);
                this.animatedHandOffValue = oldValue;

                this.animationClock.Subscribe(this);

                UpdateRequiresDigest(oldValue);
            }
Example #18
0
        private void AddProjectileSpawns()
        {
            var spawn    = FindSpawnAnimationData();
            var animBase = AnimationBase.Get(mMyBase.Animations[spawn].AnimationId);

            for (var x = 0; x < ProjectileBase.SPAWN_LOCATIONS_WIDTH; x++)
            {
                for (var y = 0; y < ProjectileBase.SPAWN_LOCATIONS_WIDTH; y++)
                {
                    for (var d = 0; d < ProjectileBase.MAX_PROJECTILE_DIRECTIONS; d++)
                    {
                        if (mMyBase.SpawnLocations[x, y].Directions[d] == true)
                        {
                            var s = new ProjectileSpawns(
                                FindProjectileRotationDir(Dir, d), X + FindProjectileRotationX(Dir, x - 2, y - 2),
                                Y + FindProjectileRotationY(Dir, x - 2, y - 2), Z, CurrentMap, animBase,
                                mMyBase.Animations[spawn].AutoRotate, mMyBase, this
                                );

                            Spawns[mSpawnedAmount] = s;
                            if (Collided(mSpawnedAmount))
                            {
                                Spawns[mSpawnedAmount].Dispose();
                                Spawns[mSpawnedAmount] = null;
                                mSpawnCount--;
                            }

                            mSpawnedAmount++;
                            mSpawnCount++;
                        }
                    }
                }
            }

            mQuantity++;
            mSpawnTime = Globals.System.GetTimeMs() + mMyBase.Delay;
        }
Example #19
0
        public void InitEditor()
        {
            var selectedId  = Guid.Empty;
            var folderNodes = new Dictionary <string, TreeNode>();

            if (lstAnimations.SelectedNode != null && lstAnimations.SelectedNode.Tag != null)
            {
                selectedId = (Guid)lstAnimations.SelectedNode.Tag;
            }

            lstAnimations.Nodes.Clear();

            //Collect folders
            var mFolders = new List <string>();

            foreach (var anim in AnimationBase.Lookup)
            {
                if (!string.IsNullOrEmpty(((AnimationBase)anim.Value).Folder) &&
                    !mFolders.Contains(((AnimationBase)anim.Value).Folder))
                {
                    mFolders.Add(((AnimationBase)anim.Value).Folder);
                    if (!mKnownFolders.Contains(((AnimationBase)anim.Value).Folder))
                    {
                        mKnownFolders.Add(((AnimationBase)anim.Value).Folder);
                    }
                }
            }

            mFolders.Sort();
            mKnownFolders.Sort();
            cmbFolder.Items.Clear();
            cmbFolder.Items.Add("");
            cmbFolder.Items.AddRange(mKnownFolders.ToArray());

            lstAnimations.Sorted = !btnChronological.Checked;

            if (!btnChronological.Checked && !CustomSearch())
            {
                foreach (var folder in mFolders)
                {
                    var node = lstAnimations.Nodes.Add(folder);
                    node.ImageIndex         = 0;
                    node.SelectedImageIndex = 0;
                    folderNodes.Add(folder, node);
                }
            }

            foreach (var itm in AnimationBase.ItemPairs)
            {
                var node = new TreeNode(itm.Value);
                node.Tag                = itm.Key;
                node.ImageIndex         = 1;
                node.SelectedImageIndex = 1;

                var folder = AnimationBase.Get(itm.Key).Folder;
                if (!string.IsNullOrEmpty(folder) && !btnChronological.Checked && !CustomSearch())
                {
                    var folderNode = folderNodes[folder];
                    folderNode.Nodes.Add(node);
                    if (itm.Key == selectedId)
                    {
                        folderNode.Expand();
                    }
                }
                else
                {
                    lstAnimations.Nodes.Add(node);
                }

                if (CustomSearch())
                {
                    if (!node.Text.ToLower().Contains(txtSearch.Text.ToLower()))
                    {
                        node.Remove();
                    }
                }

                if (itm.Key == selectedId)
                {
                    lstAnimations.SelectedNode = node;
                }
            }

            var selectedNode = lstAnimations.SelectedNode;

            if (!btnChronological.Checked)
            {
                lstAnimations.Sort();
            }

            lstAnimations.SelectedNode = selectedNode;
            foreach (var node in mExpandedFolders)
            {
                if (folderNodes.ContainsKey(node))
                {
                    folderNodes[node].Expand();
                }
            }
        }
        /// <summary>
        /// Enlists a dependency property on this object into the specified storyboard instance.
        /// </summary>
        /// <param name="dp">A <see cref="DependencyProperty"/> that identifies the dependency property to enlist.</param>
        /// <param name="storyboardInstance">The <see cref="StoryboardInstance"/> into which to enlist the dependency property.</param>
        /// <param name="animation">The animation to apply to the dependency property.</param>
        internal void EnlistDependencyPropertyInStoryboard(DependencyProperty dp, StoryboardInstance storyboardInstance, AnimationBase animation)
        {
            Contract.Require(dp, nameof(dp));
            Contract.Require(storyboardInstance, nameof(storyboardInstance));
            Contract.Require(animation, nameof(animation));

            if (dp.IsReadOnly)
            {
                throw new InvalidOperationException(PresentationStrings.DependencyPropertyIsReadOnly.Format(dp.Name));
            }

            var wrapper = GetDependencyPropertyValue(dp, dp.PropertyType);

            storyboardInstance.Enlist(wrapper, animation);
        }
Example #21
0
        public void PlaceAttribute(MapBase tmpMap, int x, int y)
        {
            if (rbBlocked.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.Blocked);
            }
            else if (rbItem.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.Item);
                ((MapItemAttribute)tmpMap.Attributes[x, y]).ItemId =
                    ItemBase.IdFromList(cmbItemAttribute.SelectedIndex);

                ((MapItemAttribute)tmpMap.Attributes[x, y]).Quantity = (int)nudItemQuantity.Value;
            }
            else if (rbZDimension.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.ZDimension);
                ((MapZDimensionAttribute)tmpMap.Attributes[x, y]).GatewayTo    = GetEditorDimensionGateway();
                ((MapZDimensionAttribute)tmpMap.Attributes[x, y]).BlockedLevel = GetEditorDimensionBlock();
            }
            else if (rbNPCAvoid.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.NpcAvoid);
            }
            else if (rbWarp.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.Warp);
                ((MapWarpAttribute)tmpMap.Attributes[x, y]).MapId =
                    MapList.OrderedMaps[cmbWarpMap.SelectedIndex].MapId;

                ((MapWarpAttribute)tmpMap.Attributes[x, y]).X         = (byte)nudWarpX.Value;
                ((MapWarpAttribute)tmpMap.Attributes[x, y]).Y         = (byte)nudWarpY.Value;
                ((MapWarpAttribute)tmpMap.Attributes[x, y]).Direction = (WarpDirection)cmbDirection.SelectedIndex;
            }
            else if (rbSound.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.Sound);
                ((MapSoundAttribute)tmpMap.Attributes[x, y]).Distance = (byte)nudSoundDistance.Value;
                ((MapSoundAttribute)tmpMap.Attributes[x, y]).File     = TextUtils.SanitizeNone(cmbMapAttributeSound.Text);
            }
            else if (rbResource.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.Resource);
                ((MapResourceAttribute)tmpMap.Attributes[x, y]).ResourceId =
                    ResourceBase.IdFromList(cmbResourceAttribute.SelectedIndex);

                if (rbLevel1.Checked)
                {
                    ((MapResourceAttribute)tmpMap.Attributes[x, y]).SpawnLevel = 0;
                }
                else
                {
                    ((MapResourceAttribute)tmpMap.Attributes[x, y]).SpawnLevel = 1;
                }
            }
            else if (rbAnimation.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.Animation);
                ((MapAnimationAttribute)tmpMap.Attributes[x, y]).AnimationId =
                    AnimationBase.IdFromList(cmbAnimationAttribute.SelectedIndex);
            }
            else if (rbGrappleStone.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.GrappleStone);
            }
            else if (rbSlide.Checked)
            {
                tmpMap.Attributes[x, y] = MapAttribute.CreateAttribute(MapAttributes.Slide);
                ((MapSlideAttribute)tmpMap.Attributes[x, y]).Direction = (byte)cmbSlideDir.SelectedIndex;
            }
        }
 public MapAnimation(AnimationBase animBase, int tileX, int tileY, int dir, Entity owner = null) : base(animBase, false, false, -1, owner)
 {
     mTileX = tileX;
     mTileY = tileY;
     mDir   = dir;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Enlistment"/> structure.
 /// </summary>
 /// <param name="dpValue">The dependency property which has been enlisted.</param>
 /// <param name="animation">The animation to apply to the dependency property.</param>
 public Enlistment(IDependencyPropertyValue dpValue, AnimationBase animation)
 {
     this.dpValue = dpValue;
     this.animation = animation;
 }
Example #24
0
        public WeatherParticle(List <WeatherParticle> RemoveParticle, int xvelocity, int yvelocity, AnimationBase anim)
        {
            TransmittionTimer = Globals.System.GetTimeMs();
            bounds            = new Rectangle(0, 0, Graphics.Renderer.GetScreenWidth(), Graphics.Renderer.GetScreenHeight());

            xVelocity = xvelocity;
            yVelocity = yvelocity;

            animInstance = new Animation(anim, true, false);
            var animSize = animInstance.AnimationSize();

            partSize = animSize;

            if (xVelocity > 0)
            {
                originalX = Globals.Random.Next(
                    -Graphics.Renderer.GetScreenWidth() / 4 - animSize.X,
                    Graphics.Renderer.GetScreenWidth() + animSize.X
                    );
            }
            else if (xVelocity < 0)
            {
                originalX = Globals.Random.Next(
                    animSize.X, (int)(Graphics.Renderer.GetScreenWidth() * 1.25f) + animSize.X
                    );
            }
            else
            {
                originalX = Globals.Random.Next(-animSize.X, Graphics.Renderer.GetScreenWidth() + animSize.X);
            }

            if (yVelocity > 0)
            {
                originalY = -animSize.Y;
            }
            else if (yVelocity < 0)
            {
                originalY = Graphics.Renderer.GetScreenHeight() + animSize.Y;
            }
            else
            {
                originalY = Globals.Random.Next(-animSize.Y, Graphics.Renderer.GetScreenHeight() + animSize.Y);
                if (xVelocity > 0)
                {
                    originalX = -animSize.X;
                }
                else if (xVelocity < 0)
                {
                    originalX = Graphics.Renderer.GetScreenWidth();
                }
            }

            if (originalX < 0)
            {
                bounds.X      = originalX;
                bounds.Width += Math.Abs(originalX);
            }

            if (originalY < 0)
            {
                bounds.Y       = originalY;
                bounds.Height += Math.Abs(originalY);
            }

            if (originalY > Graphics.Renderer.GetScreenHeight())
            {
                bounds.Height = originalY;
            }

            if (originalX > Graphics.Renderer.GetScreenWidth())
            {
                bounds.Width = originalX;
            }

            bounds.X      -= animSize.X;
            bounds.Width  += animSize.X * 2;
            bounds.Y      -= animSize.Y;
            bounds.Height += animSize.Y * 2;

            X               = originalX;
            Y               = originalY;
            cameraSpawnX    = Graphics.Renderer.GetView().Left;
            cameraSpawnY    = Graphics.Renderer.GetView().Top;
            _RemoveParticle = RemoveParticle;
        }
 private void btnOkay_Click(object sender, EventArgs e)
 {
     mMyAction.AnimationId = AnimationBase.IdFromList(cmbAnimation.SelectedIndex - 1);
     mRouteDesigner.Controls.Remove(this);
 }
 public MapAnimation(AnimationBase animBase, int tileX, int tileY, int dir) : base(animBase, false)
 {
     mTileX = tileX;
     mTileY = tileY;
     mDir   = dir;
 }
Example #27
0
 public void AddAnimation(AnimationBase anim)
 {
     Engine.AddAnimation(anim);
 }
Example #28
0
 private void cmbAttackAnimation_SelectedIndexChanged(object sender, EventArgs e)
 {
     mEditorItem.AttackAnimation =
         AnimationBase.Get(AnimationBase.IdFromList(cmbAttackAnimation.SelectedIndex - 1));
 }
Example #29
0
        private void UpdateEditor()
        {
            if (mEditorItem != null)
            {
                pnlContainer.Show();

                txtName.Text            = mEditorItem.Name;
                cmbFolder.Text          = mEditorItem.Folder;
                cmbSprite.SelectedIndex = cmbSprite.FindString(TextUtils.NullToNone(mEditorItem.Sprite));
                nudLevel.Value          = mEditorItem.Level;
                nudSpawnDuration.Value  = mEditorItem.SpawnDuration;

                //Behavior
                chkAggressive.Checked = mEditorItem.Aggressive;
                if (mEditorItem.Aggressive)
                {
                    btnAttackOnSightCond.Text = Strings.NpcEditor.dontattackonsightconditions;
                }
                else
                {
                    btnAttackOnSightCond.Text = Strings.NpcEditor.attackonsightconditions;
                }

                nudSightRange.Value          = mEditorItem.SightRange;
                cmbMovement.SelectedIndex    = Math.Min(mEditorItem.Movement, cmbMovement.Items.Count - 1);
                chkSwarm.Checked             = mEditorItem.Swarm;
                nudFlee.Value                = mEditorItem.FleeHealthPercentage;
                chkFocusDamageDealer.Checked = mEditorItem.FocusHighestDamageDealer;

                //Common Events
                cmbOnDeathEventKiller.SelectedIndex = EventBase.ListIndex(mEditorItem.OnDeathEventId) + 1;
                cmbOnDeathEventParty.SelectedIndex  = EventBase.ListIndex(mEditorItem.OnDeathPartyEventId) + 1;

                nudStr.Value            = mEditorItem.Stats[(int)Stats.Attack];
                nudMag.Value            = mEditorItem.Stats[(int)Stats.AbilityPower];
                nudDef.Value            = mEditorItem.Stats[(int)Stats.Defense];
                nudMR.Value             = mEditorItem.Stats[(int)Stats.MagicResist];
                nudSpd.Value            = mEditorItem.Stats[(int)Stats.Speed];
                nudHp.Value             = mEditorItem.MaxVital[(int)Vitals.Health];
                nudMana.Value           = mEditorItem.MaxVital[(int)Vitals.Mana];
                nudExp.Value            = mEditorItem.Experience;
                chkAttackAllies.Checked = mEditorItem.AttackAllies;
                chkEnabled.Checked      = mEditorItem.NpcVsNpcEnabled;

                //Combat
                nudDamage.Value                      = mEditorItem.Damage;
                nudCritChance.Value                  = mEditorItem.CritChance;
                nudCritMultiplier.Value              = (decimal)mEditorItem.CritMultiplier;
                nudScaling.Value                     = mEditorItem.Scaling;
                cmbDamageType.SelectedIndex          = mEditorItem.DamageType;
                cmbScalingStat.SelectedIndex         = mEditorItem.ScalingStat;
                cmbAttackAnimation.SelectedIndex     = AnimationBase.ListIndex(mEditorItem.AttackAnimationId) + 1;
                cmbAttackSpeedModifier.SelectedIndex = mEditorItem.AttackSpeedModifier;
                nudAttackSpeedValue.Value            = mEditorItem.AttackSpeedValue;

                //Regen
                nudHpRegen.Value = mEditorItem.VitalRegen[(int)Vitals.Health];
                nudMpRegen.Value = mEditorItem.VitalRegen[(int)Vitals.Mana];

                // Add the spells to the list
                lstSpells.Items.Clear();
                for (var i = 0; i < mEditorItem.Spells.Count; i++)
                {
                    if (mEditorItem.Spells[i] != Guid.Empty)
                    {
                        lstSpells.Items.Add(SpellBase.GetName(mEditorItem.Spells[i]));
                    }
                    else
                    {
                        lstSpells.Items.Add(Strings.General.none);
                    }
                }

                if (lstSpells.Items.Count > 0)
                {
                    lstSpells.SelectedIndex = 0;
                    cmbSpell.SelectedIndex  = SpellBase.ListIndex(mEditorItem.Spells[lstSpells.SelectedIndex]);
                }

                cmbFreq.SelectedIndex = mEditorItem.SpellFrequency;

                // Add the aggro NPC's to the list
                lstAggro.Items.Clear();
                for (var i = 0; i < mEditorItem.AggroList.Count; i++)
                {
                    if (mEditorItem.AggroList[i] != Guid.Empty)
                    {
                        lstAggro.Items.Add(NpcBase.GetName(mEditorItem.AggroList[i]));
                    }
                    else
                    {
                        lstAggro.Items.Add(Strings.General.none);
                    }
                }

                UpdateDropValues();

                DrawNpcSprite();
                if (mChanged.IndexOf(mEditorItem) == -1)
                {
                    mChanged.Add(mEditorItem);
                    mEditorItem.MakeBackup();
                }
            }
            else
            {
                pnlContainer.Hide();
            }

            UpdateToolStripItems();
        }
Example #30
0
 public virtual void PlayAnimation(AnimationBase animation, int playCenter, Point offset)
 {
 }
        public MapAttribute CreateAttribute()
        {
            var attributeType = SelectedMapAttributeType;
            var attribute     = MapAttribute.CreateAttribute(attributeType);

            switch (SelectedMapAttributeType)
            {
            case MapAttributes.Walkable:
            case MapAttributes.Blocked:
            case MapAttributes.GrappleStone:
            case MapAttributes.NpcAvoid:
                break;

            case MapAttributes.Item:
                var itemAttribute = attribute as MapItemAttribute;
                itemAttribute.ItemId   = ItemBase.IdFromList(cmbItemAttribute.SelectedIndex);
                itemAttribute.Quantity = (int)nudItemQuantity.Value;
                break;

            case MapAttributes.ZDimension:
                var zDimensionAttribute = attribute as MapZDimensionAttribute;
                zDimensionAttribute.GatewayTo    = GetEditorDimensionGateway();
                zDimensionAttribute.BlockedLevel = GetEditorDimensionBlock();
                break;

            case MapAttributes.Warp:
                var warpAttribute = attribute as MapWarpAttribute;
                warpAttribute.MapId     = MapList.OrderedMaps[cmbWarpMap.SelectedIndex].MapId;
                warpAttribute.X         = (byte)nudWarpX.Value;
                warpAttribute.Y         = (byte)nudWarpY.Value;
                warpAttribute.Direction = (WarpDirection)cmbDirection.SelectedIndex;
                break;

            case MapAttributes.Sound:
                var soundAttribute = attribute as MapSoundAttribute;
                soundAttribute.Distance     = (byte)nudSoundDistance.Value;
                soundAttribute.File         = TextUtils.SanitizeNone(cmbMapAttributeSound.Text);
                soundAttribute.LoopInterval = (int)nudSoundLoopInterval.Value;
                break;

            case MapAttributes.Resource:
                var resourceAttribute = attribute as MapResourceAttribute;
                resourceAttribute.ResourceId = ResourceBase.IdFromList(cmbResourceAttribute.SelectedIndex);
                resourceAttribute.SpawnLevel = (byte)(rbLevel1.Checked ? 0 : 1);
                break;

            case MapAttributes.Animation:
                var animationAttribute = attribute as MapAnimationAttribute;
                animationAttribute.AnimationId = AnimationBase.IdFromList(cmbAnimationAttribute.SelectedIndex);
                break;

            case MapAttributes.Slide:
                var slideAttribute = attribute as MapSlideAttribute;
                slideAttribute.Direction = (byte)cmbSlideDir.SelectedIndex;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(SelectedMapAttributeType), @"The currently selected attribute type has not been fully implemented.");
            }

            return(attribute);
        }