
using UnityEngine;

public class MovingPlatform : MovingObject
{
    public float mMovingSpeed;
    public bool mWait;
    public float mTimer = 0.0f;
    public float mWaitTime = 3.0f;

    public void Start()
    {
        if (mUpdateId < 0)
        {
            Init();
            mSpeed.x = 0;
        }
    }

    public void Init()
    {
        mSpeed.x = mMovingSpeed;
        mWait = false;

        mAABB.HalfSize = new Vector2(32.0f, 8.0f);
        mSlopeWallHeight = 0;
        mMovingSpeed = 100.0f;
        mIsKinematic = true;
        mSpeed.x = mMovingSpeed;
        Scale = new Vector2(1.0f, 1.0f);

        mUpdateId = mGame.AddToUpdateList(this);
    }

    public void CustomUpdate()
    {
        if (mPS.pushesRightTile && !mPS.pushesBottomTile)
            mSpeed.y = -mMovingSpeed;
        else if (mPS.pushesBottomTile && !mPS.pushesLeftTile)
            mSpeed.x = -mMovingSpeed;
        else if (mPS.pushesLeftTile && !mPS.pushesTopTile)
            mSpeed.y = mMovingSpeed;
        else if (mPS.pushesTopTile && !mPS.pushesRightTile)
            mSpeed.x = mMovingSpeed;

        UpdatePhysics();
    }
}
