예제 #1
0
        protected void SpawnRune(double X, double Y, RuneType type, RuneSize size = RuneSize.Normal)
        {
            var rune = new InternalRuneData(type, size, new Frame3D(X, Y, 0));
            var id   = world.IdGenerator.CreateNewId(rune);

            var p = rune.Location;

            world.GetEngine <IPudgeWorldEngine>().SpawnRune(rune.Type, rune.Size, p.X, p.Y, p.Z, id);
            world.SpawnedRunes.Add(rune);
        }
예제 #2
0
        private void CheckRunes()
        {
            var engine = world.GetEngine <ICommonEngine>();
            var controllerIdToLocation = world.Actors
                                         .Where(actor => !actor.IsDisabled)
                                         .Where(actor => actor is PudgeRobot)
                                         .ToDictionary(a => a.ControllerId, a => engine.GetAbsoluteLocation(a.ObjectId));

            foreach (var controllerId in controllerIdToLocation.Keys)
            {
                if (world.SpawnedRunes.Count == 0)
                {
                    return;
                }

                var nearestRune = world.SpawnedRunes
                                  .Select(rune => new
                {
                    rune,
                    distance = Geometry.Distance(
                        rune.Location.ToPoint3D(),
                        controllerIdToLocation[controllerId].ToPoint3D())
                })
                                  .Where(z => z.distance < PudgeRules.Current.RunePickRange)
                                  .Select(z => z.rune)
                                  .FirstOrDefault();

                if (nearestRune != null)
                {
                    var id = world.IdGenerator.GetIdByObject(nearestRune);
                    if (id == null)
                    {
                        return;
                    }
                    engine.DeleteObject(id);

                    if (BuffActions.ContainsKey(nearestRune.Type))
                    {
                        BuffActions[nearestRune.Type](nearestRune, controllerId);
                    }
                    world.SpawnedRunes.Remove(nearestRune);
                }
            }
        }