コード例 #1
0
        public virtual void NotifyUseInteractive(InteractiveObject interactive, InteractiveSkill skill, int duration)
        {
            if (duration > 0)
            {
                UsingInteractive = interactive;
                UsingSkill = skill;
                UsageEndTime = DateTime.Now + TimeSpan.FromMilliseconds(duration);
            }

            UseInteractiveHandler handler = StartUsingInteractive;
            if (handler != null) handler(this, interactive, skill, UsageEndTime);
        }
コード例 #2
0
        public bool UseInteractiveObject(InteractiveSkill skill)
        {
            m_useAfterMove = null;

            if (!Map.Interactives.Contains(skill.Interactive) || !skill.IsEnabled())
                return false;

            if (skill.Interactive.Cell != null && !skill.Interactive.Cell.IsAdjacentTo(Cell))
            {
                var cell = skill.Interactive.Cell.GetAdjacentCells(x => Map.CanStopOnCell(x)).
                    OrderBy(x => x.ManhattanDistanceTo(Cell)).FirstOrDefault();

                if (cell == null)
                    return false;

                if (Move(cell))
                {
                    m_useAfterMove = skill;
                    return true;
                }
            }
            else
            {
                Bot.SendToServer(new InteractiveUseRequestMessage(skill.Interactive.Id, skill.Id));
                return true;
            }

            return false;
        }
コード例 #3
0
        public override void NotifyStopMoving(bool canceled, bool refused)
        {
            base.NotifyStopMoving(canceled, refused);

            if (m_useAfterMove != null)
            {
                if (!canceled)
                {
                    var skill = m_useAfterMove;
                    Bot.AddMessage(() => UseInteractiveObject(skill)); // call next tick
                }

                m_useAfterMove = null;
            }
            if (_actionAfterMove != null)
            {
                Bot.AddMessage(_actionAfterMove);
                _actionAfterMove = null;
            }

            if (m_nextMap != null)
            {
                if (!canceled && !refused)
                {
                    var id = m_nextMap.Value;
                    m_previousMap = Map.Id;
                    Bot.AddMessage(() => Bot.SendToServer(new ChangeMapMessage(id)));
                }

                m_nextMap = null;
            }
        }