Beispiel #1
0
    public override void OnUpdate()
    {
        PlayAnimationFrame++;
        if (PlayAnimationFrame % PlayAnimationFrameInterval != 1)
        {
            return;
        }
        if (mActor != null && mActor.ActorObj != null && mTargetActor != null)
        {
            //先转身
            TSVector mTSVector = (mTargetActor.AllTSTransform.position - mActor.AllTSTransform.position).normalized;
            mActor.RotateTSTransform.rotation = TSQuaternion.LookRotation(mTSVector);
            if (mActor.ActorAnimation != null)
            {
                mActor.ActorAnimation.wrapMode = WrapMode.Loop;
                mActor.ActorAnimation.Play("skill1");
            }

            if (mTargetActor.IsDeath)
            {
                mActor.TryBackMove();
            }
            else
            {
                mActor.Skill_4(mTargetActor);
            }
        }
        else
        {
            mActor.TryBackMove();
        }
    }
Beispiel #2
0
    public override void Skill_3(params object[] param)      //远程箭
    {
        int      inputAngleX = Convert.ToInt32(param[0]);
        int      inputAngleY = Convert.ToInt32(param[1]);
        TSVector mTSVector;

        if (inputAngleX == 0 && inputAngleY == 0)
        {
            mTSVector = new TSVector(Angle.x, FP.Zero, Angle.z);
        }
        else
        {
            mTSVector = new TSVector((FP)inputAngleX / 1000, FP.Zero, (FP)inputAngleY / 1000);
        }
        //houyiBullet houyibullethouyiBullet = WillUsedPrefabs[1].GetComponent<houyiBullet>();
        //houyibullethouyiBullet.ownerIndex = (int)Id;
        //houyibullethouyiBullet.AllTSTransform.position = new TSVector(AllTSTransform.position.x, 1, AllTSTransform.position.z);
        //houyibullethouyiBullet.RotateTSTransform.rotation = TSQuaternion.LookRotation(mTSVector);
        //houyibullethouyiBullet.Angle = mTSVector;
        Debug.LogErrorFormat("Skill_3远程箭==========>{0},{1},{2},OwnerID={3}", inputAngleX, inputAngleY, mTSVector, OwnerID);
        GameObject realObj = TrueSyncManager.SyncedInstantiate(WillUsedPrefabs[1], new TSVector(AllTSTransform.position.x, 1, AllTSTransform.position.z), TSQuaternion.identity);

        realObj.SetActive(true);
        houyiBullet houyibullethouyiBullet2 = realObj.GetComponent <houyiBullet>();

        houyibullethouyiBullet2.RotateTSTransform.rotation = TSQuaternion.LookRotation(mTSVector);
        houyibullethouyiBullet2.Angle = mTSVector;
    }
    public behaviac.EBTStatus BackHome()
    {
///<<< BEGIN WRITING YOUR CODE BackHome
        if (ShowLog)
        {
            Debug.Log("BackHome==>");
        }
        TSVector Angle    = (mBackPosition - AllTSTransform.position).normalized;
        FP       Distance = (mBackPosition - AllTSTransform.position).magnitude;

        if (Distance <= 1)
        {
            AllTSTransform.position = new TSVector(mBackPosition.x, mBackPosition.y, mBackPosition.z);
            _TargetEnemyActor       = null;
            mEnemyActorDict         = new Dictionary <int, Actor>();   //清空
            mActorAttr.Hp           = mActorAttr.HpMax;
            return(behaviac.EBTStatus.BT_SUCCESS);
        }
        else
        {
            AllTSTransform.Translate(Angle * Speed * 2);
            RotateTSTransform.rotation = TSQuaternion.LookRotation(Angle);
            mActorAttr.Hp += 1;
        }
        return(behaviac.EBTStatus.BT_RUNNING);
///<<< END WRITING YOUR CODE
    }
Beispiel #4
0
 public override void Enter(params object[] param)
 {
     mActor = param[0] as Actor;
     object[] param2 = param[1] as object[];
     inputAngleX = (int)(param2[0]);
     inputAngleY = (int)(param2[1]);
     //Debug.LogErrorFormat("Enter==========>{0},{1}", inputAngleX, inputAngleY);
     if (mActor != null && mActor.ActorObj != null)
     {
         //先转身
         TSVector mTSVector;
         if (inputAngleX == 0 && inputAngleY == 0)
         {
             mTSVector = new TSVector(mActor.Angle.x, FP.Zero, mActor.Angle.z);
         }
         else
         {
             mTSVector = new TSVector((FP)inputAngleX / 1000, FP.Zero, (FP)inputAngleY / 1000);
         }
         mActor.RotateTSTransform.rotation = TSQuaternion.LookRotation(mTSVector);
         if (mActor.ActorAnimation != null)
         {
             mActor.ActorAnimation.wrapMode = WrapMode.Loop;
             mActor.ActorAnimation.Play("skill3");
             PlayAnimationFrame = 25;
         }
     }
 }
    public override void PlayerInputHandle_MoveAngle(int inputAngleX, int inputAngleY)
    {
        TSVector mTSVector = new TSVector((FP)inputAngleX / 1000, FP.Zero, (FP)inputAngleY / 1000);

        //TSVector mTSVector2 = new TSVector(-(FP)inputAngleY / 1000, FP.Zero, (FP)inputAngleX / 1000);//(x,y)的法向量就是(-y,x)
        this.Angle = mTSVector;
        //Debug.LogErrorFormat("PlayerInputHandle_MoveAngle======>mTSVector={0}", mTSVector.ToString());
        //RotateTSTransform.LookAt(this.Angle);
        //RotateTSTransform.Rotate(this.Angle);
        RotateTSTransform.rotation = TSQuaternion.LookRotation(mTSVector);
    }
    /// <summary>
    /// Turn the ship to look at a target.
    /// </summary>
    /// <param name="targetin"></param>
    void Look(TSVector targetin)
    {
        TSVector     targetDir       = localtarget - transformts.position;
        TSQuaternion directiontarget = TSQuaternion.LookRotation(targetDir);
        TSQuaternion outputrot       = TSQuaternion.Slerp(transformts.rotation, directiontarget, TrueSyncManager.DeltaTime * turnspeed);

        if (TSQuaternion.Angle(outputrot, lastquaternion) < (TrueSyncManager.DeltaTime * turnspeed) / 2)
        {
            transformts.rotation = outputrot;
        }
        lastquaternion = outputrot;
    }
Beispiel #7
0
        public override void lookAt(TSVector mousePosition)
        {
            if (tsTransform != null)
            {
                TSVector facingDir = mousePosition - tsTransform.position;
                facingDir.y = 0;

                TSQuaternion rot = TSQuaternion.LookRotation(facingDir);
                //tsTransform.rotation = rot;
                tsRigidBody.MoveRotation(rot);
            }
        }
    public void Pursuit()
    {
///<<< BEGIN WRITING YOUR CODE Pursuit
        if (ShowLog)
        {
            Debug.Log("Pursuit==>");
        }
        TSVector Angle = (_TargetEnemyActor.AllTSTransform.position - AllTSTransform.position).normalized;

        AllTSTransform.Translate(Angle * Speed);
        RotateTSTransform.rotation = TSQuaternion.LookRotation(Angle);
///<<< END WRITING YOUR CODE
    }
    /// <summary>
    /// 移动
    /// </summary>
    private void Move()
    {
        if (!(_movX == 0 && _movY == 0))
        {
            bool gotIt = true;
        }

        tsRigidBody.velocity = new TSVector(_movX * speed, 0, _movY * speed);

        // 限制角色移动范围
        tsRigidBody.position = new TSVector(
            TSMath.Clamp(tsRigidBody.position.x, boundary.xMin, boundary.xMax),
            0,
            TSMath.Clamp(tsRigidBody.position.z, boundary.zMin, boundary.zMax)
            );

        // 左右平移时稍微倾斜一下机身(绕 z 轴)
        tsRigidBody.rotation = TSQuaternion.Euler(0, 0, tsRigidBody.velocity.x * -tilt);

        // 旋转方向
        if (_rotX == 0 && _rotY == 0)
        {
            tsTransform.rotation = TSQuaternion.Lerp(tsTransform.rotation, TSQuaternion.identity,
                                                     TrueSyncManager.DeltaTime * rotateSpeed);
        }
        else
        {
            TSVector     joystickKnobPos = new TSVector(_rotX, 0, _rotY);
            TSQuaternion targetRot       = TSQuaternion.LookRotation(joystickKnobPos);
            tsTransform.rotation =
                TSQuaternion.Lerp(tsTransform.rotation, targetRot, TrueSyncManager.DeltaTime * rotateSpeed);
        }

        // 旋转粒子系统
        float r = (float)tsTransform.rotation.eulerAngles.y * Mathf.Deg2Rad;

        if (null != particleSystem1)
        {
            particleSystem1.startRotation = r;
        }
        if (null != particleSystem2)
        {
            particleSystem2.startRotation = r;
        }
    }
    public bool PursuitOrAttack()
    {
///<<< BEGIN WRITING YOUR CODE PursuitOrAttack
        if (ShowLog)
        {
            Debug.Log("PursuitOrAttack==>");
        }
        TSVector Angle    = (_TargetEnemyActor.AllTSTransform.position - AllTSTransform.position);
        FP       Distance = Angle.magnitude;

        RotateTSTransform.rotation = TSQuaternion.LookRotation(Angle);
        if (Distance <= AttackDistance)
        {
            return(true); //攻击
        }
        return(false);    //追击
///<<< END WRITING YOUR CODE
    }