public void OnAdd()
        {
            var list = new ActionList<mockObject>();
            list.OnAdd += new EventHandler<ActionArgs<mockObject>>((i, args) => { args.Item.Item = 2; });

            var mock = new mockObject { Item = 1 };
            list.Add(mock);
            Assert.AreEqual(2, mock.Item);
        }
Beispiel #2
0
 public override object Clone()
 {
     ActionList list = new ActionList();
     foreach(Action action in this)
     {
         list.Add((Action)action.Clone());
     }
     return list;
 }
Beispiel #3
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ShockTime = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);

            if (!ranged)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                });
                if (damage == 0)
                {
                    return;
                }

                Target.Attacked(this, damage, DefenceType.ACAgility);
            }
            else
            {
                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID
                });
                AttackTime = Envir.Time + AttackSpeed + 500;
                if (damage == 0)
                {
                    return;
                }

                int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step

                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MAC);
                ActionList.Add(action);

                if (Envir.Random.Next(Settings.PoisonResistWeight) >= Target.Stats[Stat.PoisonResist])
                {
                    if (Envir.Random.Next(8) == 0)
                    {
                        if (Info.Effect == 0)
                        {
                            Target.ApplyPoison(new Poison
                            {
                                Owner     = this,
                                Duration  = 5,
                                PType     = PoisonType.Bleeding,
                                TickSpeed = 1000,
                            }, this);
                        }
                        else if (Info.Effect == 1)
                        {
                            Target.ApplyPoison(new Poison
                            {
                                Owner     = this,
                                Duration  = 5,
                                PType     = PoisonType.Slow,
                                TickSpeed = 1000,
                            }, this);
                        }
                    }
                }
            }

            if (Target.Dead)
            {
                FindTarget();
            }
        }
Beispiel #4
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);

            if (Envir.Random.Next(3) > 0)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });
            }
            else
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });

                MirDirection dir = Functions.PreviousDir(Direction);
                Point        target;
                Cell         cell;

                for (int i = 0; i < 4; i++)
                {
                    target = Functions.PointMove(CurrentLocation, Direction, 1);
                    dir    = Functions.NextDir(Direction);
                    if (target == Front)
                    {
                        continue;
                    }

                    if (!CurrentMap.ValidPoint(target))
                    {
                        continue;
                    }

                    cell = CurrentMap.GetCell(target);

                    if (cell.Objects == null)
                    {
                        continue;
                    }

                    for (int o = 0; o < cell.Objects.Count; o++)
                    {
                        MapObject ob = cell.Objects[o];
                        if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                        {
                            continue;
                        }
                        if (!ob.IsAttackTarget(this))
                        {
                            continue;
                        }

                        //ob.Attacked(this, MinDC, DefenceType.ACAgility);

                        DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 350, Target, MinDC, DefenceType.ACAgility);
                        ActionList.Add(action);

                        if (Envir.Random.Next(Settings.PoisonResistWeight) >= ob.PoisonResist)
                        {
                            if (Envir.Random.Next(5) == 0)
                            {
                                ob.ApplyPoison(new Poison {
                                    PType = PoisonType.Stun, Duration = Envir.Random.Next(1, 4), TickSpeed = 1000
                                }, this);
                            }
                        }

                        break;
                    }
                }
            }

            ShockTime  = 0;
            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            int damage = GetAttackPower(MinDC, MaxDC);

            if (damage == 0)
            {
                return;
            }

            Target.Attacked(this, damage, DefenceType.ACAgility);
        }
 public void AddAction(IActionList action)
 {
     ActionList.Add(action);
 }
Beispiel #6
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }
            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            int           damage   = GetAttackPower(MinDC, MaxDC);
            int           distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
            int           delay    = distance * 50 + 500; //50 MS per Step
            DelayedAction action   = null;
            int           rd       = RandomUtils.Next(100);

            if (rd <= 60)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });
                action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage / 3 * 2, DefenceType.None);
                ActionList.Add(action);
                action = new DelayedAction(DelayedType.Damage, Envir.Time + delay + 200, Target, damage, DefenceType.None);
                ActionList.Add(action);
            }
            else if (rd <= 80)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });
                List <MapObject> listtargets = CurrentMap.getMapObjects(CurrentLocation.X, CurrentLocation.Y, 3);
                for (int o = 0; o < listtargets.Count; o++)
                {
                    MapObject ob = listtargets[o];
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                    {
                        continue;
                    }
                    if (!ob.IsAttackTarget(this))
                    {
                        continue;
                    }
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.MAC);
                    ActionList.Add(action);
                }
            }
            else if (rd <= 90)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2
                });
                List <MapObject> listtargets = CurrentMap.getMapObjects(CurrentLocation.X, CurrentLocation.Y, 3);
                for (int o = 0; o < listtargets.Count; o++)
                {
                    MapObject ob = listtargets[o];
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                    {
                        continue;
                    }
                    if (!ob.IsAttackTarget(this))
                    {
                        continue;
                    }
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.MAC);
                    ActionList.Add(action);
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + delay + 300, ob, damage, DefenceType.MAC);
                    ActionList.Add(action);
                }
            }
            else
            {
                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, TargetID = Target.ObjectID, Location = CurrentLocation, Type = 0
                });
                action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MAC);
                ActionList.Add(action);
                if (RandomUtils.Next(Settings.PoisonResistWeight) >= Target.PoisonResist)
                {
                    Target.ApplyPoison(new Poison {
                        Owner = this, Duration = RandomUtils.Next(3, 6), PType = PoisonType.Frozen, Value = damage / 10, TickSpeed = 1000
                    }, this);
                }
            }

            ShockTime  = 0;
            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + (AttackSpeed);
        }
Beispiel #7
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);

            if ((HP * 100 / MaxHP) < 20 && MassAttackTime < Envir.Time)
            {
                ShockTime  = 0;
                ActionTime = Envir.Time + 500;
                AttackTime = Envir.Time + (AttackSpeed);

                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });

                List <MapObject> targets = FindAllTargets(7, CurrentLocation, false);

                if (targets.Count == 0)
                {
                    return;
                }

                int damage = GetAttackPower(MinDC, MaxDC);

                for (int i = 0; i < targets.Count; i++)
                {
                    int delay = Functions.MaxDistance(CurrentLocation, targets[i].CurrentLocation) * 50 + 750; //50 MS per Step

                    DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, targets[i], damage, DefenceType.ACAgility);
                    ActionList.Add(action);
                }

                MassAttackTime = Envir.Time + 2000 + (RandomUtils.Next(5) * 1000);
                ActionTime     = Envir.Time + 800;
                AttackTime     = Envir.Time + (AttackSpeed);
                return;
            }

            if (Functions.InRange(CurrentLocation, Target.CurrentLocation, AttackRange - 1) &&
                RandomUtils.Next(3) == 0)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });
                LineAttack(AttackRange - Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) + 1, true);
            }
            else
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });
                LineAttack(AttackRange);
            }

            ShockTime  = 0;
            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + (AttackSpeed);
        }
Beispiel #8
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ShockTime = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);

            if (Functions.InRange(CurrentLocation, Target.CurrentLocation, 3))
            {
                if (RandomUtils.Next(2) == 0 || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 2))
                {
                    Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                    });

                    int damage = GetAttackPower(MinMC, MaxMC);
                    if (damage == 0)
                    {
                        return;
                    }

                    List <MapObject> targets = FindAllTargets(3, CurrentLocation, false);

                    if (targets.Count == 0)
                    {
                        return;
                    }

                    for (int i = 0; i < targets.Count; i++)
                    {
                        DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, targets[i], damage, DefenceType.MACAgility);
                        ActionList.Add(action);
                    }
                }
                else
                {
                    WalkAway();
                }
            }
            else
            {
                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1
                });

                List <MapObject> targets = FindAllTargets(3, Target.CurrentLocation, false);

                if (targets.Count == 0)
                {
                    return;
                }

                for (int i = 0; i < targets.Count; i++)
                {
                    int damage = GetAttackPower(MinDC, MaxDC);
                    if (damage == 0)
                    {
                        continue;
                    }

                    int delay = Functions.MaxDistance(CurrentLocation, targets[i].CurrentLocation) * 50 + 500; //50 MS per Step

                    DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, targets[i], damage, DefenceType.ACAgility);
                    ActionList.Add(action);
                }
            }


            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + AttackSpeed;

            if (Target.Dead)
            {
                FindTarget();
            }
        }
Beispiel #9
0
 public void RegisterCommand(char symbol, Action <IVirtualMachine> execute)
 {
     ActionList.Add(symbol, execute);
 }
Beispiel #10
0
        private void WideLineAttack()
        {
            int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);

            if (damage == 0)
            {
                return;
            }

            var forward = Functions.PointMove(CurrentLocation, Direction, 1);

            Cell cell = CurrentMap.GetCell(forward);

            if (cell.Objects != null)
            {
                for (int o = 0; o < cell.Objects.Count; o++)
                {
                    MapObject ob = cell.Objects[o];
                    if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player)
                    {
                        if (!ob.IsAttackTarget(this))
                        {
                            continue;
                        }

                        DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, ob, damage, DefenceType.ACAgility);
                        ActionList.Add(action);
                    }
                    else
                    {
                        continue;
                    }

                    break;
                }
            }

            var direction = Functions.PreviousDir(Direction);

            for (int d = 0; d < 3; d++)
            {
                for (int i = 1; i <= 2; i++)
                {
                    Point target = Functions.PointMove(forward, direction, i);

                    if (!CurrentMap.ValidPoint(target))
                    {
                        continue;
                    }

                    cell = CurrentMap.GetCell(target);
                    if (cell.Objects == null)
                    {
                        continue;
                    }

                    for (int o = 0; o < cell.Objects.Count; o++)
                    {
                        MapObject ob = cell.Objects[o];
                        if (ob.Race == ObjectType.Monster || ob.Race == ObjectType.Player)
                        {
                            if (!ob.IsAttackTarget(this))
                            {
                                continue;
                            }

                            int           delay  = Functions.MaxDistance(CurrentLocation, ob.CurrentLocation) * 50 + 500; //50 MS per Step
                            DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, DefenceType.ACAgility);
                            ActionList.Add(action);
                        }
                        else
                        {
                            continue;
                        }

                        break;
                    }
                }

                direction = Functions.NextDir(direction);
            }
        }
Beispiel #11
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this) || NoAttack)
            {
                Target = null;
                return;
            }

            ShockTime = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            bool ranged = CurrentLocation == Target.CurrentLocation || !InAttackRange();

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);

            if (!ranged && Envir.Random.Next(5) > 0)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                });
                if (damage == 0)
                {
                    return;
                }

                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MACAgility);
                ActionList.Add(action);
            }
            else
            {
                AttackTime = Envir.Time + AttackSpeed + 500;
                if (damage == 0)
                {
                    return;
                }

                if (InRangedAttackRange(PoisonAttackRange) && Envir.Random.Next(6) == 0)
                {
                    Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                    });

                    PoisonTarget(Target, 1, 6, PoisonType.Red, 2000);
                }
                else
                {
                    Broadcast(new S.ObjectRangeAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID
                    });

                    DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC);
                    ActionList.Add(action);
                }
            }


            if (Target.Dead)
            {
                FindTarget();
            }
        }
Beispiel #12
0
 private void edit(int idx)
 {
     if (dataGridView1.CurrentCell != null && dataGridView1.CurrentCell.RowIndex >= 0 && dataGridView1.CurrentCell.RowIndex < _dataTable.Rows.Count)
     {
         if (idx == 0)
         {
             Rectangle    rc = dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex, true);
             MathNodeRoot r  = _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][0] as MathNodeRoot;
             r.ScopeMethod = _method;
             r.Project     = _prj;
             dlgMathEditor dlg = new dlgMathEditor(this.Parent.RectangleToScreen(rc));
             dlg.MathExpression = r;
             dlg.SetScopeMethod(_method);
             if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK)
             {
                 r = (MathNodeRoot)dlg.MathExpression;
                 _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][0] = r;
             }
         }
         else
         {
             ActionList        aList = _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][1] as ActionList;
             ILimnorDesignPane pane  = _prj.GetTypedData <ILimnorDesignPane>(_method.ClassId);
             if (aList == null || aList.Count == 0)
             {
                 List <IAction> actList = DesignUtil.SelectAction(pane.Loader, null, null, true, _method, _method.CurrentActionsHolder, this.FindForm());
                 if (actList != null && actList.Count > 0)
                 {
                     aList      = new ActionList();
                     aList.Name = "Actions";                            // actList[0].ToString();
                     foreach (IAction act in actList)
                     {
                         aList.Add(new ActionItem(act));
                     }
                     _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][1] = aList;
                 }
                 else
                 {
                     return;
                 }
             }
             IMethodDialog        imd = this.FindForm() as IMethodDialog;
             MethodDesignerHolder v   = null;
             if (imd != null)
             {
                 v = imd.GetEditor();
             }
             DlgActionList dlg = new DlgActionList();
             dlg.LoadData(aList, _method, _prj, v);
             if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK)
             {
                 aList = dlg.Result;
                 _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][1] = aList;
                 if (v != null)
                 {
                     MethodDiagramViewer mv = v.GetCurrentViewer();
                     foreach (ActionItem a in aList)
                     {
                         if (a.Action != null && a.Action.Changed)
                         {
                             if (!mv.ChangedActions.ContainsKey(a.ActionId))
                             {
                                 mv.ChangedActions.Add(a.ActionId, a.Action);
                             }
                         }
                     }
                 }
             }
             else
             {
                 foreach (ActionItem a in aList)
                 {
                     if (a.Action != null && a.Action.Changed)
                     {
                         a.Action.ReloadFromXmlNode();
                     }
                 }
             }
         }
     }
 }
Beispiel #13
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(9.3968f, -0.7408f, 2.9288f);
            var center   = new vec3(-0.0710f, -2.2829f, 1.3023f);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera);
            var rootNode = new GroupNode();

            this.scene.RootNode = rootNode;

            Texture texBRDF = LoadBRDFTexture();

            texBRDF.TextureUnitIndex = 2;
            Texture prefilterMap = LoadPrefilterMap();

            prefilterMap.TextureUnitIndex = 1;
            Texture irradianceMap = LoadIrradianceMap();

            irradianceMap.TextureUnitIndex = 0;
            Texture envCubemap = LoadEnvCubeMap();
            Texture texHDR     = LoadHDRTexture("environment.hdr");

            {
                var node = CubemapNode.Create(envCubemap, texHDR);
                rootNode.Children.Add(node);
            }
            {
                var node = IrradianceNode.Create(irradianceMap, envCubemap);
                rootNode.Children.Add(node);
            }
            {
                var node = PrefilterNode.Create(prefilterMap, envCubemap);
                rootNode.Children.Add(node);
            }
            {
                var node = BRDFNode.Create(texBRDF);
                rootNode.Children.Add(node);
            }
            {
                var textureGroups = new string[] { "cerberus", "cerberus", "gold", "grass", "plastic", "rock", "rusted_iron", "wall", "wood" };
                var models        = new ObjVNF[textureGroups.Length];
                {
                    var          filename = Path.Combine(System.Windows.Forms.Application.StartupPath, "cerberus.obj_");
                    var          parser   = new ObjVNFParser(false, false);
                    ObjVNFResult result   = parser.Parse(filename);
                    if (result.Error != null)
                    {
                        MessageBox.Show(string.Format("Error: {0}", result.Error));
                        return;
                    }
                    ObjVNFMesh mesh = result.Mesh;
                    // scale it to 0.1 percent.
                    for (int i = 0; i < mesh.vertexes.Length; i++)
                    {
                        mesh.vertexes[i] = mesh.vertexes[i] / 10;
                    }
                    //// Dump texture coordinates' layout.
                    //{
                    //    vec2[] texCoords = mesh.texCoords;
                    //    int polygon = (mesh.faces[0] is ObjVNFTriangle) ? 3 : 4;
                    //    int index = 0;
                    //    var indices = new uint[polygon * mesh.faces.Length];
                    //    foreach (var face in mesh.faces) {
                    //        foreach (var vertexIndex in face.VertexIndexes()) {
                    //            indices[index++] = vertexIndex;
                    //        }
                    //    }
                    //    var bmp = TexCoordAnalyzer.DumpLines(texCoords, indices, 1024);
                    //    bmp.Save("cerberus.texCoords.png");
                    //}
                    var model = new ObjVNF(mesh);
                    models[0] = model;
                }
                {
                    var sphere   = new Sphere2();//(1, 40, 80);
                    var filename = Path.Combine(System.Windows.Forms.Application.StartupPath, "sphere2.obj_");
                    sphere.DumpObjFile(filename, "sphere2");
                    var          parser = new ObjVNFParser(false, true);
                    ObjVNFResult result = parser.Parse(filename);
                    if (result.Error != null)
                    {
                        MessageBox.Show(string.Format("Error: {0}", result.Error));
                        return;
                    }
                    ObjVNFMesh mesh  = result.Mesh;
                    var        model = new ObjVNF(mesh);
                    for (int i = 1; i < textureGroups.Length; i++)
                    {
                        models[i] = model;
                    }
                }

                for (int i = 0; i < textureGroups.Length; i++)
                {
                    ObjVNF model = models[i];
                    string group = textureGroups[i];
                    var    node  = PBRNode.Create(model, model.GetSize(),
                                                  ObjVNF.strPosition, ObjVNF.strTexCoord, ObjVNF.strNormal);
                    node.IrradianceMap = irradianceMap;
                    node.PrefilterMap  = prefilterMap;
                    node.texBRDF       = texBRDF;
                    Texture albedo = GetTexture(string.Format(@"Textures\{0}\albedo.png", group), 3);
                    node.AlbedoMap = albedo;
                    Texture ao = GetTexture(string.Format(@"Textures\{0}\ao.png", group), 4);
                    node.AOMap = ao;
                    Texture metallic = GetTexture(string.Format(@"Textures\{0}\metallic.png", group), 5);
                    node.MetallicMap = metallic;
                    Texture normal = GetTexture(string.Format(@"Textures\{0}\normal.png", group), 6);
                    node.NormalMap = normal;
                    Texture roughness = GetTexture(string.Format(@"Textures\{0}\roughness.png", group), 7);
                    node.RoughnessMap = roughness;
                    if (i == 0)
                    {
                        node.WorldPosition = new vec3(0, -5, 0);
                    }
                    else
                    {
                        node.WorldPosition = new vec3(
                            0.0f,
                            0.0f,
                            ((textureGroups.Length / 2.0f) - i) * spacing);
                    }
                    rootNode.Children.Add(node);
                }
            }
            {
                var backgroundNode = BackgroundNode.Create(envCubemap);
                rootNode.Children.Add(backgroundNode);
            }

            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
        }
Beispiel #14
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }
            int  rd        = RandomUtils.Next(10);
            byte attckType = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            int           damage   = GetAttackPower(MinDC, MaxDC);
            int           distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
            int           delay    = distance * 50 + 750; //50 MS per Step
            DelayedAction action   = null;

            if (distance > 1)//这条线上没有人,才拉,否则不拉
            {
                if (RevivalCount >= LifeCount)
                {
                    if (rd < 7)
                    {
                        attckType = 2;
                    }
                    else
                    {
                        attckType = 3;
                    }
                }
                else
                {
                    if (rd < 7)
                    {
                        attckType = 2;
                    }
                    else
                    {
                        attckType = 1;
                    }
                }
            }
            else
            {
                if (RevivalCount >= LifeCount)
                {
                    if (rd < 7)
                    {
                        attckType = 2;
                    }
                    else
                    {
                        attckType = 3;
                    }
                }
                else
                {
                    if (rd < 7)
                    {
                        attckType = 0;
                    }
                    else
                    {
                        attckType = 1;
                    }
                }
            }

            switch (attckType)
            {
            case 0:    //拳击
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });
                action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.ACAgility);
                ActionList.Add(action);
                break;

            case 1:    //拍击
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });
                action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.ACAgility);
                ActionList.Add(action);
                if (RandomUtils.Next(Settings.PoisonResistWeight) >= Target.PoisonResist)
                {
                    if (RandomUtils.Next(2) == 0)
                    {
                        Target.ApplyPoison(new Poison {
                            PType = PoisonType.Stun, Duration = 8, TickSpeed = 2000
                        }, this);
                    }
                }
                break;

            case 2:    //仗击(半月的范围攻击,1.5倍伤害)
                       //
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2
                });
                List <MapObject> list = CurrentMap.getMapObjects(Target.CurrentLocation.X, Target.CurrentLocation.Y, 1);
                for (int o = 0; o < list.Count; o++)
                {
                    MapObject ob = list[o];
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                    {
                        continue;
                    }
                    if (!ob.IsAttackTarget(this))
                    {
                        continue;
                    }
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage * 14 / 10, DefenceType.None);
                    ActionList.Add(action);
                }
                break;

            case 3:    //唱歌,释放魔法,范围禁锢,麻痹
                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });
                List <MapObject> list2 = CurrentMap.getMapObjects(Target.CurrentLocation.X, Target.CurrentLocation.Y, 2);
                for (int o = 0; o < list2.Count; o++)
                {
                    MapObject ob = list2[o];
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                    {
                        continue;
                    }
                    if (!ob.IsAttackTarget(this))
                    {
                        continue;
                    }
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage * 18 / 10, DefenceType.MAC);
                    ActionList.Add(action);
                    if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist)
                    {
                        if (RandomUtils.Next(10) < 7)
                        {
                            ob.ApplyPoison(new Poison {
                                PType = PoisonType.Paralysis, Duration = 6, TickSpeed = 1000
                            }, this);
                        }
                    }
                }
                break;
            }

            ShockTime  = 0;
            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + (AttackSpeed);
        }
Beispiel #15
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }
            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            int Distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);
            int damage   = GetAttackPower(MinDC, MaxDC);

            attType = 0;
            if (RandomUtils.Next(100) < 30)
            {
                attType = 1;
            }
            if (HP < MaxHP / 3)
            {
                attType = 1;
            }

            DelayedAction action = null;

            if (attType == 1)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });
                List <MapObject> list = FindAllTargets(2, CurrentLocation, false);
                foreach (MapObject ob in list)
                {
                    if (!ob.IsAttackTarget(this))
                    {
                        continue;
                    }
                    //几率冰冻
                    if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist && RandomUtils.Next(3) == 1)
                    {
                        ob.ApplyPoison(new Poison
                        {
                            Owner     = this,
                            Duration  = RandomUtils.Next(5, 10),
                            PType     = PoisonType.Slow,
                            Value     = damage / 3,
                            TickSpeed = 1000
                        }, this);
                    }
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + 200, ob, damage * 2 / 3, DefenceType.MAC);
                    ActionList.Add(action);
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, ob, damage, DefenceType.MAC);
                    ActionList.Add(action);
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + 800, ob, damage * 3 / 2, DefenceType.MAC);
                    ActionList.Add(action);
                }
            }
            else
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });
                action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility);
                ActionList.Add(action);
            }

            ShockTime  = 0;
            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + (AttackSpeed);
        }
Beispiel #16
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ShockTime = 0;

            Direction  = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + AttackSpeed;

            int damage;
            var rnd = Envir.Random.Next(100);

            if (rnd < 10)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2
                });
                damage = GetAttackPower(MinMC, MaxMC);
                if (damage == 0)
                {
                    return;
                }

                AoeDmg(1, damage);
            }
            else if (rnd > 10 && rnd < 40)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });

                damage = GetAttackPower(MinDC, MaxDC);
                if (damage == 0)
                {
                    return;
                }

                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.AC);
                ActionList.Add(action);
                action = new DelayedAction(DelayedType.Damage, Envir.Time + 900, Target, damage, DefenceType.AC);
                ActionList.Add(action);
            }
            else
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });

                damage = GetAttackPower(MinDC, MaxDC);
                if (damage == 0)
                {
                    return;
                }

                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.AC);
                ActionList.Add(action);
            }

            if (Target.Dead)
            {
                FindTarget();
            }
        }
Beispiel #17
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }
            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            int           damage = GetAttackPower(MinDC, MaxDC);
            int           delay  = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 750; //50 MS per Step
            DelayedAction action = null;

            if (HP < MaxHP / 10)
            {
                damage = damage * 3 / 2;
            }
            else if (HP < MaxHP / 4)
            {
                damage = damage * 4 / 3;
            }
            int rd       = RandomUtils.Next(10);
            int Distance = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation);

            if (Distance <= 1)
            {
                if (rd <= 1)
                {
                    attType = 2;
                }
                else if (rd <= 3)
                {
                    attType = 1;
                }
                else
                {
                    attType = 0;
                }
            }
            if (Distance == 2)
            {
                attType = 2;
            }
            if (Distance > 2)
            {
                attType = 3;
            }

            switch (attType)
            {
            case 0:    //撕咬,身前1格
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });
                action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility);
                ActionList.Add(action);
                break;

            case 1:    //拍飞,身前2个,直线距离的,全部击退2格
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });
                LineAttack(2, true);
                break;

            case 2:    //身前1格,拍地板,身前1格位置2*2范围内的攻击,几率眩晕
                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, TargetID = Target.ObjectID, Location = CurrentLocation, Type = 0
                });
                Point            dp   = Functions.PointMove(CurrentLocation, Direction, 1);
                List <MapObject> list = CurrentMap.getMapObjects(dp.X, dp.Y, 2);
                for (int o = 0; o < list.Count; o++)
                {
                    MapObject ob = list[o];
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                    {
                        continue;
                    }
                    if (!ob.IsAttackTarget(this))
                    {
                        continue;
                    }
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, ob, damage * 4 / 3, DefenceType.MAC);
                    ActionList.Add(action);
                    if (RandomUtils.Next(Settings.PoisonResistWeight) >= ob.PoisonResist)
                    {
                        if (RandomUtils.Next(3) == 0)
                        {
                            ob.ApplyPoison(new Poison {
                                Owner = this, Duration = 5, PType = PoisonType.Stun, Value = damage / 2, TickSpeed = 2000
                            }, this);
                        }
                    }
                }
                break;

            case 3:    //吐气攻击,远程攻击7格访问内都攻击到,单点,几率冰冻
                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, TargetID = Target.ObjectID, Location = CurrentLocation, Type = 1
                });
                action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MAC);
                ActionList.Add(action);
                if (RandomUtils.Next(Settings.PoisonResistWeight) >= Target.PoisonResist)
                {
                    if (RandomUtils.Next(3) == 0)
                    {
                        Target.ApplyPoison(new Poison {
                            Owner = this, Duration = 5, PType = PoisonType.Slow, Value = damage / 2, TickSpeed = 2000
                        }, this);
                    }
                    else if (RandomUtils.Next(10) == 0)
                    {
                        Target.ApplyPoison(new Poison {
                            Owner = this, Duration = 3, PType = PoisonType.Frozen, Value = damage / 2, TickSpeed = 2000
                        }, this);
                    }
                }
                //Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1 });
                break;
            }

            ShockTime  = 0;
            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + (AttackSpeed);
        }
Beispiel #18
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ShockTime = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            if (!ranged)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });

                int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
                if (damage == 0)
                {
                    return;
                }

                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.AC);
                ActionList.Add(action);
            }
            else
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });

                var location = Functions.PointMove(CurrentLocation, Direction, 3);

                for (int y = location.Y - 2; y <= location.Y + 2; y++)
                {
                    if (y < 0)
                    {
                        continue;
                    }
                    if (y >= CurrentMap.Height)
                    {
                        break;
                    }

                    for (int x = location.X - 2; x <= location.X + 2; x++)
                    {
                        if (x < 0)
                        {
                            continue;
                        }
                        if (x >= CurrentMap.Width)
                        {
                            break;
                        }

                        var cell = CurrentMap.GetCell(x, y);

                        if (!cell.Valid)
                        {
                            continue;
                        }

                        int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MinDC]);

                        var start = 500;

                        SpellObject ob = new SpellObject
                        {
                            Spell           = Spell.StoneGolemQuake,
                            Value           = damage,
                            ExpireTime      = Envir.Time + 800 + start,
                            TickSpeed       = 1000,
                            Direction       = Direction,
                            CurrentLocation = new Point(x, y),
                            CastLocation    = CurrentLocation,
                            Show            = location.X == x && location.Y == y,
                            CurrentMap      = CurrentMap
                        };

                        Broadcast(new S.MapEffect {
                            Effect = SpellEffect.Tester, Location = new Point(x, y), Value = (byte)Direction
                        });

                        DelayedAction action = new DelayedAction(DelayedType.Spawn, Envir.Time + start, ob);
                        CurrentMap.ActionList.Add(action);
                    }
                }
            }
        }
Beispiel #19
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            AttackTime = Envir.Time + AttackSpeed;
            ShockTime  = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);

            //Charge-Up AOE Rock Fall
            if (_StartAdvanced && Envir.Random.Next(20) == 0)
            {
                byte rockFallLoops    = (byte)Envir.Random.Next(5, 10);
                int  rockFallDuration = rockFallLoops * 500;

                _Immune    = true;
                ActionTime = Envir.Time + (rockFallDuration) + 500;
                AttackTime = Envir.Time + (rockFallDuration) + 500 + AttackSpeed;

                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 3, Level = rockFallLoops
                });

                var front = Functions.PointMove(CurrentLocation, Direction, 2);

                MassSpawnRockFall(front, rockFallDuration);

                int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]) * rockFallLoops;

                DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + (rockFallDuration) + 500, Target, damage, DefenceType.AC, 5);
                ActionList.Add(action);

                return;
            }

            //Charge-Up Spin Hit
            if (_StartAdvanced && Envir.Random.Next(15) == 0)
            {
                byte spinLoops    = (byte)Envir.Random.Next(5, 10);
                int  spinDuration = spinLoops * 700;

                _Immune    = true;
                ActionTime = Envir.Time + spinDuration + 1500;
                AttackTime = Envir.Time + spinDuration + 1500 + AttackSpeed;

                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2, Level = spinLoops
                });

                int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]) * spinLoops;

                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + spinDuration + 500, Target, damage, DefenceType.AC, true);
                ActionList.Add(action);

                action = new DelayedAction(DelayedType.Damage, Envir.Time + spinDuration + 1000, Target, damage, DefenceType.AC, true);
                ActionList.Add(action);

                return;
            }

            //Hammer Smash
            if (_StartAdvanced && Envir.Random.Next(10) == 0)
            {
                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });

                int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
                if (damage == 0)
                {
                    return;
                }

                DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 300, Target, damage, DefenceType.AC, 3);
                ActionList.Add(action);
                return;
            }

            //Teleport
            if (_StartAdvanced && Envir.Random.Next(10) == 0)
            {
                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });

                DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 300);
                ActionList.Add(action);

                return;
            }

            //Normal Attacks
            if (Envir.Random.Next(2) == 0)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                });

                int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
                if (damage == 0)
                {
                    return;
                }

                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, false);
                ActionList.Add(action);
            }
            else
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });

                int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
                if (damage == 0)
                {
                    return;
                }

                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, false);
                ActionList.Add(action);
            }
        }
Beispiel #20
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ShockTime = 0;


            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            Broadcast(new S.ObjectRangeAttack {
                ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID
            });


            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            int damage = GetAttackPower(MinDC, MaxDC);  // into this atk

            if (damage == 0)
            {
                return;
            }
            int boost = 0;

            switch (PetLevel)
            {
            case 1:
                boost = 5;
                break;

            case 2:
                boost = 10;
                break;

            case 3:
                boost = 15;
                break;

            case 4:
                boost = 20;
                break;

            case 5:
                boost = 25;
                break;

            case 6:
                boost = 30;
                break;

            case 7:
                boost = 35;
                break;
            }
            if (boost > 0)
            {
                int tmp = damage * boost / 100;
                damage += tmp;
            }
            long delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step

            List <MapObject> targets = FindAllTargets(1, Target.CurrentLocation, false);

            if (targets.Count > 0)
            {
                for (int i = 0; i < targets.Count; i++)
                {
                    if (targets[i].IsAttackTarget(this))
                    {
                        DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, targets[i], damage, DefenceType.MAC);
                        ActionList.Add(action);
                    }
                }
            }
            else if (CurrentMap.ValidPoint(Target.CurrentLocation))
            {
                Cell cell = CurrentMap.GetCell(Target.CurrentLocation);
                if (cell != null &&
                    cell.Objects != null &&
                    cell.Objects.Count > 0)
                {
                    for (int i = 0; i < cell.Objects.Count; i++)
                    {
                        if (cell.Objects[i].Race != ObjectType.Player &&
                            cell.Objects[i].Race != ObjectType.Monster)
                        {
                            continue;
                        }
                        if (cell.Objects[i].IsAttackTarget(this))
                        {
                            DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, cell.Objects[i], damage, DefenceType.MAC);
                            ActionList.Add(action);
                        }
                    }
                }
            }
            else
            {
                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, Target, damage, DefenceType.MAC);
                ActionList.Add(action);
            }
            if (Target.Dead)
            {
                FindTarget();
            }
        }
Beispiel #21
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;
            ShockTime  = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 2);

            if (!ranged)
            {
                if (Envir.Random.Next(5) > 0)
                {
                    Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                    });

                    int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);

                    PoisonLineAttack(2, damage, DefenceType.ACAgility);
                }
                else
                {
                    Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                    });

                    int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC] * 2);

                    PoisonLineAttack(2, damage, DefenceType.ACAgility, true);
                }
            }
            else
            {
                if (Envir.Random.Next(10) > 0)
                {
                    Broadcast(new S.ObjectRangeAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID
                    });

                    int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);

                    int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step

                    DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.ACAgility, (byte)4);
                    ActionList.Add(action);
                }
                else
                {
                    Broadcast(new S.ObjectRangeAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1
                    });

                    int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC] * 2);

                    DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, (byte)5);
                    ActionList.Add(action);

                    if (damage > 0)
                    {
                        SpawnSlaves();
                    }
                }
            }
        }
Beispiel #22
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            DelayedAction action;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);

            int damage = 0;

            if (ranged)
            {
                if (tornado)
                {
                    Broadcast(new S.ObjectRangeAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0, TargetID = Target.ObjectID
                    });

                    damage = GetAttackPower(MinDC, MaxDC);

                    List <MapObject> targets = FindAllTargets(1, Target.CurrentLocation);

                    for (int i = 0; i < targets.Count; i++)
                    {
                        action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 1000, targets[i], damage, DefenceType.ACAgility);
                        ActionList.Add(action);
                    }

                    ActionTime = Envir.Time + 800;
                    AttackTime = Envir.Time + AttackSpeed;

                    tornado = false;
                    return;
                }
            }

            if (!ranged)
            {
                if (stomp)
                {
                    //Foot stomp
                    Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2
                    });

                    MirDirection dir = Functions.PreviousDir(Direction);
                    Point        tar;
                    Cell         cell;

                    damage = GetAttackPower(MinDC, MaxDC);

                    for (int i = 0; i < 8; i++)
                    {
                        tar = Functions.PointMove(CurrentLocation, dir, 1);
                        dir = Functions.NextDir(dir);

                        if (!CurrentMap.ValidPoint(tar))
                        {
                            continue;
                        }

                        cell = CurrentMap.GetCell(tar);

                        if (cell.Objects == null)
                        {
                            continue;
                        }

                        for (int o = 0; o < cell.Objects.Count; o++)
                        {
                            MapObject ob = cell.Objects[o];
                            if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                            {
                                continue;
                            }
                            if (!ob.IsAttackTarget(this))
                            {
                                continue;
                            }

                            action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.Stomp);
                            ActionList.Add(action);
                            break;
                        }
                    }

                    ActionTime = Envir.Time + 800;
                    AttackTime = Envir.Time + AttackSpeed;

                    stomp = false;
                    return;
                }

                switch (Envir.Random.Next(2))
                {
                case 0:
                    //Slash
                    Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0
                    });

                    damage = GetAttackPower(MinDC, MaxDC);
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash);
                    ActionList.Add(action);

                    damage = GetAttackPower(MinDC, MaxDC);
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash);
                    ActionList.Add(action);
                    break;

                case 1:
                    //Two hand slash
                    Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                    });

                    damage = GetAttackPower(MinDC, MaxDC);
                    action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, AttackType.SingleSlash);
                    ActionList.Add(action);
                    break;
                }

                if (Envir.Random.Next(5) == 0)
                {
                    stomp = true;
                }

                if (Envir.Random.Next(2) == 0)
                {
                    tornado = true;
                }
            }

            ActionTime = Envir.Time + 500;
            AttackTime = Envir.Time + AttackSpeed;
            ShockTime  = 0;
        }
Beispiel #23
0
 public override void Die()
 {
     ActionList.Add(new DelayedAction(DelayedType.Die, Envir.Time + 500));
     base.Die();
 }
Beispiel #24
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ShockTime = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 2);

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            /* Energy Shield Logic:
               When mob gets to certain health percentages (i.e. 80% / 60% / 40% / 20%) active Energy Shield.
               Whilst Energy Shield is active the following happen:
                    - This monsters damage taken is reduced (50% reduction?)
                    - Every 'x' amount of seconds all players in range are attacked with a thunderbolt
             */

            var hpPercent = (HP * 100) / Stats[Stat.HP];

            bool stage1Bubble = hpPercent >= 70 && hpPercent <= 80;//HP < Stats[Stat.HP] / 10 * 8 && this.HP > Stats[Stat.HP] / 10 * 7;
            bool stage2Bubble = hpPercent >= 40 && hpPercent <= 50;//HP < Stats[Stat.HP] / 10 * 5 && this.HP > Stats[Stat.HP] / 10 * 4;
            bool stage3Bubble = hpPercent <= 20; //this.HP < Stats[Stat.HP] / 10 * 2 && this.HP > 1;

            if (stage1Bubble == true || stage2Bubble == true || stage3Bubble == true)
            {
                if (Target != null)
                {
                    var stats = new Stats
                    {
                        [Stat.MaxAC] = 100,
                        [Stat.MinAC] = 100
                    };

                    AddBuff(BuffType.GeneralMeowMeowShield, this, ShieldUpDuration, stats, visible: true);                 

                    if (Envir.Time > ThunderAttackTime)
                    {
                        MassThunderAttack();
                    }

                    OperateTime = 0;                    
                }
            }

            if (!ranged)
            {
                if (Envir.Random.Next(9) != 0)
                {
                    Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 0 });
                    int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
                    if (damage == 0) return;

                    DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, false);
                    ActionList.Add(action);
                }
                else
                {
                    Broadcast(new S.ObjectAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1 });
                    int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]) * 3;
                    if (damage == 0) return;

                    DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.AC, true);
                    ActionList.Add(action);
                }
            }
            else
            {
                Broadcast(new S.ObjectRangeAttack { ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0 });
                int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
                if (damage == 0) return;

                DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MACAgility);
                ActionList.Add(action);
            }
        }
Beispiel #25
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            var position = new vec3(5, 6, 4) * 3;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            this.scene = new Scene(camera);

            //(new FormTree(scene)).Show();

            this.scene.RootNode = new GroupNode();
            {
                var axisNode = AxisNode.Create();
                axisNode.Scale = new vec3(1, 1, 1) * 30;
                this.scene.RootNode.Children.Add(axisNode);
            }

            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            this.pickingAction = new Picking(scene);

            //this.triangleTip = new LegacyTriangleNode();
            //this.quadTip = new LegacyQuadNode();
            this.tipNode = HighlightGeometryNode.Create();

            var manipulater = new FirstPerspectiveManipulater();

            manipulater.Bind(camera, this.winGLCanvas1);
            {
                ObjItem[] items = HanoiTower.GetDataSource();
                for (int i = 0; i < items.Length; i++)
                {
                    var item     = items[i];
                    var filename = "item" + (i) + ".obj";
                    item.model.DumpObjFile(filename, "item" + (i));
                    var          parser = new ObjVNFParser(false);
                    ObjVNFResult result = parser.Parse(filename);
                    if (result.Error != null)
                    {
                        //Console.WriteLine("Error: {0}", result.Error);
                    }
                    else
                    {
                        ObjVNFMesh mesh = result.Mesh;
                        var        node = ObjVNFNode.Create(mesh);
                        node.Children.Add(new LegacyBoundingBoxNode(node.ModelSize));
                        //float max = node.ModelSize.max();
                        //node.Scale *= 7.0f / max;
                        node.WorldPosition = item.position;
                        node.Diffuse       = item.color;
                        var rootElement = this.scene.RootNode;
                        this.scene.RootNode.Children.Add(node);
                        //if (rootElement != null) { rootElement.Dispose(); }
                    }
                }
            }
        }
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);

            if (_attackCount >= 5)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2
                });

                int damage = GetAttackPower(MinMC, MaxMC);

                List <MapObject> targets = FindAllTargets(3, CurrentLocation);

                for (int i = 0; i < targets.Count; i++)
                {
                    //targets[i].Attacked(this, damage, DefenceType.MAC);

                    DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 350, targets[i], damage, DefenceType.MAC);
                    ActionList.Add(action);

                    if (Envir.Random.Next(Settings.PoisonResistWeight) >= targets[i].PoisonResist)
                    {
                        if (Envir.Random.Next(5) == 0)
                        {
                            targets[i].ApplyPoison(new Poison {
                                PType = PoisonType.Frozen, Duration = 5, TickSpeed = 1000
                            }, this);
                        }
                    }
                }

                _attackCount = 0;

                return;
            }

            switch (Envir.Random.Next(3))
            {
            case 0:
            case 1:
                _attackCount++;
                base.Attack();
                break;

            case 2:
            {
                int damage = GetAttackPower(MinDC, MaxDC);

                Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                    });

                MirDirection dir = Functions.PreviousDir(Direction);
                Point        tar;
                Cell         cell;

                for (int i = 0; i < 8; i++)
                {
                    tar = Functions.PointMove(CurrentLocation, dir, 1);
                    dir = Functions.NextDir(dir);
                    if (tar == Front)
                    {
                        continue;
                    }

                    if (!CurrentMap.ValidPoint(tar))
                    {
                        continue;
                    }

                    cell = CurrentMap.GetCell(tar);

                    if (cell.Objects == null)
                    {
                        continue;
                    }

                    for (int o = 0; o < cell.Objects.Count; o++)
                    {
                        MapObject ob = cell.Objects[o];
                        if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster)
                        {
                            continue;
                        }
                        if (!ob.IsAttackTarget(this))
                        {
                            continue;
                        }

                        //ob.Attacked(this, damage, DefenceType.Agility);

                        DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 350, ob, damage, DefenceType.Agility);
                        ActionList.Add(action);
                        break;
                    }
                }
                break;
            }
            }

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;
            ShockTime  = 0;
        }
Beispiel #27
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            bool ranged = CurrentLocation != Target.CurrentLocation && !Functions.InRange(CurrentLocation, Target.CurrentLocation, 3);

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);

            ShockTime = 0;

            if (!ranged)
            {
                int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
                if (damage == 0)
                {
                    return;
                }

                ActionTime = Envir.Time + 500;
                AttackTime = Envir.Time + AttackSpeed;

                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                });
                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MACAgility);
                ActionList.Add(action);
            }
            else
            {
                if (Envir.Random.Next(5) > 0)
                {
                    int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
                    if (damage == 0)
                    {
                        return;
                    }

                    ActionTime = Envir.Time + 500;
                    AttackTime = Envir.Time + AttackSpeed;

                    Broadcast(new S.ObjectRangeAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 0
                    });
                    DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 800, Target, damage, DefenceType.AC);
                    ActionList.Add(action);
                }
                else
                {
                    Broadcast(new S.ObjectRangeAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1
                    });

                    TeleportTarget(4, 4);

                    Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
                }
            }
        }
Beispiel #28
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ShockTime = 0;

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);

            if (Envir.Random.Next(7) > 0)
            {
                if (Envir.Random.Next(2) > 0)
                {
                    Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                    });

                    int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
                    if (damage == 0)
                    {
                        return;
                    }

                    DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.ACAgility, false);
                    ActionList.Add(action);
                }
                else
                {
                    Broadcast(new S.ObjectAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 2
                    });

                    int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
                    if (damage == 0)
                    {
                        return;
                    }

                    DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MAC, true);
                    ActionList.Add(action);
                }
            }
            else
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });

                int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
                if (damage == 0)
                {
                    return;
                }

                HalfmoonAttack(damage, 300);
            }
        }
Beispiel #29
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            foreach (var item in Enum.GetNames(typeof(EnvironmentMappingNode.Ratio)))
            {
                this.cmbRatios.Items.Add(item);
            }

            var position = new vec3(8, 0, 4) * 3;
            var center   = new vec3(0, 0, 0);
            var up       = new vec3(0, 1, 0);
            var camera   = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height);

            string folder   = System.Windows.Forms.Application.StartupPath;
            var    totalBmp = new Bitmap(System.IO.Path.Combine(folder, @"cubemaps_skybox.png"));

            Bitmap[] bitmaps = GetBitmaps(totalBmp);
            this.skybox = SkyboxNode.Create(bitmaps); this.skybox.Scale *= 60;
            string       objFilename = System.IO.Path.Combine(folder + @"\..\..\..\..\Infrastructure\CSharpGL.Models", "nanosuit.obj_");
            var          parser      = new ObjVNFParser(false);
            ObjVNFResult result      = parser.Parse(objFilename);

            if (result.Error != null)
            {
                MessageBox.Show(result.Error.ToString());
            }
            else
            {
                var model = new ObjVNF(result.Mesh);
                var node  = EnvironmentMappingNode.Create(
                    this.skybox.SkyboxTexture,
                    model, ObjVNF.strPosition, ObjVNF.strNormal);
                node.ModelSize = model.GetSize();
                float max = node.ModelSize.max();
                node.Scale *= 20.0f / max;
                node.Children.Add(new LegacyBoundingBoxNode(node.ModelSize));
                this.environmentMappingNode = node;

                var group = new GroupNode(this.environmentMappingNode, this.skybox);

                this.scene = new Scene(camera)

                {
                    RootNode = group,
                };

                var list            = new ActionList();
                var transformAction = new TransformAction(scene.RootNode);
                list.Add(transformAction);
                var renderAction = new RenderAction(scene);
                list.Add(renderAction);
                this.actionList = list;

                var manipulater = new FirstPerspectiveManipulater();
                manipulater.Bind(camera, this.winGLCanvas1);

                this.pickingAction = new Picking(scene);

                this.triangleTip = new LegacyTriangleNode();
                this.quadTip     = new LegacyQuadNode();
            }
        }
Beispiel #30
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ShockTime = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            if (!ranged)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                });
                int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
                if (damage == 0)
                {
                    return;
                }

                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 300, Target, damage, DefenceType.MAC, true);
                ActionList.Add(action);
            }
            else
            {
                if (Envir.Random.Next(3) > 0)
                {
                    //Ice Attack
                    Broadcast(new S.ObjectRangeAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID
                    });
                    AttackTime = Envir.Time + AttackSpeed + 500;
                    int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
                    if (damage == 0)
                    {
                        return;
                    }

                    DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC, true);
                    ActionList.Add(action);
                }
                else
                {
                    //Fire Attack
                    Broadcast(new S.ObjectRangeAttack {
                        ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID, Type = 1
                    });
                    AttackTime = Envir.Time + AttackSpeed + 500;
                    int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
                    if (damage == 0)
                    {
                        return;
                    }

                    DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + 500, Target, damage, DefenceType.MAC, false);
                    ActionList.Add(action);
                }
            }
        }
Beispiel #31
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ShockTime = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            bool ranged = CurrentLocation == Target.CurrentLocation || !Functions.InRange(CurrentLocation, Target.CurrentLocation, 1);

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            if (!ranged)
            {
                switch (Envir.Random.Next(6))
                {
                case 0:
                case 3:
                case 4:
                {
                    Broadcast(new S.ObjectAttack {
                            ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                        });

                    int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]);
                    if (damage == 0)
                    {
                        return;
                    }

                    DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.ACAgility, false);
                    ActionList.Add(action);
                }
                break;

                case 1:
                case 5:
                {
                    Broadcast(new S.ObjectAttack {
                            ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                        });

                    int damage = GetAttackPower(Stats[Stat.MinDC], Stats[Stat.MaxDC]) * 2;
                    if (damage == 0)
                    {
                        return;
                    }

                    DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 600, Target, damage, DefenceType.ACAgility, true);
                    ActionList.Add(action);
                }
                break;

                case 2:
                {
                    AttackTime = Envir.Time + AttackSpeed + 500;

                    Broadcast(new S.ObjectRangeAttack {
                            ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID
                        });

                    int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
                    if (damage == 0)
                    {
                        return;
                    }

                    int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500;         //50 MS per Step

                    DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.MACAgility, true);
                    ActionList.Add(action);
                }
                break;
                }
            }
            else
            {
                AttackTime = Envir.Time + AttackSpeed + 500;

                Broadcast(new S.ObjectRangeAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, TargetID = Target.ObjectID
                });

                int damage = GetAttackPower(Stats[Stat.MinMC], Stats[Stat.MaxMC]);
                if (damage == 0)
                {
                    return;
                }

                int delay = Functions.MaxDistance(CurrentLocation, Target.CurrentLocation) * 50 + 500; //50 MS per Step

                DelayedAction action = new DelayedAction(DelayedType.RangeDamage, Envir.Time + delay, Target, damage, DefenceType.MACAgility, true);
                ActionList.Add(action);
            }
        }
Beispiel #32
0
        protected override void Attack()
        {
            if (!Target.IsAttackTarget(this))
            {
                Target = null;
                return;
            }

            ShockTime = 0;

            Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
            bool ranged = CurrentLocation == Target.CurrentLocation || !InAttackRange();

            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;

            int damage;

            if (!ranged && Envir.Random.Next(3) > 0)
            {
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation
                });
                damage = GetAttackPower(MinDC, MaxDC);
                if (damage == 0)
                {
                    return;
                }

                List <MapObject> targets = FindAllTargets(1, CurrentLocation);
                if (targets.Count == 0)
                {
                    return;
                }

                int levelgap;

                for (int i = 0; i < targets.Count; i++)
                {
                    if (targets[i].IsAttackTarget(this))
                    {
                        levelgap = 60 - targets[i].Level;
                        if (Envir.Random.Next(20) < 4 + levelgap)
                        {
                            if (Envir.Random.Next(Settings.MagicResistWeight) < targets[i].MagicResist)
                            {
                                continue;
                            }
                            if (targets[i].Pushed(this, Functions.DirectionFromPoint(CurrentLocation, targets[i].CurrentLocation), 3 + Envir.Random.Next(3)) > 0 &&
                                Envir.Random.Next(8) == 0)
                            {
                                targets[i].ApplyPoison(new Poison {
                                    PType = PoisonType.Paralysis, Duration = 5, TickSpeed = 1000
                                }, this, true);
                            }
                        }
                    }
                }

                LineAttack(2);
            }
            else
            {
                AttackTime = Envir.Time + AttackSpeed + 500;
                Broadcast(new S.ObjectAttack {
                    ObjectID = ObjectID, Direction = Direction, Location = CurrentLocation, Type = 1
                });

                damage = GetAttackPower(MinMC, MaxMC);
                if (damage == 0)
                {
                    return;
                }

                DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + 500, Target, damage, DefenceType.MAC);
                ActionList.Add(action);
            }

            if (Target.Dead)
            {
                FindTarget();
            }
        }
Beispiel #33
0
    private void SetServerActionHierarchy(SFSObject hierarchy)
    {
        serverActionHierarchy = new ActionList();

        for (int a = 0; a < hierarchy.Size(); a++)
        {
            SFSObject actionObject = hierarchy.GetObj(Convert.ToString(a));
            Action action = new Action();
            action.name = actionObject.GetString("n");
            int numParam = actionObject.Size();
            for (int i = 0; i < numParam - 1; i++)
            {
                SFSObject param = actionObject.GetObj(Convert.ToString(i));
                string paramName = param.GetString("n");
                string paramType = param.GetString("t");
                switch (paramType)
                {
                    case "b" ://boolean
                        bool boolValue = param.GetBool("v");
                        action.AddBoolParam(paramName, boolValue);
                        break;
                    case "maq"://maximum quantity (integer > 0 or "MAX")
                        //
                        break;
                    case "miq"://minimum quantity (integer > 0 or "MIN")
                        //
                        break;
                    case "n"://integer with min and max values
                        //
                        break;
                    case "mi"://minored integer : integer with min value or "INF"
                        string value = param.GetString("v");
                        int minValue = (int) param.GetNumber("m");
                        action.AddMinoredIntegerParam(paramName, value, minValue);
                        break;
                    case "ii"://inventory item
                        //
                        break;
                    case "it"://item type
                        //
                        break;
                    case "am"://actionMark (an absolute position or the position of a physical entity marked by the player or his faction)
                        bool playerIsMarkOwner = param.GetBool("o");
                        int actionMarkID = (int)param.GetNumber("n");
                        action.AddActionMark(paramName, playerIsMarkOwner, actionMarkID);
                        break;
                    case "c"://character (player or npc)
                        //
                        break;
                    case "s"://string message
                        //
                        break;

                }
            }

            serverActionHierarchy.Add(action);
        }
    }
Beispiel #34
0
 public MainWindowViewModel()
 {
     Items = new ActionList<TestModel>(new[]
                                     {
                                         new TestModel() {A1 = "1"},
                                          new TestModel() {A1 = "22"} ,
                                          new TestModel() {A1 = "33"}
                                     });
     for (int i = 0; i < 999; i++)
     {
           Items.Add(new TestModel(){A1 = i.ToString()});
     }
 }