Ejemplo n.º 1
0
        private void AddAction(Type type, Action <ImageAction> initializer = null)
        {
            var action = (ImageAction)Activator.CreateInstance(type);

            action.EventAggregator = _ea;
            action.IsEditMode      = true;
            action.HasChanged      = true;
            initializer?.Invoke(action);
            CurrentActions.Add(action);
            _ea.GetEvent <OperateOnImageEvent>().Publish(this.CurrentActions);
        }
Ejemplo n.º 2
0
        private IEnumerable <Wait> RoutineTakeTurn(Turn turn)
        {
            FindAggroTarget();
            if (AggroTarget != null)
            {
                FaceTowards(AggroTarget);
            }
            Skill usableSkill = GetUsableSkill();

            foreach (Skill skill in Skills)
            {
                skill.Update(this);
            }

            if (usableSkill != null)
            {
                var target = usableSkill.GetEnemyTarget(this);
                CurrentActions.Add(Scheduler.Instance.RunAndWait(RoutineUseSkill(usableSkill, target)));
                if (usableSkill.WaitUse)
                {
                    yield return(CurrentActions);
                }
            }
            else
            {
                var move = new[] { Facing.North, Facing.East, Facing.South, Facing.West }.Pick(Random).ToOffset();
                if (AggroTarget != null)
                {
                    var movementType = this.GetMovementType();
                    var costMap      = new CostMap(Map, this, movementType.GetTileCost);
                    costMap.SetMask(Mask);
                    costMap.Recalculate();
                    var targetPoints = Mask.Select(o => new Point(AggroTarget.X, AggroTarget.Y) - o).ToList();
                    var dijkstra     = Util.Dijkstra(new Point[] { new Point(X, Y) }, targetPoints, Map.Width, Map.Height, new Rectangle(X - 20, Y - 20, 41, 41), double.MaxValue, costMap, movementType.GetNeighbors());
                    var path         = dijkstra.FindPath(targetPoints.Pick(Random));
                    if (path.Any())
                    {
                        move = path.First() - new Point(X, Y);
                    }
                    else
                    {
                        move = new Point(0, 0);
                    }
                }

                if (move != Point.Zero) //No move to self
                {
                    CurrentActions.Add(Scheduler.Instance.RunAndWait(RoutineMove(move.X, move.Y)));
                }
            }
        }
Ejemplo n.º 3
0
        private void Sim_FinishedStep(CraftingSim sim, int index)
        {
            if (index == 0)
            {
                if (CurrentActions != null)
                {
                    CurrentActions.ForEach(x => x.Dispose());
                    CurrentActions.Clear();
                }
                CurrentActions = new List <CraftingActionContainer>();
                OldProgress    = 0;
                OldQuality     = 0;
            }
            var currentAction = sim.CraftingActions[index];
            CraftingActionContainer container = new CraftingActionContainer(Sim, currentAction);

            container.ProgressIncreased = sim.CurrentProgress - OldProgress;
            container.QualityIncreased  = sim.CurrentQuality - OldQuality;
            OldProgress = sim.CurrentProgress;
            OldQuality  = sim.CurrentQuality;
            CurrentActions.Add(container);
        }