Ejemplo n.º 1
0
 internal void HostilityTarget()
 {
     if (IsHostile && Target == -1)
     {
         Character character = ServerManager.Instance.Sessions.FirstOrDefault(s => s?.Character != null && s.Character.Hp > 0 && !s.Character.InvisibleGm && !s.Character.Invisible && s.Character.MapInstance == MapInstance && Map.GetDistance(new MapCell {
             X = MapX, Y = MapY
         }, new MapCell {
             X = s.Character.PositionX, Y = s.Character.PositionY
         }) < (NoticeRange == 0 ? Monster.NoticeRange : NoticeRange))?.Character;
         if (character != null)
         {
             if (!OnNoticeEvents.Any() && MoveEvent == null)
             {
                 Target = character.CharacterId;
                 if (!Monster.NoAggresiveIcon && LastEffect.AddSeconds(5) < DateTime.Now)
                 {
                     character.Session.SendPacket(GenerateEff(5000));
                 }
             }
             OnNoticeEvents.ForEach(e =>
             {
                 EventHelper.Instance.RunEvent(e, monster: this);
             });
             OnNoticeEvents.RemoveAll(s => s != null);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Hostility on actual Target
        /// </summary>
        internal void HostilityTarget()
        {
            if (!IsHostile || Target != null)
            {
                return;
            }
            IBattleEntity target = MapInstance.BattleEntities.FirstOrDefault(e => e.IsTargetable(SessionType()) && IsFactionTargettable(e.Faction) && Map.GetDistance(GetPos(), e.GetPos()) < (NoticeRange == 0 ? Monster.NoticeRange : NoticeRange));

            if (target == null || MoveEvent != null)
            {
                return;
            }
            if (OnNoticeEvents.Any())
            {
                OnNoticeEvents.ToList().ForEach(e => { EventHelper.Instance.RunEvent(e, monster: this); });
                OnNoticeEvents.Clear();
                return;
            }

            Target = target;
            if (!Monster.NoAggresiveIcon && LastEffect.AddSeconds(5) < DateTime.Now && target.GetSession() is Character character)
            {
                character?.Session.SendPacket(GenerateEff(5000));
            }
        }
Ejemplo n.º 3
0
        private void PopulateMenu()
        {
            DropDownItems.Clear();

            if (EnableRepeatEffectMenuItem && LastEffect != null)
            {
                string      repeatFormat = PdnResources.GetString("Effects.RepeatMenuItem.Format");
                string      menuName     = string.Format(repeatFormat, LastEffect.Name);
                PdnMenuItem pmi          = new PdnMenuItem(menuName, LastEffect.Image, RepeatEffectMenuItem_Click)
                {
                    Name         = "RepeatEffect(" + LastEffect.GetType().FullName + ")",
                    ShortcutKeys = Keys.Control | Keys.F
                };
                DropDownItems.Add(pmi);

                ToolStripSeparator tss = new ToolStripSeparator();
                DropDownItems.Add(tss);
            }

            AddEffectsToMenu();

            Triple <Assembly, Type, Exception>[] errors = Effects.GetLoaderExceptions();

            for (int i = 0; i < errors.Length; ++i)
            {
                AppWorkspace.ReportEffectLoadError(errors[i]);
            }

            MenuPopulated = true;
        }
Ejemplo n.º 4
0
        private void RepeatEffectMenuItem_Click(object sender, EventArgs e)
        {
            Exception         exception = null;
            Effect            effect    = null;
            DocumentWorkspace activeDW  = AppWorkspace.ActiveDocumentWorkspace;

            if (activeDW != null)
            {
                using (new PushNullToolMode(activeDW))
                {
                    Surface copy = activeDW.BorrowScratchSurface(GetType() +
                                                                 ".RepeatEffectMenuItem_Click() utilizing scratch for rendering");

                    try
                    {
                        using (new WaitCursorChanger(AppWorkspace))
                        {
                            copy.CopySurface(((BitmapLayer)activeDW.ActiveLayer).Surface);
                        }

                        PdnRegion selectedRegion = activeDW.Selection.CreateRegion();

                        EffectEnvironmentParameters eep = new EffectEnvironmentParameters(
                            AppWorkspace.AppEnvironment.PrimaryColor,
                            AppWorkspace.AppEnvironment.SecondaryColor,
                            AppWorkspace.AppEnvironment.PenInfo.Width,
                            selectedRegion,
                            copy);

                        effect = (Effect)Activator.CreateInstance(LastEffect.GetType());
                        effect.EnvironmentParameters = eep;

                        EffectConfigToken token = LastEffectToken == null ? null :
                                                  (EffectConfigToken)LastEffectToken.Clone();
                        DoEffect(effect, token, selectedRegion, selectedRegion, copy, out exception);
                    }

                    finally
                    {
                        activeDW.ReturnScratchSurface(copy);
                    }
                }
            }

            if (exception != null)
            {
                HandleEffectException(AppWorkspace, effect, exception);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Validates the preferences.
        /// </summary>
        internal void ValidatePreferences()
        {
            if (x != Int32.MinValue && x < 0)
            {
                x = 0;
            }
            if (y != Int32.MinValue && y < 0)
            {
                y = 0;
            }
            if (w != Int32.MinValue && w < 0)
            {
                w = 800;
            }
            if (h != Int32.MinValue && h < 0)
            {
                h = 480;
            }

            if (SplitterDistanceEffects < 0)
            {
                SplitterDistanceEffects = 0;
            }
            else if (SplitterDistanceEffects > w && w != Int32.MinValue)
            {
                SplitterDistanceEffects = w;
            }

            if (SplitterDistanceOptions < 0)
            {
                SplitterDistanceOptions = 0;
            }
            else if (SplitterDistanceOptions > SplitterDistanceEffects)
            {
                SplitterDistanceOptions = SplitterDistanceEffects;
            }

            if (SplitterDistanceEvents < 0)
            {
                SplitterDistanceEvents = 0;
            }
            if (SplitterDistanceEvents > sevi.that.GetEventsContainerHeight())
            {
                SplitterDistanceEvents = sevi.that.GetEventsContainerHeight();
            }

            if (Scene < 1 || Scene > 3)
            {
                Scene = 1;
            }

            while (FocusTheta < -util.pi2)
            {
                FocusTheta += util.pi2;
            }
            while (FocusTheta > util.pi2)
            {
                FocusTheta -= util.pi2;
            }

            if (FocusPhi < 0f)
            {
                FocusPhi = 0f;
            }
            else if (FocusPhi > util.pi_2)
            {
                FocusPhi = util.pi_2;
            }

            if (Distance < 1f)
            {
                Distance = 1f;
            }
            else if (Distance > 100f)
            {
                Distance = 100f;
            }

            if (FocusPoint_x < 0f || FocusPoint_x > 200f)
            {
                FocusPoint_x = 100f;
            }
            if (FocusPoint_y < 0f || FocusPoint_y > 200f)
            {
                FocusPoint_y = 100f;
            }
            if (FocusPoint_z < 0f || FocusPoint_z > 10f)
            {
                FocusPoint_z = 1f;
            }

            if (SceneDataDelay < 15)
            {
                SceneDataDelay = 15;
            }

            if (SceneData_x != Int32.MinValue && SceneData_x < 0)
            {
                SceneData_x = 0;
            }
            if (SceneData_y != Int32.MinValue && SceneData_y < 0)
            {
                SceneData_y = 0;
            }
            if (SceneData_w != Int32.MinValue && SceneData_w < 0)
            {
                SceneData_w = 455;
            }
            if (SceneData_h != Int32.MinValue && SceneData_h < 0)
            {
                SceneData_h = 725;
            }

            if (AppearanceSource < 0)
            {
                AppearanceSource = 0;
            }
            if (AppearanceTarget < 0)
            {
                AppearanceTarget = 0;
            }

            if (DoubleCharacterDistance < DIST_Min)
            {
                DoubleCharacterDistance = DIST_Min;
            }
            else if (DoubleCharacterDistance > DIST_Max)
            {
                DoubleCharacterDistance = DIST_Max;
            }

            if (LastEffect.Trim() == String.Empty)
            {
                LastEffect = String.Empty;
            }

            // search0..7
        }