Esempio n. 1
0
File: Gun.cs Progetto: yh821/Zombie
    public override void ShowEffect()
    {
        if (Owner != null && Owner is Hero)
        {
            if (GamingSys.Instance.Player.Bullet > 0)//子弹数判断
            {
                GameObject cCastEffect = EffectManager.Create("GenericMuzzleFlash", true, (Owner as Hero).FirePoint);
                if (null != cCastEffect)
                {
                    cCastEffect.transform.forward = Owner.transform.forward;
                }

                GameObject go = EffectManager.Create("Z_bullet", false);
                go.transform.position = (Owner as Actor).FirePoint.position - (Owner as Actor).FirePoint.forward;
                FlyBullet bullet = go.AddUniqueComponent <FlyBullet>();
                bullet.Skill   = this;
                bullet.Forward =
                    XUtility.DirectionNoY((Owner as Actor).AttackTarget.position - go.transform.position).normalized;
                bullet.LayerMask = mCollisionMask ^ (1 << Owner.gameObject.layer);
                bullet.EnterScene();
                GamingSys.Instance.Player.Bullet--;
            }
            else
            {
                GamingSys.Instance.Player.ChangeWeapon();
            }
        }
    }
Esempio n. 2
0
    protected Vector3 CommonMove()
    {
        NextPace = MovingSpeed * Time.deltaTime;

        if (XUtility.DistanceNoY(transform.position, NavMeshPosition) <= 0.1f ||
            ToCorner == mNavMeshPath.corners.Length ||
            (NextPace >= LeftLength && ToCorner == mNavMeshPath.corners.Length - 1))
        {
            if (!IsClearTargetPosition)
            {
                // 清除行走目标方向,停下,恢复Idle,到达目的地
                StopMoveToPoint();

                transform.position = NavMeshPosition;
                LeftLength         = 0;

                if (MoveEndCallBack != null)
                {
                    MoveEndCallBack();
                    MoveEndCallBack = null;
                }
            }
        }
        else if (mNavMeshPath.corners.Length > 0 &&
                 (XUtility.DistanceNoY(transform.position, mNavMeshPath.corners[ToCorner]) <= 0.1f || (NextPace > LeftLength)))
        {
            if (!IsClearTargetPosition)
            {
                //到达拐点
                transform.position = mNavMeshPath.corners[ToCorner];
                ToCorner++;

                if (ToCorner < mNavMeshPath.corners.Length)
                {
                    transform.LookAt(mNavMeshPath.corners[ToCorner]);
                    LeftLength = XUtility.DistanceNoY(transform.position, mNavMeshPath.corners[ToCorner]);
                }
            }
        }
        else if (!IsClearTargetPosition && ToCorner < mNavMeshPath.corners.Length)
        {
            // 继续走
            MovingDirection = XUtility.DirectionNoY(mNavMeshPath.corners[ToCorner] - transform.position).normalized;
        }

        return(MovingSpeed * MovingDirection);
    }
Esempio n. 3
0
File: Hero.cs Progetto: yh821/Zombie
    public override bool MoveToAttackTarget()
    {
        if (AttackTarget == null)
        {
            return(false);
        }

        //先暂用网格导航移动方式,后面再加其他移动方式
        Vector3 dire = XUtility.DirectionNoY(transform.position - AttackTarget.transform.position);

        if (dire.magnitude > CurSkill.Attr.AttackDist)
        {
            ControllerNavMeshMove(AttackTarget.transform.position + dire.normalized * CurSkill.Attr.AttackDist);
        }

        return(true);
    }
Esempio n. 4
0
File: Hero.cs Progetto: yh821/Zombie
    public override void OnUpdate()
    {
        base.OnUpdate();

        if (IsDead)
        {
            AttackTarget = null;
            FollowTarget = null;
            return;
        }

        #region 刷新动作
        if (null != FollowTarget)
        {
            mDeltaTime += Time.deltaTime;
            if (mDeltaTime >= 0.2f)
            {
                mDeltaTime = 0;
                SetFloat("runSpeed", XUtility.DistanceNoY(mLastPostion, transform.position));
                mLastPostion = transform.position;
            }

            if (AttackTarget != null && CurSkill.Data.kind == (int)Skill.ESkillKind.Hot)
            {
                mShotDire = XUtility.DirectionNoY(AttackTarget.transform.position - transform.position);
                if (mShotDire.magnitude != 0)
                {
                    Controller.transform.forward = mShotDire.normalized;
                    mMoveDire = XUtility.DirectionNoY(FollowPoint - transform.position);
                    Vector3 dire = Controller.transform.InverseTransformDirection(mMoveDire.normalized);
                    SetFloat("runDirX", dire.x);
                    SetFloat("runDirZ", dire.z);
                }
            }
        }
        #endregion
    }