Beispiel #1
0
    public void Create(GameMainController mainController, Spring2DManager springManager, Vector2 pos)
    {
        _mainController = mainController;
        _body           = gameObject.GetComponent <MassPoint2D>();
        _body.position  = pos;

        _legList = new List <PlayerLeg>(LEG_NUM);
        for (int i = 0; i < LEG_NUM; i++)
        {
            var inst = Instantiate(_legPrefab);
            inst.Create(springManager);
            _legList.Add(inst);
        }

        var posList = new Vector2[] { new Vector2(1f, 1), new Vector2(-1f, 1), new Vector2(1f, -1), new Vector2(-1f, -1) };

        for (int i = 0; i < LEG_NUM; i++)
        {
            _legList[i].SetPosition(pos, pos + posList[i].normalized * RADIUS);
        }

        for (int i = 0; i < LEG_NUM; i++)
        {
            springManager.Add(_body, _legList[i].first.body, 0, 1.0f);
        }
    }
Beispiel #2
0
    public void Create(Spring2DManager springManager)
    {
        List <PlayerLegJoint> list = new List <PlayerLegJoint>(JOINT_NUM);

        for (int i = 0; i < JOINT_NUM; i++)
        {
            list.Add(Instantiate(_jointPrefab, transform));
        }

        Color ca, cb;

        ColorUtility.TryParseHtmlString("#de7518", out ca);
        ColorUtility.TryParseHtmlString("#fab443", out cb);
        for (int i = 0; i < JOINT_NUM - 1; i++)
        {
            float t = (float)(i) / (JOINT_NUM - 2);
            Color c = Color.Lerp(ca, cb, (float)(i) / JOINT_NUM);
            list[i].Init(list[i + 1].body, c);
        }

        list[JOINT_NUM - 1].SetEdge();
        for (int i = 0; i < JOINT_NUM - 1; i++)
        {
            var a = list[i];
            var b = list[i + 1];
            springManager.Add(a.body, b.body, JOINT_WIDTH, JOINT_SOFTNESS);
        }

        _legJointList = list;
    }
    void Awake()
    {
        _springManager = new Spring2DManager();
        _state         = new StateMachine(State_Ready);

        _player.Create(this, _springManager, _player.transform.position);

        var check = _checkPointRoot.GetComponentsInChildren <CheckPoint>();

        foreach (var i in check)
        {
            i.Create(_springManager);
        }
    }
Beispiel #4
0
    public void Create(Spring2DManager springMapanger)
    {
        for (int i = 0; i < JOINT_NUM; i++)
        {
            var inst = Instantiate(_jointPrefab, transform);
            _jointList.Add(inst);
        }

        Color col = _isGoal ? Color.yellow : Color.white;

        _jointList[0].isKinematic             = true;
        _jointList[0].position                = new Vector2(transform.position.x, -5.0f);
        _jointList[JOINT_NUM - 1].isKinematic = true;
        _jointList[JOINT_NUM - 1].position    = new Vector2(transform.position.x, 5.0f);
        // 終端のオブジェクトを無理やり消す…
        _jointList[JOINT_NUM - 1].GetComponentInParent <PlayerLegJoint>().Init(null, col, true);
        _jointList[JOINT_NUM - 1].transform.Find("View").gameObject.SetActive(false);
        for (int i = 0; i < JOINT_NUM - 1; i++)
        {
            var aa = _jointList[i].GetComponent <PlayerLegJoint>();
            aa?.Init(_jointList[i + 1], col);
            springMapanger.Add(_jointList[i], _jointList[i + 1], 0.5f, 0.1f);
        }
    }