Exemplo n.º 1
0
    private bool SelectWalkTarget()
    {
        OnWalk();

        var movingSideWalkAt = GameSingleton.Instance.GetMovingSideWalkAt(m_positionInt);
        var endProperty      = GameSingleton.Instance.GridInformation.GetPositionProperty(Helper.ToVector3Int(m_positionInt),
                                                                                          TilemapProperty.EndProperty, 0);

        if (endProperty == 1 && !m_tempVictory)
        {
            m_tempVictory = true;
            OnStatic(2);
            return(true);
        }

        if (movingSideWalkAt == null)
        {
            Debug.LogError("Impossible move at " + m_positionInt);
            if (!m_tempVictory)
            {
                m_currentLife = 0;
            }
            return(true);
        }
        var previousTarget = m_target;

        m_target = m_positionInt + MovingSidewalk.GetVector2IntFromDirection(movingSideWalkAt.PickExit());
        ChangeDirectionByTarget(previousTarget, m_target);
        m_targetWithALittleJoke        = m_target + Random.insideUnitCircle * 0.3f;
        m_startPosition                = m_position;
        m_startPositionWithALittleJoke = m_positionWithALittleJoke;
        m_movePercentage               = 0.0f;
        return(false);
    }
Exemplo n.º 2
0
    private bool SelectRunTarget(bool invertDirection)
    {
        Debug.Log("SelectRun " + Time.frameCount);
        if (m_fearCounter <= 0)
        {
            OnStopRun();
            return(false);
        }

        OnRun();

        var startProperty = GameSingleton.Instance.GridInformation.GetPositionProperty(Helper.ToVector3Int(m_positionInt),
                                                                                       TilemapProperty.StartProperty, 0);

        if (startProperty == 1)
        {
            m_target = null;
            OnStatic(2);
            return(true);
        }

        var movingSideWalkAt = GameSingleton.Instance.GetMovingSideWalkAt(m_positionInt);

        if (movingSideWalkAt == null)
        {
            m_currentLife = 0;
            return(true);
        }

        m_fearCounter--;

        var previousTarget = m_target;

        m_target = m_positionInt + MovingSidewalk.GetVector2IntFromDirection(movingSideWalkAt.PickEntrance());
        ChangeDirectionByTarget(previousTarget, m_target);
        m_targetWithALittleJoke        = m_target + Random.insideUnitCircle * 0.3f;
        m_startPosition                = m_position;
        m_startPositionWithALittleJoke = m_positionWithALittleJoke;
        m_movePercentage               = 0.0f;
        return(false);
    }