Пример #1
0
    public void MoveCharacter(MyNamespace.CharacterController characterCtrl, Vector3 destination)
    {
        Vector3 currentPos = characterCtrl.character.Role.transform.position;
        Vector3 middlePos  = currentPos;

        //采用线段式的折线运动
        //终点纵坐标小,则为从岸上船
        //否则,从船上岸
        if (destination.y > currentPos.y)
        {
            middlePos.y = destination.y;
        }
        else
        {
            middlePos.x = destination.x;
        }
        SSAction action1 = SSMoveToAction.GetSSMoveToAction(middlePos, characterCtrl.character.movingSpeed);
        SSAction action2 = SSMoveToAction.GetSSMoveToAction(destination, characterCtrl.character.movingSpeed);
        //动作队列完成上船或上岸动作
        SSAction seqAction = SequenceAction.GetSequenceAction(1, 0, new List <SSAction> {
            action1, action2
        });

        AddAction(characterCtrl.character.Role, seqAction, this);
    }
Пример #2
0
    void addCombinedMoving(GameObject sourceObj, Vector3[] target, float[] speed, bool isCatching)
    {
        List <SSAction> acList = new List <SSAction>();

        for (int i = 0; i < target.Length; i++)
        {
            acList.Add(SSMoveToAction.GetSSMoveToAction(target[i], speed[i], isCatching));
        }
        SequenceAction MoveSeq = SequenceAction.GetSequenceAction(acList);

        this.AddAction(sourceObj, MoveSeq, this);
    }
Пример #3
0
    public void MoveCharacter(myGame.MyCharacterController characterCtrl, Vector3 destination)
    {
        Vector3 currentPos = characterCtrl.getPosition();
        Vector3 middlePos  = currentPos;

        if (destination.y > currentPos.y)
        {
            middlePos.y = destination.y;
        }
        else
        {
            middlePos.x = destination.x;
        }
        SSAction action1   = SSMoveToAction.GetSSMoveToAction(middlePos, characterCtrl.speed);
        SSAction action2   = SSMoveToAction.GetSSMoveToAction(destination, characterCtrl.speed);
        SSAction seqAction = SequenceAction.GetSequenceAction(1, 0, new List <SSAction> {
            action1, action2
        });

        AddAction(characterCtrl.getCharacter(), seqAction, this);
    }
Пример #4
0
    public void MoveItem(ItemControl itemCtrl, Vector3 finalDes)
    {
        //Debug.Log("enter MoveItem!");
        float   time = 3;
        float   g    = -10;
        Vector3 v0;
        float   vy_ByGravity = 0;
        float   stepTime     = 0.1f;
        Vector3 currentDes   = itemCtrl.item.transform.position;

        List <SSAction> divide = new List <SSAction>();

        // the des here is the final des
        v0 = new Vector3((finalDes.x - itemCtrl.item.transform.position.x) / time,
                         (finalDes.y - itemCtrl.item.transform.position.y) / time - 0.5f * g * time, (finalDes.z - itemCtrl.item.transform.position.z) / time);
        //Debug.Log(v0);
        //Debug.Log(time / stepTime);


        // divide the curve to many parts
        for (int i = 0; i < time / stepTime - 1; i++)
        {
            //Debug.Log(divide[i]);
            //Debug.Log(currentDes);
            // change the vy
            vy_ByGravity += g * stepTime;
            // set current des
            currentDes   += v0 * stepTime;
            currentDes.y += vy_ByGravity * stepTime;
            // get the current speed
            float currentSpeed = Mathf.Sqrt(v0.x * v0.x + (v0.y + vy_ByGravity) * (v0.y + vy_ByGravity));
            // add one of the movements
            SSAction temp = SSMoveToAction.GetSSMoveToAction(currentDes, currentSpeed * 10);
            divide.Add(temp);
        }
        SSAction seqAction = SequenceAction.GetSequenceAction(1, 0, divide);

        AddAction(itemCtrl.item, seqAction, this);
    }