protected override void OnUpdate()
    {
        Entities.ForEach((InputComponent inputcomponent, MoveSpeedComponent moveSpeed) =>
        {
            m_moveSpeedComponent = moveSpeed;
        });

        Entities.ForEach((FallingPlatformComponent fallingplatform, Rigidbody2D rigidbody2D) =>
        {
            if (m_moveSpeedComponent.gameObject.tag == "Player")
            {
                rigidbody2D.isKinematic = false;
            }
        });
    }
Beispiel #2
0
    protected override void OnUpdate()
    {
        Entities.ForEach((InputComponent inputcomponent, MoveSpeedComponent moveSpeed) =>
        {
            m_inputComponent = inputcomponent;

            m_moveSpeedComponent = moveSpeed;
        });

        Entities.ForEach((BoxCollider2D collider, PlatformEffector2D platform) =>
        {
            if (m_inputComponent.Down == true && m_moveSpeedComponent.isGrounded == true) //checks to see if the player is pushing down and grounded
            {
                collider.enabled = false;
            }
            else
            {
                collider.enabled |= (m_inputComponent.Down == false && m_moveSpeedComponent.isGrounded == true);
            }
        });
    }
Beispiel #3
0
    private static void _Move(ref Translation pT, ref MoveSpeedComponent pMsc, NativeArray <bool> wallMap, float deltaTime, Random rand)
    {
        float3 speed    = GetMoveVector(pMsc.direction);
        float3 nextStep = pT.Value + new float3(speed.x / 5.5f, 0f, speed.z / 5.5f);

        int nextX = Mathf.RoundToInt(nextStep.x);
        int nextZ = Mathf.RoundToInt(nextStep.z);

        if ((nextX < 0f) || (nextX > 100f) ||
            (nextZ < 0f) || (nextZ > 100f) ||
            wallMap[nextX * 100 + nextZ])
        {
            // pMsc.direction = (pMsc.direction + 1) % 4;
            pMsc.direction = rand.NextInt(0, 4);
            pT.Value.x     = (int)pT.Value.x;
            pT.Value.z     = (int)pT.Value.z;
            // _Move(ref pT, ref pMsc, wallMap, deltaTime);
        }
        else
        {
            pT.Value += GetMoveVector(pMsc.direction) * deltaTime;
        }
    }