private void Update_Play()
 {
     // 歩く
     if (GetPlayerStatus == PlayerStatus.Walk)
     {
         unitMove.Move();
     }
     // HP==0の状態
     else if (GetPlayerStatus == PlayerStatus.Dead)
     {
         Update_Dead();
     }
 }
Example #2
0
    //public void Init()
    //{
    //    if (!_onTheMove)
    //    {
    //        _unitMoveScript.Move(_positionToBuild);
    //        _onTheMove = true;
    //        Invoke("NextInit", 0.06f);
    //    }
    //}

    //private void NextInit()
    //{
    //    // Nothing, just wait for the damn navMesh to update his damn destination
    //    startbuilding = true;
    //}

    public void Build(GameObject building, GameObject buildingGhost, Vector3 position)
    {
        _building        = building;
        _buildingGhost   = buildingGhost;
        _positionToBuild = position;

        _unitMoveScript.Move(_positionToBuild);

        startbuilding = true;
        //_isBuilding = true;
        //_constructionDone = false;
        //_onTheMove = false;
        //_building = building;
        //_positionToBuild = position;
        //_buildingGhost = buildingGhost;
        //_buildingGhost.GetComponent<BuildingGhost>().NbWorkersAssigned++;
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        animator.speed = animationSpeed / self.AttackSpeed;

        if (target && _unitMoveScript.DestMoveReached)
        {
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(target.transform.position - transform.position), 5f * Time.deltaTime);
            onTheMove = false;
        }

        if(attackTimer > 0)
            attackTimer -= Time.deltaTime;

        if (attackTimer < 0)
            attackTimer = 0;

        if (_attackStance)
        {
            if (target)
            {
                if (attackTimer <= 0)
                {
                    animator.SetTrigger("Attack");
                    audioSource.Play();

                    attackTimer = self.AttackSpeed;
                }
            }
        }

        //if (_isAttacking)
        //{
        if (target != null)
        {
            //_targettedAttack = true;

            if (!onTheMove)
            {
                _unitMoveScript.Move(target.transform.position);
                onTheMove = true;
            }

            // Move to the target
            if (RemainingTargetDistance() >= 0 && RemainingTargetDistance() < self.Range)
            {
                onTheMove = false;
                _unitMoveScript.StopAction();
                _attackStance = true;
            }
            else
            {
                if (!onTheMove)
                {
                    _unitMoveScript.Move(target.transform.position);
                    onTheMove = true;
                }

                _attackStance = false;
            }
        }
        else
        {
            //_targettedAttack = false;

            if (!onTheMove)
            {
                if (!_attackDestination.Equals(Vector3.zero))
                {
                    _unitMoveScript.Move(_attackDestination);
                    onTheMove = true;
                }
            }
        }
    }
Example #4
0
 public void TakeObject(CollectableObject target)
 {
     this.objectToTake = target;
     moveScript.Move(target.transform.position);
     onTheMove = true;
 }