public void OnSkillActivated(Skill skill)
        {
            SkillDefinitionComponent def_cmp = skill.GetDefinitionComponent();

            if (def_cmp.StartsActive)
            {
                return;
            }
            if (def_cmp.BlocksMovementWhenActive)
            {
                ++m_move_block_count;
                if (m_move_block_count == 1)
                {
                    if (m_locomotor_cmp != null)
                    {
                        m_locomotor_cmp.Disable();
                    }
                }
            }
            else
            {
                if (def_cmp.BlocksRotatingWhenActive)
                {
                    PositionComponent position_component = skill.GetOwnerEntity().GetComponent(PositionComponent.ID) as PositionComponent;
                    if (position_component != null)
                    {
                        position_component.DisableRotating();
                    }
                }
                if (def_cmp.DeactivateWhenMoving)
                {
                    if (m_locomotor_cmp != null)
                    {
                        m_locomotor_cmp.StopMoving();
                    }
                }
                else
                {
                    if (def_cmp.m_main_animation != null && m_locomotor_cmp != null)
                    {
                        m_locomotor_cmp.BlockAnimation();
                    }
                }
            }
            if (def_cmp.BlocksOtherSkillsWhenActive)
            {
                ++m_active_block_count;
            }
            m_active_skill_ids.Add(skill.ID);
        }
Exemplo n.º 2
0
        bool HandleEntityMove(EntityMoveCommand cmd)
        {
            Entity entity = m_logic_world.GetEntityManager().GetObject(cmd.m_entity_id);

            if (entity == null)
            {
                return(false);
            }
            LocomotorComponent locomotor_component = entity.GetComponent(LocomotorComponent.ID) as LocomotorComponent;

            if (locomotor_component == null)
            {
                return(false);
            }
            if (cmd.m_move_type != EntityMoveCommand.StopMoving)
            {
                TargetingComponent targeting_component = entity.GetComponent(TargetingComponent.ID) as TargetingComponent;
                if (targeting_component != null)
                {
                    targeting_component.StopTargeting();
                }
            }
            if (cmd.m_move_type == EntityMoveCommand.DestinationType)
            {
                PathFindingComponent pathfinding_component = entity.GetComponent(PathFindingComponent.ID) as PathFindingComponent;
                if (pathfinding_component != null)
                {
                    return(pathfinding_component.FindPath(cmd.m_vector));
                }
                else
                {
                    PositionComponent position_component = entity.GetComponent(PositionComponent.ID) as PositionComponent;
                    List <Vector3FP>  path = new List <Vector3FP>();
                    path.Add(position_component.CurrentPosition);
                    path.Add(cmd.m_vector);
                    locomotor_component.MoveAlongPath(path, true);
                }
            }
            else if (cmd.m_move_type == EntityMoveCommand.DirectionType)
            {
                locomotor_component.MoveByDirection(cmd.m_vector);
            }
            else if (cmd.m_move_type == EntityMoveCommand.StopMoving)
            {
                locomotor_component.StopMoving(true);
            }
            return(true);
        }
Exemplo n.º 3
0
        //FixPoint m_tolerance = FixPoint.One / FixPoint.Ten;
        //Vector3FP m_destination = new Vector3FP(new FixPoint(99999), FixPoint.Zero, new FixPoint(99999));

        public bool FindPath(Vector3FP destination)
        {
            if (!IsEnable())
            {
                return(false);
            }
            //if (FixPoint.Abs(destination.x - m_destination.x) + FixPoint.Abs(destination.z - m_destination.z) < m_tolerance)
            //    return true;
            LocomotorComponent locomotor_cmp = ParentObject.GetComponent(LocomotorComponent.ID) as LocomotorComponent;

            if (locomotor_cmp == null)
            {
                return(false);
            }
            PositionComponent position_cmp = ParentObject.GetComponent(PositionComponent.ID) as PositionComponent;

            if (position_cmp == null)
            {
                return(false);
            }
            GridGraph graph = position_cmp.GetGridGraph();

            if (graph == null)
            {
                return(false);
            }
            if (!graph.FindPath(position_cmp.CurrentPosition, destination))
            {
                locomotor_cmp.StopMoving();
                return(false);
            }
            List <Vector3FP> path = graph.GetPath();

            if (!locomotor_cmp.MoveAlongPath(path, false))
            {
                return(false);
            }
            //m_destination = destination;
            return(true);
        }