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);
    }
Example #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);
    }
Example #3
0
    public void MoveBoat(BoatControl boatCtrl)
    {
        SSMoveToAction action;

        if (boatCtrl.status == -1)
        {
            action = SSMoveToAction.GetSSMoveToAction(boatCtrl.from, BoatControl.speed);
        }
        else
        {
            action = SSMoveToAction.GetSSMoveToAction(boatCtrl.to, BoatControl.speed);
        }
        boatCtrl.status = -boatCtrl.status;
        AddAction(boatCtrl.boat, action, this);
    }
Example #4
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);
    }
Example #5
0
    public void moveChar(MyCharacterController charCtrl, Vector3 dest, float speed)
    {
        Vector3 middle = dest;
        Vector3 chara  = charCtrl.getGameobj().transform.position;

        if (dest.y < chara.y)
        {
            middle.y = chara.y;
        }
        else
        {
            middle.x = chara.x;
        }

        SSAction action1 = SSMoveToAction.GetSSMoveToAction(middle, speed);
        SSAction action2 = SSMoveToAction.GetSSMoveToAction(dest, speed);

        char_move = SSSequenceAction.GetSSSequenceAction(1, 0, new List <SSAction> {
            action1, action2
        });
        this.RunAction(charCtrl.getGameobj(), char_move, this);
    }
Example #6
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);
    }
Example #7
0
    public void moveChar(MyCharacterController charCtrl, Vector3 dest, float speed)
    {
        //moveable.setDestion()的功能
        Vector3 middle = dest;
        Vector3 chara  = charCtrl.getGameobj().transform.position;

        if (dest.y < chara.y)   // character from bank to boat,说明角色在岸上,可以上船
        {
            middle.y = chara.y;
        }
        else                                                                    // character from boat to bank   说明角色在船上,可以上岸
        {
            middle.x = chara.x;
        }

        SSAction action1 = SSMoveToAction.GetSSMoveToAction(middle, speed);
        SSAction action2 = SSMoveToAction.GetSSMoveToAction(dest, speed);

        char_move = SSSequenceAction.GetSSSequenceAction(1, 0, new List <SSAction> {
            action1, action2
        });
        this.RunAction(charCtrl.getGameobj(), char_move, this);
    }
Example #8
0
 public void moveBoat(BoatController boatCtrl, Vector3 dest, float speed)
 {
     boat_move = SSMoveToAction.GetSSMoveToAction(dest, speed);
     this.RunAction(boatCtrl.getGameobj(), boat_move, this);
 }
Example #9
0
 void addSingleMoving(GameObject sourceObj, Vector3 target, float speed, bool isCatching)
 {
     this.AddAction(sourceObj, SSMoveToAction.GetSSMoveToAction(target, speed, isCatching), this);
 }
Example #10
0
    public void MoveBoat(BoatController boatController)
    {
        SSMoveToAction action = SSMoveToAction.GetSSMoveToAction(boatController.GetDestination(), boatController.boat.movingSpeed);

        AddAction(boatController.boat._Boat, action, this);
    }
Example #11
0
    public void MoveBoat(BoatController boatController)
    {
        SSMoveToAction action = SSMoveToAction.GetSSMoveToAction(boatController.getDestination(), boatController.speed);

        AddAction(boatController.getBoat(), action, this);
    }