예제 #1
0
 // Use this for initialization
 void Start () {
     se2d = GetComponent<SurfaceEffector2D>();
     if (target != null)
     {
         target = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
     }
 }
예제 #2
0
        private void Standardization_Physics()
        {
Axises:
            {
                for (int i = 0; i < 2; i++)
                {
                    Transform        axis = Axises [i];
                    CircleCollider2D cc2d = axis.gameObject.EnsureComponent <CircleCollider2D> ();
                    cc2d.radius         = .5f + chain_unit_height / Radius / 4f;
                    cc2d.usedByEffector = true;
                    Rigidbody2D r2d = axis.gameObject.EnsureComponent <Rigidbody2D> ();
                    r2d.isKinematic = true;
                    SurfaceEffector2D se2d = axis.gameObject.EnsureComponent <SurfaceEffector2D> ();
                    se2d.speed = Speed;
                }
            }

ChainPhysics:
            {
                BoxCollider2D bc2d = ChainPhysics.EnsureComponent <BoxCollider2D> ();
                bc2d.size = new Vector2(AxisDistance, Radius * 2f + chain_unit_height);
                ChainPhysics.transform.localPosition = Vector3.zero;
                ChainPhysics.transform.localScale    = Vector3.one;
                ChainPhysics.transform.right         = p0 - p1;
                bc2d.usedByEffector = true;
                Rigidbody2D r2d = ChainPhysics.EnsureComponent <Rigidbody2D> ();
                r2d.isKinematic = true;
                SurfaceEffector2D se2d = ChainPhysics.EnsureComponent <SurfaceEffector2D> ();
                se2d.speed = Speed;
            }
        }
        private void Awake()
        {
            effector = gameObject.GetComponent <SurfaceEffector2D>();


            originalSpeed = effector.speed;
            eventListener.Add("exitThinking", OnExitThinking);
            eventListener.Add("enterThinking", OnEnterThinking);
        }
예제 #4
0
 /// <summary>
 /// Updates the buttons to disable them where appropriate.
 /// </summary>
 void UpdateButtons()
 {
     if (LevelController.instance.selectedObject == null || !LevelController.instance.IsPaused)
     {
         foreach (Button button in allButtons)
         {
             button.interactable = false;
         }
     }
     else
     {
         //set all to interactable but then check what the selected object is an update buttons accordingly.
         foreach (Button button in allButtons)
         {
             button.interactable = true;
         }
         if (LevelController.instance.IsPaused)
         {
             if (LevelController.instance.selectedObject.tag == "Conveyor")
             {
                 allButtons [6].interactable = true;
                 SurfaceEffector2D surface = LevelController.instance.selectedObject.GetComponent <SurfaceEffector2D> ();
                 if (surface != null)
                 {
                     if (surface.speed < 0)
                     {
                         allButtons [6].GetComponentsInChildren <Image> () [1].sprite = switchLeft;
                     }
                     else
                     {
                         allButtons [6].GetComponentsInChildren <Image> () [1].sprite = switchRight;
                     }
                 }
             }
             else
             {
                 allButtons [6].GetComponentsInChildren <Image> () [1].sprite = switchDisabled;
                 allButtons [6].interactable = false;
             }
             if (LevelController.instance.selectedObject.tag == "Funnel")
             {
                 allButtons [1].interactable = false;
                 allButtons [2].interactable = false;
                 allButtons [3].interactable = false;
             }
             if (getSelectedObjectCost() > LevelController.instance.startingMoney)
             {
                 allButtons [7].interactable = false;
             }
         }
     }
 }
예제 #5
0
    void Start()
    {
        // gets SurfaceEffector 2D of object
        se = obj.GetComponent <SurfaceEffector2D>();

        if (se == null)
        {
            obj.AddComponent <SurfaceEffector2D>();
            se = obj.GetComponent <SurfaceEffector2D>();
        }

        ChangeSpeed();
    }
예제 #6
0
    public void Start()
    {
        //ultimo trilho para freiar na estação
        FaseDetail faseDetail = FindObjectOfType(typeof(FaseDetail)) as FaseDetail;

        accelerator     = faseDetail.accelerator;
        scoreTMP        = FindObjectOfType(typeof(ScoreTMP)) as ScoreTMP;
        trainController = FindObjectOfType(typeof(TrainController)) as TrainController;
        //hudCompletou.SetActive(false);
        nextlevel       = false;
        audioController = AudioController.getInstance();
        audioController.trocarMusica(audioController.musicaFase1);
    }
예제 #7
0
    private void ManageBoostDirection() //Depending on initial direction of the drawing, the boost direction needs to be changed accordingly
    {
        surfaceEffector = GetComponent <SurfaceEffector2D>();

        if (points[0].x < points[1].x)
        {
            surfaceEffector.speed = boostSpeed;
        }
        else
        {
            surfaceEffector.speed = -boostSpeed;
        }
    }
예제 #8
0
    private void Start()
    {
        m_disBtTrack    = m_disBtTrack * ratio;
        m_trackEffector = m_track.GetComponent <SurfaceEffector2D>();
        m_rtk           = m_detect.GetComponent <RotateTrackDetect>();
        m_playerTrans   = GameObject.FindWithTag("Player").transform;
        m_playerRig     = m_playerTrans.GetComponent <Rigidbody2D>();

        Death.Instance.Add(gameObject);

        m_curAngle = m_startAngle;
        SetTrackState(true);
        InitPos();
    }
예제 #9
0
    private void Start()
    {
        surface = GetComponent <SurfaceEffector2D>();

        speed = Mathf.Abs(speed);

        surface.speed = (isRightward ? speed : -speed);

        Animator[] anims = GetComponentsInChildren <Animator>();

        foreach (Animator anim in anims)
        {
            anim.SetBool("right", isRightward);
        }
    }
예제 #10
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "SpawnPlatform")
        {
            grounded = true;
        }
        else
        {
            grounded = false;
        }

        if (collision.gameObject.tag == "conveyer")
        {
            sf2 = collision.gameObject.GetComponent <SurfaceEffector2D>();
        }
    }
예제 #11
0
    public static int get_speedVariation(IntPtr l)
    {
        int result;

        try
        {
            SurfaceEffector2D surfaceEffector2D = (SurfaceEffector2D)LuaObject.checkSelf(l);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, surfaceEffector2D.speedVariation);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
예제 #12
0
    void Start()
    {
        effector       = gameObject.GetComponent <SurfaceEffector2D> ();
        gears          = transform.GetChild(1).transform;
        rotateArrow    = transform.GetChild(2).gameObject;
        directionArrow = transform.GetChild(3).gameObject;
        keeperScript   = GameObject.Find("ScoreKeeper").GetComponent <ScoreKeeper> ();
        sr             = gameObject.GetComponent <SpriteRenderer> ();

        if (startingDirection == "left")
        {
            flip();
        }
        if (disabledOnStart)
        {
            gameObject.tag = "Untagged";
        }
    }
예제 #13
0
    public static int set_useBounce(IntPtr l)
    {
        int result;

        try
        {
            SurfaceEffector2D surfaceEffector2D = (SurfaceEffector2D)LuaObject.checkSelf(l);
            bool useBounce;
            LuaObject.checkType(l, 2, out useBounce);
            surfaceEffector2D.useBounce = useBounce;
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
예제 #14
0
    public static int set_speed(IntPtr l)
    {
        int result;

        try
        {
            SurfaceEffector2D surfaceEffector2D = (SurfaceEffector2D)LuaObject.checkSelf(l);
            float             speed;
            LuaObject.checkType(l, 2, out speed);
            surfaceEffector2D.speed = speed;
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
예제 #15
0
    /// <summary>
    /// Switch the direction a conveyor is pushing.
    /// </summary>
    /// <param name="theObject">The object.</param>
    private void Switch(GameObject theObject)
    {
        SurfaceEffector2D surface = theObject.GetComponent <SurfaceEffector2D> ();

        if (surface != null)
        {
            surface.speed *= -1;
            if (surface.speed < 0)
            {
                allButtons [6].GetComponentsInChildren <Image> () [1].sprite = switchLeft;
            }
            else
            {
                allButtons [6].GetComponentsInChildren <Image> () [1].sprite = switchRight;
            }
        }
        else
        {
            allButtons [6].GetComponentsInChildren <Image> () [1].sprite = switchDisabled;
        }
    }
예제 #16
0
    private float resistSpeed;                   //抵抗速度

    // Start is called before the first frame update
    void Start()
    {
        _surfaceEffector2D = transform.parent.GetComponent <SurfaceEffector2D>();
        _gameController    = GameObject.Find("GameController").GetComponent <Gamecontroller>();
        _flagManager       = GameObject.Find("FlagManager").GetComponent <FlagManager>();

        //resistSpeedはdefaultSpeedの半分
        resistSpeed = -defaultSpeed / 2.0f;

        _nowResist = false;
        _surfaceEffector2D.useFriction = false;

        if (resistDirection[0] && resistDirection[1])
        {
            for (int i = 0; i < 2; i++)
            {
                resistDirection[i] = false;

                //メッセージ表示
                Debug.Log("Resist Directionのどちら一方にチェックを入れてください");
            }
        }
    }
예제 #17
0
 private void Start()
 {
     se2d         = se2d.GetComponent <SurfaceEffector2D>();
     slider.value = se2d.speed;
 }
예제 #18
0
 void Start()
 {
     effector = GetComponentInParent <SurfaceEffector2D> ();
 }
    // Start is called before the first frame update
    void Start()
    {
        se2d = GetComponent <SurfaceEffector2D>();

        se2d.speed = 0.0f;
    }
예제 #20
0
 // Start is called before the first frame update
 void Start()
 {
     rb              = GetComponent <Rigidbody2D>();
     DefaultPos      = transform.position;
     surfaceEffector = GetComponent <SurfaceEffector2D>();
 }
예제 #21
0
 // Start is called before the first frame update
 void Start()
 {
     surface = GetComponent <SurfaceEffector2D>();
 }
예제 #22
0
 public static Tween TweenSpeed(this SurfaceEffector2D effector, float to, float duration) =>
 Tweening.To(getter: () => effector.speed,
             setter: speed => effector.speed = speed,
             to, duration).SetTarget(effector);
예제 #23
0
 public static Tween TweenForceScale(this SurfaceEffector2D effector, float to, float duration) =>
 Tweening.To(getter: () => effector.forceScale,
             setter: forceScale => effector.forceScale = forceScale,
             to, duration).SetTarget(effector);
 // Use this for initialization
 void Start()
 {
     SE2D = this.GetComponent <SurfaceEffector2D>();
 }
예제 #25
0
 private void Start()
 {
     surfaceEffector = GetComponent <SurfaceEffector2D>();
     //playerRb = Player.gameObject.GetComponent<Rigidbody2D>();
 }
예제 #26
0
파일: Goal.cs 프로젝트: carlw0S/Cabezones
 void Awake()
 {
     se = GetComponent <SurfaceEffector2D>();
 }
예제 #27
0
    /*
     * Returns the X-velocity Gimmick will have on this frame, based on current situation and input.
     *    If speeding up, use NORMALACCEL
     *    If slowing down, use SKIDDECEL
     *    If grounded with no left/right input, use COASTDECEL
     *    If airborne with no left/right input, velocity unchanged
     *    Speed is capped by MAXSPEED
     *    Accounts for being on a moving platform if that moving platform contains a Rigidbody2D component
     */
    public float getXVelocity()
    {
        // Get velocity of any ground Gimmick is standing on
        Rigidbody2D       groundBody   = ground.GetComponent <Rigidbody2D> ();
        SurfaceEffector2D groundEffect = ground.GetComponent <SurfaceEffector2D> ();
        Vector3           parentVel;

        if (groundBody)
        {
            parentVel = groundBody.velocity;
        }
        else if (groundEffect)
        {
            parentVel = new Vector3(groundEffect.speed * ground.transform.localScale.x, 0f, 0f);
        }
        else
        {
            parentVel = new Vector3(0f, 0f, 0f);
        }

        // Convert to local velocity
        Vector3 localVel = ((Vector3)myRigidbody.velocity) - parentVel;
        float   xVel     = localVel.x;

        if (Input.GetAxisRaw("Horizontal") > 0 && canMove)
        {
            // Player inputting "right"
            xInput = RIGHT;
            if (myRigidbody.velocity.x > 0)
            {
                // Speeding up
                xVel = Mathf.Min(xVel + NORMALACCEL * Time.deltaTime, MAXSPEED);
            }
            else
            {
                // Slowing down
                xVel += SKIDDECEL * Time.deltaTime;
            }
        }
        else if (Input.GetAxisRaw("Horizontal") < 0 && canMove)
        {
            // Player inputting "left"
            xInput = LEFT;
            if (myRigidbody.velocity.x < 0)
            {
                // Speeding up
                xVel = Mathf.Max(xVel - NORMALACCEL * Time.deltaTime, -MAXSPEED);
            }
            else
            {
                // Slowing down
                xVel -= SKIDDECEL * Time.deltaTime;
            }
        }
        else
        {
            // No left/right input
            if (isGrounded)
            {
                // Coasting to a stop
                xInput = NEUTRAL;
                if (xVel >= 0)
                {
                    xVel = Mathf.Max(xVel - COASTDECEL * Time.deltaTime, 0f);
                }
                else
                {
                    xVel = Mathf.Min(xVel + COASTDECEL * Time.deltaTime, 0f);
                }
            }             // else airborne with no left/right input, velocity unchanged
        }

        localVel.x = xVel;
        return(xVel + parentVel.x);
    }