Exemplo n.º 1
0
        public override void HandleAttacks(List <Attack> p_attackList, Monster p_monster, Character p_character, Boolean p_isMagic)
        {
            if (p_monster.DistanceToParty > 1f)
            {
                return;
            }
            Party    party     = LegacyLogic.Instance.WorldManager.Party;
            Grid     grid      = LegacyLogic.Instance.MapLoader.Grid;
            Position position  = party.Position;
            Position position2 = position + EDirectionFunctions.GetLineOfSightDirection(p_monster.Position, party.Position);
            GridSlot slot      = grid.GetSlot(position2);

            if (slot == null)
            {
                return;
            }
            party.IsPushed = true;
            if (!slot.HasEntities && grid.CanMoveEntity(party, p_monster.Direction))
            {
                GridSlot slot2 = grid.GetSlot(position);
                slot2.RemoveEntity(party);
                party.Position = position2;
                grid.GetSlot(position2).AddEntity(party);
                MoveEntityEventArgs p_eventArgs = new MoveEntityEventArgs(position, position2);
                LegacyLogic.Instance.EventManager.InvokeEvent(party, EEventType.MOVE_ENTITY, p_eventArgs);
                LegacyLogic.Instance.EventManager.InvokeEvent(this, EEventType.ENTITY_ABILITY_ADDED, new AbilityEventArgs(p_monster, this));
                AbilityTriggeredEventArgs p_args = new AbilityTriggeredEventArgs(p_monster, this);
                LegacyLogic.Instance.ActionLog.PushEntry(p_args);
            }
            else
            {
                party.IsPushed = false;
            }
        }
Exemplo n.º 2
0
 private void ShowHitEffect(Monster mob)
 {
     if (mob != null)
     {
         Party      party = LegacyLogic.Instance.WorldManager.Party;
         EDirection lineOfSightDirection = EDirectionFunctions.GetLineOfSightDirection(party.Position, mob.Position);
         if (lineOfSightDirection != party.Direction)
         {
             if (EDirectionFunctions.Add(lineOfSightDirection, 2) == party.Direction)
             {
                 m_bottomEffect.Stop();
                 m_bottomEffect.Play();
             }
             if (EDirectionFunctions.Add(lineOfSightDirection, 1) == party.Direction)
             {
                 m_leftEffect.Stop();
                 m_leftEffect.Play();
             }
             if (EDirectionFunctions.Add(lineOfSightDirection, -1) == party.Direction)
             {
                 m_rightEffect.Stop();
                 m_rightEffect.Play();
             }
         }
     }
 }
Exemplo n.º 3
0
 private Boolean IsMonsterInFrontOfParty()
 {
     if (MyController != null)
     {
         Monster  monster = (Monster)MyController;
         Party    party   = LegacyLogic.Instance.WorldManager.Party;
         GridSlot slot    = LegacyLogic.Instance.MapLoader.Grid.GetSlot(party.Position);
         return(Position.Distance(monster.Position, party.Position) <= 1f && EDirectionFunctions.GetLineOfSightDirection(party.Position, monster.Position) == party.Direction && slot != null && slot.GetConnection(party.Direction, false, true) != null);
     }
     return(false);
 }
Exemplo n.º 4
0
        private void Update()
        {
            if (!enabled)
            {
                return;
            }
            if (!Input.GetMouseButtonUp(0))
            {
                return;
            }
            if (UICamera.hoveredObject != null)
            {
                return;
            }
            if (FXMainCamera.Instance == null)
            {
                return;
            }
            Camera camera = FXMainCamera.Instance.DefaultCamera.camera;

            if (camera == null)
            {
                return;
            }
            Ray        ray = camera.ScreenPointToRay(Input.mousePosition);
            RaycastHit raycastHit;

            if (Physics.Raycast(ray, out raycastHit, 50f))
            {
                InteractiveObjectHighlight component = raycastHit.collider.GetComponent <InteractiveObjectHighlight>();
                if (component != null && component.IsClickable)
                {
                    InteractiveObject myController = component.MyController;
                    LegacyLogic.Instance.WorldManager.Party.SelectedInteractiveObject = myController;
                    LegacyLogic.Instance.CommandManager.AddCommand(new InteractCommand(myController));
                    return;
                }
                if (raycastHit.rigidbody != null)
                {
                    BaseView component2 = raycastHit.rigidbody.GetComponent <BaseView>();
                    if (component2 != null && component2.MyController is Monster)
                    {
                        Monster monster = (Monster)component2.MyController;
                        Party   party   = LegacyLogic.Instance.WorldManager.Party;
                        Single  num     = Position.Distance(monster.Position, party.Position);
                        if (num == 1f && EDirectionFunctions.GetLineOfSightDirection(party.Position, monster.Position) == party.Direction && monster.CurrentHealth > 0)
                        {
                            party.SelectedMonster = monster;
                        }
                        return;
                    }
                }
            }
        }
Exemplo n.º 5
0
 public override Boolean CanDoAction(Command p_command)
 {
     if (Party.SelectedMonster != null)
     {
         EDirection lineOfSightDirection = EDirectionFunctions.GetLineOfSightDirection(Party.Position, Party.SelectedMonster.Position);
         if (lineOfSightDirection != Party.Direction)
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 6
0
 protected Boolean Move(List <GridSlot> p_movePath)
 {
     if (p_movePath.Count > 0)
     {
         GridSlot   gridSlot             = p_movePath[0];
         Grid       grid                 = LegacyLogic.Instance.MapLoader.Grid;
         EDirection lineOfSightDirection = EDirectionFunctions.GetLineOfSightDirection(Controller.Position, gridSlot.Position);
         if (grid.MoveEntity(Controller, lineOfSightDirection))
         {
             p_movePath.RemoveAt(0);
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 7
0
        internal Boolean TryMove(List <GridSlot> p_targets, Grid p_grid, GridSlot p_startSlot, Party p_party)
        {
            if (m_owner.CombatHandler.CanMove)
            {
                List <GridSlot> pathBuffer = m_PathBuffer;
                GridSlot        gridSlot   = null;
                Int32           num        = 999;
                GridSlot        gridSlot2  = null;
                foreach (GridSlot gridSlot3 in p_targets)
                {
                    pathBuffer.Clear();
                    if (CalculatePath(p_startSlot, gridSlot3, pathBuffer) && pathBuffer.Count < num)
                    {
                        gridSlot  = gridSlot3;
                        num       = pathBuffer.Count;
                        gridSlot2 = pathBuffer[1];
                    }
                }
                if (gridSlot != null)
                {
                    EDirection lineOfSightDirection = EDirectionFunctions.GetLineOfSightDirection(p_startSlot.Position, gridSlot2.Position);
                    if (lineOfSightDirection != EDirection.CENTER)
                    {
                        m_owner.Direction = EDirectionFunctions.GetDirection(gridSlot2.Position, p_party.Position);
                        if (p_grid.MoveEntity(m_owner, lineOfSightDirection))
                        {
                            m_targetSlot = gridSlot;
                            GridSlot slot  = p_grid.GetSlot(m_owner.Position);
                            GridSlot slot2 = p_grid.GetSlot(p_party.Position);
                            Int32    num2  = AStarHelper <GridSlot> .Calculate(slot, slot2, GameConfig.MaxSteps, m_owner, true, null);

                            if (num2 > 0)
                            {
                                m_owner.DistanceToParty = num2;
                            }
                            else
                            {
                                m_owner.DistanceToParty = 99f;
                            }
                            m_owner.StartMovement.Trigger();
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 8
0
        public virtual List <GridSlot> GetMeleeTargets(Grid p_grid, Party p_party)
        {
            List <GridSlot> list = new List <GridSlot>();
            Int32           num  = Math.Min(p_party.Position.X, m_owner.Position.X);
            Int32           num2 = Math.Min(p_party.Position.Y, m_owner.Position.Y);
            Int32           num3 = Math.Max(p_party.Position.X, m_owner.Position.X);
            Int32           num4 = Math.Max(p_party.Position.Y, m_owner.Position.Y);

            if (num == p_party.Position.X)
            {
                num--;
                num3 = num + 2;
            }
            if (num2 == p_party.Position.Y)
            {
                num2--;
                num4 = num2 + 2;
            }
            for (Int32 i = num; i <= num3; i++)
            {
                for (Int32 j = num2; j <= num4; j++)
                {
                    Position position = new Position(i, j);
                    if (!(position == p_party.Position) && !(position == m_owner.Position))
                    {
                        GridSlot slot = p_grid.GetSlot(position);
                        if (slot != null && slot.IsPassable(m_owner, false) && Position.Distance(position, p_party.Position) == 1f)
                        {
                            EDirection lineOfSightDirection = EDirectionFunctions.GetLineOfSightDirection(slot.Position, p_party.Position);
                            if (slot.GetTransition(lineOfSightDirection).TransitionType == EGridTransitionType.OPEN)
                            {
                                list.Add(slot);
                            }
                        }
                    }
                }
            }
            return(list);
        }