Beispiel #1
0
    public void addRandomAction(GameObject gameObj)
    {
        Vector3 force = new Vector3(
            UnityEngine.Random.Range(-10, 10),
            UnityEngine.Random.Range(-10, 10),
            UnityEngine.Random.Range(-10, 10)
            );

        int[] X = { -20, 20 };
        int[] Y = { -5, 5 };
        int[] Z = { -20, -20 };

        Vector3 starttPos = new Vector3(
            UnityEngine.Random.Range(-70, 70),
            UnityEngine.Random.Range(-10, 10),
            UnityEngine.Random.Range(100, 150)
            );

        gameObj.transform.position = starttPos;

        Vector3 randomTarget = new Vector3(
            X[UnityEngine.Random.Range(0, 2)],
            Y[UnityEngine.Random.Range(0, 2)],
            Z[UnityEngine.Random.Range(0, 2)]
            );

        gameObj.GetComponent <Rigidbody> ().velocity = Vector3.zero;
        gameObj.GetComponent <Rigidbody> ().AddForce(force, ForceMode.Impulse);
        MoveToAction action = MoveToAction.getAction(randomTarget, gameObj.GetComponent <UFOData>().speed);

        RunAction(gameObj, action, this);
    }
Beispiel #2
0
    public void addRandomAction(GameObject gameObj)
    {
        int[] X = { -20, 20 };
        int[] Y = { -5, 5 };
        int[] Z = { -20, -20 };

        // 随机生成起始点和终点
        Vector3 starttPos = new Vector3(
            UnityEngine.Random.Range(-70, 70),
            UnityEngine.Random.Range(-10, 10),
            UnityEngine.Random.Range(100, 150)
            );

        gameObj.transform.position = starttPos;

        Vector3 randomTarget = new Vector3(
            X[UnityEngine.Random.Range(0, 2)],
            Y[UnityEngine.Random.Range(0, 2)],
            Z[UnityEngine.Random.Range(0, 2)]
            );

        MoveToAction action = MoveToAction.getAction(randomTarget, gameObj.GetComponent <DiskData>().speed);

        RunAction(gameObj, action, this);
    }
    public void getOnBoat(GameObject people, int shore, int seat)
    {
        if (shore == 0 && seat == 0)
        {
            horizontal = MoveToAction.getAction(new Vector3(-5f, 2.7f, 0), speed); //右移
            vertical   = MoveToAction.getAction(new Vector3(-5f, 1.2f, 0), speed); //下移
        }
        else if (shore == 0 && seat == 1)
        {
            horizontal = MoveToAction.getAction(new Vector3(-3f, 2.7f, 0), speed); //右移
            vertical   = MoveToAction.getAction(new Vector3(-3f, 1.2f, 0), speed); //下移
        }
        else if (shore == 1 && seat == 0)
        {
            horizontal = MoveToAction.getAction(new Vector3(3f, 2.7f, 0), speed); //左移
            vertical   = MoveToAction.getAction(new Vector3(3f, 1.2f, 0), speed); //下移
        }
        else if (shore == 1 && seat == 1)
        {
            horizontal = MoveToAction.getAction(new Vector3(5f, 2.7f, 0), speed); //左移
            vertical   = MoveToAction.getAction(new Vector3(5f, 1.2f, 0), speed); //下移
        }

        SequenceAction saction = SequenceAction.getAction(0, 0, new List <SSAction> {
            horizontal, vertical
        });                                                                                                  //将动作组合

        this.Action(people, saction, this);
    }
    public void addRandomAction(GameObject gameObj)
    {
        int[] X = { -20, 20 };
        int[] Y = { -5, 5 };
        int[] Z = { -20, -20 };


        Vector3 starttPos = new Vector3(
            UnityEngine.Random.Range(-20, 20),
            UnityEngine.Random.Range(-20, 20),
            0
            );

        gameObj.transform.position = starttPos;

        /*Vector3 randomTarget = new Vector3(
         *      X[UnityEngine.Random.Range(0, 2)],
         *      Y[UnityEngine.Random.Range(0, 2)],
         *      Z[UnityEngine.Random.Range(0, 2)]
         * );*/

        MoveToAction action = MoveToAction.getAction(new Vector3(starttPos.x > 0? -20 :20, starttPos.y > 0? -20 :20, 0), gameObj.GetComponent <DiskData>().speed);

        RunAction(gameObj, action, this);
    }
    public void getOffBoat(GameObject people, int shoreNum)
    {
        horizontal = MoveToAction.getAction(new Vector3(people.transform.position.x, 2.7f, 0), speed);//上移

        if (shoreNum == 0)
        {
            vertical = MoveToAction.getAction(new Vector3(-16f + 1.5f * Convert.ToInt32(people.name), 2.7f, 0), speed);               //左移
        }
        else
        {
            vertical = MoveToAction.getAction(new Vector3(16f - 1.5f * Convert.ToInt32(people.name), 2.7f, 0), speed); //右移
        }
        SequenceAction saction = SequenceAction.getAction(0, 0, new List <SSAction> {
            horizontal, vertical
        });                                                                                                  //将动作组合

        this.Action(people, saction, this);
    }
Beispiel #6
0
    public void addRandomAction(GameObject gameObj, float speed)
    {
        Vector3 currentPos    = gameObj.transform.position;
        Vector3 randomTarget1 = new Vector3(
            Random.Range(currentPos.x - 7, currentPos.x + 7),
            Random.Range(1, currentPos.y + 5),
            Random.Range(currentPos.z - 7, currentPos.z + 7)
            );
        MoveToAction moveAction1 = MoveToAction.getAction(randomTarget1, speed);

        Vector3 randomTarget2 = new Vector3(
            Random.Range(currentPos.x - 7, currentPos.x + 7),
            Random.Range(1, currentPos.y + 5),
            Random.Range(currentPos.z - 7, currentPos.z + 7)
            );
        MoveToAction moveAction2 = MoveToAction.getAction(randomTarget2, speed);

        SequenceAction sequenceAction = SequenceAction.getAction(new List <ObjAction> {
            moveAction1, moveAction2
        }, -1);

        addAction(gameObj, sequenceAction, this);
    }
 public void moveBoat(GameObject boat)
 {
     horizontal = MoveToAction.getAction((boat.transform.position == new Vector3(4, 0, 0) ? new Vector3(-4, 0, 0) : new Vector3(4, 0, 0)), speed);
     this.Action(boat, horizontal, this);
 }