Пример #1
0
    public virtual bool Move(PlayerCharacter player)
    {
        if (Type == ObjectType.Stair)
        {
            return(false);
        }
        if (CommonFunction.IsNull(ThrowPoint) == true)
        {
            return(false);
        }
        //目標位置の取得
        Vector3 target = new Vector3(ThrowPoint.X * PositionUnit,
                                     PosY,
                                     ThrowPoint.Y * PositionUnit);

        //距離が一定以上あったらアクションさせない
        if (Vector3.Distance(player.ThisTransform.position, this.ThisTransform.position) > 6)
        {
            //強制的にキャラポジを移動させて終了
            ThisTransform.localPosition = target;
        }

        //目標地点に到着したら終了
        if (Vector3.Distance(ThisTransform.localPosition, target) <= MinDistance)
        {
            //投擲位置に達したらキャラクタコンポーネントを削除し現在位置を強制移動
            //if(ThisDisplayObject.GetComponent<CharacterController>())
            //{
            //    Destroy(ThisDisplayObject.GetComponent<CharacterController>());
            //}
            ResetObjectPosition();

            ThrowPoint = null;
            return(false);
        }

        //移動単位の取得
        Vector3 velocity = (target - ThisTransform.localPosition).normalized;

        //移動方向と移動単位が一致するか調べる
        if (CommonFunction.CheckDirectionVector(Direction, velocity) == true)
        {
            //一致していれば通常の移動操作

            //キャラクターを目標に移動
            //ThisDisplayObject.transform.localPosition += (velocity * MoveSpeed);
            //ThisDisplayObject.transform.localPosition += CommonFunction.GetVelocity(velocity, MoveSpeed);
            ThisTransform.Translate(CommonFunction.GetVelocity(velocity, MoveSpeed), Space.World);
        }
        else
        {
            //一致していなければ目標地点を追い越したとみなす
            //強制的にキャラポジを移動させて終了
            ThisTransform.localPosition = target;
        }
        return(true);
    }
Пример #2
0
    void Awake()
    {
        this.CacheTransform();

        m_heroCharactorController = ThisTransform.GetComponent <CharacterController>();
        RefreshRenderCach();
        m_skills = GetComponents <SkillBase>().ToList();
        NormalAttackButtonPress = false;
    }
Пример #3
0
    /// <summary>
    /// 対象オブジェクトの現在位置を再設定する
    /// </summary>
    public virtual void ResetObjectPosition()
    {
        ThisTransform.localPosition = new Vector3(CurrentPoint.X * PositionUnit,
                                                  PosY,
                                                  CurrentPoint.Y * PositionUnit);

        Transform tar = ThisTransform.Find("Body");

        if (CommonFunction.IsNull(tar) == false)
        {
            tar.localPosition = Vector3.zero;
        }
    }
Пример #4
0
    /// <summary>
    /// 刷新玩家自身与装备的Renderer列表
    /// </summary>
    public void RefreshRenderCach()
    {
        List <PlayDataStruct <Renderer> >            partRenderer;
        List <PlayDataStruct <SkinnedMeshRenderer> > mainRenderer;

        ThisTransform.RecursiveGetComponent <Renderer>("Renderer", out partRenderer);
        ThisTransform.RecursiveGetComponent <SkinnedMeshRenderer>("SkinnedMeshRenderer", out mainRenderer);

        if (this.m_monsterRendererDatas == null)
        {
            this.m_monsterRendererDatas = new List <Renderer>();
        }
        this.m_monsterRendererDatas.Clear();

        this.m_monsterRendererDatas.AddRange(partRenderer.Select(P => P.AnimComponent));
        this.m_monsterRendererDatas.AddRange(mainRenderer.Select(P => (Renderer)P.AnimComponent));
    }
Пример #5
0
    protected override IEnumerator STATE()
    {
        _damageReceiver.ActiveLogic();
        if (string.IsNullOrEmpty(_soundFx))
        {
            _sfxAudioSource = SoundManager.Instance.PlaySoundEffect(_soundFx, true);
        }
        Transform leftHand  = _owner._avatarController.GetSlotNode(EnumEquipSlot.weapon_left);
        Transform rightHand = _owner._avatarController.GetSlotNode(EnumEquipSlot.weapon_right);

        while (!_isDead)
        {
            // ami to forward.
            Vector3 origin = (leftHand.position + rightHand.position) / 2.0f;
            Vector3 dir    = _owner.ThisTransform.forward;
            ThisTransform.position = origin;
            ThisTransform.LookAt(origin + dir * _range);
            Vector3 scale = _lineTransform.localScale;
            scale.z = _range;
            RaycastHit hitInfo;
            if (Physics.Raycast(origin, dir, out hitInfo, _range, _mask))
            {
                scale.z = (hitInfo.point - origin).magnitude;
            }
            _lineTransform.localScale = scale;
            // hurt enemys.
            foreach (EnemyInRange e in _enemys)
            {
                e._timer -= Time.deltaTime;
                if (e._timer <= 0.0f && e._ac.IsAlived)
                {
                    _fastCommand._param2 = e._ac;
                    CommandManager.Instance.SendFast(ref _fastCommand, e._ac);
                    IsHitSomeone(_owner, this, _damageType, e._ac);
                    e._timer = _hurtStep;
                }
            }
            yield return(null);
        }

        Dead();
    }
Пример #6
0
    /// <summary>
    /// °ÑÖ÷œÇµÄ×ø±êÉú³ÉÊýŸÝ°ü
    /// </summary>
    /// <returns></returns>
    public Package GetSendInfoPkg()
    {
        ThisTransform.position.SetToServer(out this.m_SMsgActionMove_SC.floatX, out this.m_SMsgActionMove_SC.floatY);

        var direct = ThisTransform.TransformDirection(Vector3.forward);

        this.m_SMsgActionMove_SC.fDirectX = direct.x;
        this.m_SMsgActionMove_SC.fDirectY = -direct.z;

        this.m_SMsgActionMove_SC.uidEntity = this.RoleDataModel.SMsg_Header.uidEntity;
        this.m_SMsgActionMove_SC.dwMapID   = GameManager.Instance.GetCurSceneMapID;
        if (m_FSMSystem.CurrentStateID == StateID.PlayerIdle)
        {
            this.m_SMsgActionMove_SC.fSpeed = 0.0f;
        }
        else if (m_FSMSystem.CurrentStateID == StateID.PlayerRun)
        {
            this.m_SMsgActionMove_SC.fSpeed = ((PlayerRunState)m_FSMSystem.CurrentState).CurrentMoveSpeed * 10.0f;
        }


        return(this.m_SMsgActionMove_SC.GeneratePackage(MasterMsgType.NET_ROOT_THING, CommonMsgDefineManager.MSG_ACTION_MOVE));
    }
Пример #7
0
    //public void SetArrowBehaviour(ArrowBehaviour arrowBehaviour)
    //{
    //    this.m_ArrowBehaviour = arrowBehaviour;
    //}

    public void EntityMove(SMsgActionMove_SCS sMsgActionMove)
    {
        monsterMoveNodes.Add(new Vector3(sMsgActionMove.floatX / 10.0f, 0.1f, sMsgActionMove.floatY / -10.0f));

        if (m_FSMSystem.CurrentStateID == StateID.MonsterBeHitFly ||
            m_FSMSystem.CurrentStateID == StateID.MonsterStand ||
            m_FSMSystem.CurrentStateID == StateID.MonsterBeAttacked ||
            m_FSMSystem.CurrentStateID == StateID.MonsterAttack)

        {
            TraceUtil.Log(SystemModel.Common, TraceLevel.Error, "wrong node");
            return;
        }

        if (this.RoleDataModel.SMsg_Header.uidEntity == sMsgActionMove.uidEntity && MonsterBehaviour.UsePathSmooth)
        {
            m_currentNode = sMsgActionMove;
            Vector2 lastPos    = new Vector2(m_lastNode.floatX, m_lastNode.floatY);
            Vector2 currentPos = new Vector2(ThisTransform.position.x * 10.0f, ThisTransform.position.z * (-10.0f));
            if (m_currentNode.fSpeed > 0.1f)           //Vector2.Distance( currentPos , lastPos) > 0.1f && lastPos != Vector2.zero)
            {
                if (m_FSMSystem.CurrentStateID == StateID.MonsterIdle)
                {
                    m_smooth.Init(ThisTransform.position,
                                  ThisTransform.TransformDirection(Vector3.forward) * WalkSpeed,
                                  new Vector3(sMsgActionMove.floatX / 10.0f, 0, -sMsgActionMove.floatY / 10.0f),
                                  new Vector3(sMsgActionMove.fDirectX, 0, -sMsgActionMove.fDirectY) * sMsgActionMove.fSpeed / 10.0f,
                                  ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    nodes.Clear();
                    for (int i = 0; i <= 10; i++)
                    {
                        Vector3 nodepos = m_smooth.GetCurrentPos(0.1f * i);
                        nodes.Add(new Vector3(nodepos.x, 1, nodepos.z));
                    }


                    m_FSMSystem.PerformTransition(Transition.MonsterToMove);
                    MonsterMoveState state = (MonsterMoveState)m_FSMSystem.CurrentState;
                    state.ResetSmooth(ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                }
                else if (m_FSMSystem.CurrentStateID == StateID.MonsterMove)
                {
                    MonsterMoveState state = (MonsterMoveState)m_FSMSystem.CurrentState;
                    state.ResetSmooth(ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    m_smooth.Init(ThisTransform.position,
                                  ThisTransform.TransformDirection(Vector3.forward) * WalkSpeed,
                                  new Vector3(sMsgActionMove.floatX / 10.0f, 0, -sMsgActionMove.floatY / 10.0f),
                                  new Vector3(sMsgActionMove.fDirectX, 0, -sMsgActionMove.fDirectY) * sMsgActionMove.fSpeed / 10.0f,
                                  ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    nodes.Clear();
                    for (int i = 0; i <= 10; i++)
                    {
                        Vector3 nodepos = m_smooth.GetCurrentPos(0.1f * i);
                        nodes.Add(new Vector3(nodepos.x, 1, nodepos.z));
                    }
                }

                m_clientEndPos = null;
                ClientMove     = true;
            }
            else
            {
                m_clientEndPos = new Vector3(CurrentNode.floatX / 10.0f, 0, CurrentNode.floatY / -10.0f);
                ClientMove     = false;
            }
            m_lastNode = m_currentNode;
        }

        WalkToPosition = ThisTransform.position;
        WalkToPosition = WalkToPosition.Value.GetFromServer(sMsgActionMove.floatX, 0.1f, sMsgActionMove.floatY, -0.1f);
    }
Пример #8
0
 private void GetMeshRenderer()
 {
     m_MonsterMeshRenderer = ThisTransform.GetComponentInChildren <SkinnedMeshRenderer>();
 }
Пример #9
0
    //must not be override by any other child class
    public void Fire(ActionController target, Transform firePoint, int angleOffset, int angleOffsetY, float lifeTime, RangerAgent.FirePort rfp)
    {
        _isDead = false;
        _attackInfo._isFromSkill = rfp.IsFromSkill;

        _lifeTime                       = lifeTime;
        _deadTime                       = -1;
        _target                         = target;
        _isFrom2P                       = _owner.IsClientPlayer;
        ThisObject.layer                = (int)_faction + 1;
        _firePoint                      = firePoint;
        _step                           = 0;
        _attackInfo._attackPoints       = _owner.TotalAttackPoints;
        _attackInfo._criticalChance     = _owner.Data.TotalCritRate;
        _attackInfo._criticalDamage     = _owner.Data.TotalCritDamage;
        _attackInfo._skillTriggerChance = _owner.Data.TotalSkillTriggerRate;
        _attackInfo._skillAttackDamage  = _owner.Data.TotalSkillAttackDamage;
        _attackInfo._pushStrength       = _pushStrength;
        _attackInfo._pushTime           = _pushTime;
        _attackInfo._pushAngle          = _pushAngle;
        _attackInfo._pushByPoint        = _pushByPoint;
        RangerAgent.FireRangeInfo fri = rfp._rangeInfo;
        if (angleOffsetY != 0)
        {
            _enableSpeedY = true;
            _fireAngleY   = angleOffsetY;
        }
        if (fri != null)
        {
            _attackInfo._effectTime = fri._effectTime;
        }
        //_damageScale = rfp.DamageScale;
        if (!_owner.IsPlayer && _owner.ACGetCurrentAttack() != null)
        {
            _attackInfo._damageScale = _damageScale * _owner.ACGetCurrentAttack().DamageScale;
        }
        else
        {
            _attackInfo._damageScale = _damageScale * rfp.DamageScale;
        }
        if (_firePorts != null && _firePorts.Length != 0)
        {
            foreach (RangerAgent.FirePort pt in _firePorts)
            {
                pt.IsFromSkill = rfp.IsFromSkill;
                pt.DamageScale = _attackInfo._damageScale;
            }
        }

        ThisTransform.localPosition = firePoint.position;
        if (rfp._shootByFirePointDirection)
        {
            ThisTransform.forward = firePoint.forward;
        }
        else if (target != null)
        {
            if (target.ThisTransform.localPosition != ThisTransform.localPosition)
            {
                Vector3 d3 = target.ThisTransform.localPosition - ThisTransform.localPosition;
                d3.y = 0;
                ThisTransform.forward = d3;
            }
            else
            {
                ThisTransform.forward = _owner.ThisTransform.forward;
            }
        }
        else
        {
            ThisTransform.forward = _owner.ThisTransform.forward;
        }
        if (angleOffset != 65535)
        {
            ThisTransform.Rotate(new Vector3(0, angleOffset, 0));
        }
        if (rfp.IsOverride && _hitInfo != null && _hitInfo.Length > 0)
        {
            foreach (Eot eot in _hitInfo[_step]._eots)
            {
                eot.lastTime = rfp.DotDamageTime;
            }
        }
        //add record to remeber ther port name
        // for if some one want to kill bullet
        _firePortName = rfp._portName;
        ActiveLogic(rfp);
    }
Пример #10
0
 private void Update()
 {
     ThisTransform.Translate(ThisTransform.forward * _speed * Time.deltaTime, Space.World);
 }
Пример #11
0
    /// <summary>
    /// ÊÕµœœÇÉ«Òƶ¯Ð­Òé°ü
    /// </summary>
    /// <param name="notifyArgs"></param>
    public void EntityMove(SMsgActionMove_SCS sMsgActionMove_SC)
    {
        if (this.RoleDataModel.SMsg_Header.uidEntity == sMsgActionMove_SC.uidEntity)
        {
            //正常情况下这个实体移动消息不会发给主角,如果是主角说明服务器需要进行位置同步
            if (this.IsHero)
            {
                transform.position = new Vector3(0, 0.1f, 0);
                transform.position = transform.position.GetFromServer(sMsgActionMove_SC.floatX, sMsgActionMove_SC.floatY);

                return;
            }
            if (this.FSMSystem.CurrentStateID != StateID.PlayerIdle &&
                this.FSMSystem.CurrentStateID != StateID.PlayerRun)
            {
                return;
            }

            if (this.IsDie)
            {
                return;
            }

            if (sMsgActionMove_SC.fSpeed > 0.1f)
            {
                if (m_FSMSystem.CurrentStateID == StateID.PlayerIdle)
                {
                    m_smooth.Init(ThisTransform.position,
                                  ThisTransform.TransformDirection(Vector3.forward) * sMsgActionMove_SC.fSpeed / 10.0f,
                                  new Vector3(sMsgActionMove_SC.floatX / 10.0f, 0, -sMsgActionMove_SC.floatY / 10.0f),
                                  new Vector3(sMsgActionMove_SC.fDirectX, 0, -sMsgActionMove_SC.fDirectY) * sMsgActionMove_SC.fSpeed / 10.0f,
                                  ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    for (int i = 0; i <= 10; i++)
                    {
                        Vector3 nodepos = m_smooth.GetCurrentPos(0.1f * i);
                        nodes.Add(new Vector3(nodepos.x, 1, nodepos.z));
                    }

                    m_FSMSystem.PerformTransition(Transition.PlayerToTarget);
                    PlayerRunState state = (PlayerRunState)m_FSMSystem.CurrentState;
                    state.MoveMode = GetMoveModeBySpeed(sMsgActionMove_SC.fSpeed / 10.0f);
                    state.ResetSmooth(ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                }
                else if (m_FSMSystem.CurrentStateID == StateID.PlayerRun)
                {
                    PlayerRunState state = (PlayerRunState)m_FSMSystem.CurrentState;
                    state.MoveMode = GetMoveModeBySpeed(sMsgActionMove_SC.fSpeed / 10.0f);
                    state.ResetSmooth(ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    m_smooth.Init(ThisTransform.position,
                                  ThisTransform.TransformDirection(Vector3.forward) * sMsgActionMove_SC.fSpeed / 10.0f,
                                  new Vector3(sMsgActionMove_SC.floatX / 10.0f, 0, -sMsgActionMove_SC.floatY / 10.0f),
                                  new Vector3(sMsgActionMove_SC.fDirectX, 0, -sMsgActionMove_SC.fDirectY) * sMsgActionMove_SC.fSpeed / 10.0f,
                                  ConfigDefineManager.TIME_MOVE_SYNC_FOWARD);
                    for (int i = 0; i <= 10; i++)
                    {
                        Vector3 nodepos = m_smooth.GetCurrentPos(0.1f * i);
                        nodes.Add(new Vector3(nodepos.x, 1, nodepos.z));
                    }
                }
                m_clientEndPos = null;
                ClientMove     = true;
            }
            else
            {
                m_clientEndPos = new Vector3(sMsgActionMove_SC.floatX / 10.0f, 0, sMsgActionMove_SC.floatY / -10.0f);
                ClientMove     = false;
            }
        }
    }
Пример #12
0
 public void ChangeForward(Vector3 lookToDir)
 {
     ThisTransform.LookAt(new Vector3(lookToDir.x, ThisTransform.position.y, lookToDir.z));
 }