void Start()
    {
        gameObject.Play(ShakeAction.Create(minX, maxX, varX, speedX, minY, maxY, varY, speedY, isLocal));

        // Self-destroy
        Destroy(this);
    }
Beispiel #2
0
    void InitJBT_Parallel()
    {
        ColorAction ca = new ColorAction();

        ca.mat       = material;
        ca.totalTime = 3;
        ca.color     = Color.red;

        ShakeAction sa = new ShakeAction();

        sa.transform = transform;
        sa.totalTime = 1.3f;
        sa.Init();

        JBNActionNode ja1 = new JBNActionNode();

        ja1.action = ca;
        JBNActionNode ja2 = new JBNActionNode();

        ja2.action = sa;


        ca           = new ColorAction();
        ca.mat       = material;
        ca.totalTime = 4;
        ca.color     = Color.green;
        JBNActionNode ja3 = new JBNActionNode();

        ja3.action = ca;

        sa           = new ShakeAction();
        sa.totalTime = 1.3f;
        sa.transform = transform;
        sa.Init();
        JBNActionNode ja4 = new JBNActionNode();

        ja4.action = sa;

        JBNParallel r1 = new JBNParallel();

        r1.children.Add(ja1);
        r1.children.Add(ja2);

        JBNSequence r2 = new JBNSequence();

        r2.children.Add(ja3);
        r2.children.Add(ja4);


        jbt      = new JBehaviorTree();
        jbt.root = new JBNSequence();
        jbt.root.children.Add(r1);
        jbt.root.children.Add(r2);
    }
Beispiel #3
0
 void Start()
 {
     //		Graph attenGraph = new Graph((float _x) =>
     //			{
     //				if (_x < 0.5f)
     //					return _x * 2.0f;
     //				else
     //					return _x * -2.0f + 2.0f;
     //			});
     ShakeAction shake = new ShakeAction(transform, 100, 1.5f, Graph.InverseLinear);
     shake.SetShakeByDuration(2.0f, 100);
     ActionHandler.RunAction(shake);
 }
Beispiel #4
0
    void Start()
    {
//		Graph attenGraph = new Graph((float _x) =>
//			{
//				if (_x < 0.5f)
//					return _x * 2.0f;
//				else
//					return _x * -2.0f + 2.0f;
//			});
        ShakeAction shake = new ShakeAction(transform, 100, 1.5f, Graph.InverseLinear);

        shake.SetShakeByDuration(2.0f, 100);
        ActionHandler.RunAction(shake);
    }
Beispiel #5
0
    public void OnEventPlay(int type)
    {
        // 暂定处理 当前动作在进行中时则不接受其他的请求
        if (startPlay)
        {
            return;
        }

        original0 = camera.localPosition;
        original1 = camera.localEulerAngles;

        float speedPlus     = 0.0f;
        float waveMountPlus = 0.0f;

        if (type == 1)
        {
            speedPlus     = 14.0f;
            waveMountPlus = 1.0f;
        }
        else if (type == 2)
        {
            speedPlus     = 17.0f;
            waveMountPlus = 2.0f;
        }
        else if (type == 3)
        {
            speedPlus     = 30.0f;
            waveMountPlus = 1.0f;
        }
        else if (type == 4)
        {
            speedPlus     = 20.0f;
            waveMountPlus = 1.0f;
        }
        else if (type == 5)
        {
            speedPlus     = 20.0f;
            waveMountPlus = 1.0f;
        }

        if (shakeDic.ContainsKey(type))
        {
            speedMount     = speedPlus;
            waveMount      = waveMountPlus;
            currentShake   = shakeDic[type];
            shakeStartTime = Time.realtimeSinceStartup;
            startPlay      = true;
        }
    }
    // Use this for initialization
    void Start()
    {
        parent   = gameObject.transform.parent;
        shakeDic = new Dictionary <int, ShakeAction>();
        for (int index = 1; index <= actionCount; ++index)
        {
            string      goName = "Action" + index.ToString();
            ShakeAction go     = transform.Find(goName).GetComponent <ShakeAction>();
            shakeDic.Add(go.shakeTypeName, go);
        }

        startPlay = false;
        original  = Camera.main.transform.position;
        addEvent();
    }
Beispiel #7
0
    // Use this for initialization
    public void Init(Transform camera)
    {
        this.camera = camera;
        //int actionCount  = camera.childCount;
        int actionCount = 5;

        shakeDic = new Dictionary <int, ShakeAction>();
        for (int index = 1; index <= actionCount; ++index)
        {
            string      goName = "Action" + index.ToString();
            ShakeAction go     = this.camera.Find(goName).GetComponent <ShakeAction>();
            shakeDic.Add(go.shakeTypeName, go);
        }
        startPlay = false;
    }
    public void OnEventPlay(int type)
    {
        // 暂定处理 当前动作在进行中时则不接受其他的请求
        if (startPlay)
        {
            return;
        }

        float speedPlus     = 0.0f;
        float waveMountPlus = 0.0f;

        if (type == 1)
        {
            speedPlus     = 14.0f;
            waveMountPlus = 1.0f;
        }
        else if (type == 2)
        {
            speedPlus     = 17.0f;
            waveMountPlus = 2.0f;
        }
        else if (type == 3)
        {
            speedPlus     = 30.0f;
            waveMountPlus = 1.0f;
        }

        if (shakeDic.ContainsKey(type))
        {
            speedMount     = speedPlus;
            waveMount      = waveMountPlus;
            currentShake   = shakeDic[type];
            shakeStartTime = Time.realtimeSinceStartup;
            startPlay      = true;
        }
    }
Beispiel #9
0
    void InitJBT_Decorator()
    {
        ColorAction ca = new ColorAction();

        ca.mat       = material;
        ca.totalTime = 3;
        ca.color     = Color.red;

        JBNActionNode ja1 = new JBNActionNode();

        ja1.action = ca;


        NumberCondition nc1 = new NumberCondition();

        nc1.SetKonwledgePool(this);
        nc1.Number = 1;
        JBNConditionNode conditionNode1 = new JBNConditionNode();

        conditionNode1.condition = nc1;


        NumberCondition nc2 = new NumberCondition();

        nc2.SetKonwledgePool(this);
        nc2.Number = 3;
        JBNConditionNode conditionNode2 = new JBNConditionNode();

        conditionNode2.condition = nc2;

        JBNDecorator jd = new JBNDecorator();

        jd.DefSuccState(JBTNodeState.succ);
        jd.children.Add(conditionNode2);

        ShakeAction sa = new ShakeAction();

        sa.transform = transform;
        sa.totalTime = 3.0f;
        sa.Init();
        JBNActionNode ja2 = new JBNActionNode();

        ja2.action = sa;


        JBNSequence r1 = new JBNSequence();

        r1.children.Add(conditionNode1);
        r1.children.Add(ja1);

        JBNSequence r2 = new JBNSequence();

        r2.children.Add(jd);
        r2.children.Add(ja2);


        jbt      = new JBehaviorTree();
        jbt.root = new JBNSequence();
        jbt.root.children.Add(r1);
        jbt.root.children.Add(r2);
    }
 private void Awake()
 {
     _fadeAction    = GetComponent <FadeAction>();
     _chatBoxAction = GetComponent <ChatAction>();
     _shakeAction   = GetComponent <ShakeAction>();
 }