Ejemplo n.º 1
0
    /// <summary>
    /// 尽量避免使用Awake等unity控制流程的接口来初始化,而改用自己调用的接口 by吴江
    /// </summary>
    protected override void Init()
    {
        height     = actorInfo.NameHeight;
        nameHeight = height;
        base.Init();
        if (headTextCtrl == null)
        {
            headTextCtrl = this.gameObject.AddComponent <HeadTextCtrl>();
        }
        animFSM = base.animFSM as PlayerAnimFSM;
        if (animFSM == null)
        {
            animFSM = this.gameObject.GetComponentInChildrenFast <PlayerAnimFSM>(true);
        }

        rendererCtrl = base.rendererCtrl as PlayerRendererCtrl;
        if (rendererCtrl == null)
        {
            rendererCtrl = this.gameObject.GetComponentInChildrenFast <PlayerRendererCtrl>(true);
        }



        ActiveBoxCollider(true, actorInfo.ColliderRadius);
        rendererCtrl.Init(actorInfo, fxCtrl);
        animationRoot.gameObject.transform.localScale *= actorInfo.ModelScale;

        if (animFSM != null)
        {
            animFSM.SetMoveSpeed(CurRealSpeed / (actorInfo.AnimationMoveSpeedBase * actorInfo.ModelScale));
            animFSM.OnDeadEnd = OnDeadEnd;
        }

        ReBuildMount();
        GameObject obj = new GameObject("ShokWaveObj");

        obj.transform.parent           = this.transform;
        obj.transform.localPosition    = Vector3.zero;
        obj.transform.localEulerAngles = Vector3.zero;
        AfsShockWave afsShockWave = obj.AddComponent <AfsShockWave>();

        afsShockWave.ShockSpeed = 1.0f;
        afsShockWave.ShockPower = 1.0f;
        afsShockWave.ShockDelay = 1.0f;
        Rigidbody rigidbody = obj.AddComponent <Rigidbody>();

        rigidbody.useGravity  = false;
        rigidbody.isKinematic = true;
    }
Ejemplo n.º 2
0
 public void SwapTouchBending()
 {
     Player_ID          = Player1_ID;
     PlayerVars         = PlayerVars1;
     Player_Direction   = Player_Direction1;
     Player_Speed       = Player_Speed1;
     intialTouchForce   = intialTouchForce1;
     touchBending       = touchBending1;
     targetTouchBending = targetTouchBending1;
     easingControl      = easingControl1;
     left     = left1;
     finished = finished1;
     axis     = axis1;
     timer    = timer1;
 }
Ejemplo n.º 3
0
    void OnTriggerEnter(Collider other)
    {
        if (!hasInit)
        {
            Init();
            hasInit = true;
        }

        AfsShockWave tempPlayerVars = other.GetComponent <AfsShockWave>();

        // register touch only if collider has the touchBendingPlayerListener script attached and enabled
        if (tempPlayerVars != null && tempPlayerVars.enabled)
        {
            // no other touch event registered
            if (!touched)
            {
                //register gameobject ID
                Player_ID = other.GetInstanceID();

                Destroy(myRenderer.material);

                PlayerVars       = tempPlayerVars;
                Player_Direction = myTransform.position - PlayerVars.transform.position;
                Player_Speed     = PlayerVars.ShockSpeed;
                intialTouchForce = Player_Speed;

                // instantiate mat
                myRenderer.material = touchBendingMaterial;
                myRenderer.material.SetVector("_TouchBendingPosition", new Vector4(myTransform.position.x, myTransform.position.y, myTransform.position.z, 0f));

                axis = Player_Direction;
                // rotate by 90
                axis = Quaternion.Euler(0, 90, 0) * axis;

                timer              = 0.0f;
                touched            = true;
                left               = false;
                targetTouchBending = 1.0f;
                touchBending       = targetTouchBending;
                finished           = false;
            }
            else
            {
                /// 2nd+ touch: we simply drop the first registered collision
                if (doubletouched == true)
                {
                    SwapTouchBending();
                }
                //register gameobject ID
                Player1_ID = other.GetInstanceID();

                PlayerVars1       = tempPlayerVars;
                Player_Direction1 = Player_Direction;
                Player_Speed1     = PlayerVars1.ShockSpeed;
                intialTouchForce1 = Player_Speed1;

                axis1 = Player_Direction1;
                // rotate by 90
                axis1 = Quaternion.Euler(0, 90, 0) * axis1;

                timer1 = 0.0f;
                left1  = false;
                targetTouchBending1 = 1.0f;
                touchBending1       = targetTouchBending1;
                finished1           = false;
                lerptime            = duration - timer;
                doubletouched       = true;
            }
        }
    }