Example #1
0
File: Fire.cs Project: beuoon/FILO
    public void MoveEmber()
    {
        // 빈 영역 확인
        EmberArea.Clear();
        for (int y = -2; y <= 2; y++)
        {
            for (int x = -2; x <= 2; x++)
            {
                Vector3Int tempPos = tilePos + new Vector3Int(x, y, 0);
                if (!TileMgr.Instance.ExistObject(tempPos, floor) && !TileMgr.Instance.ExistEnvironment(tempPos, floor))
                {
                    EmberArea.Add(tempPos);
                }
            }
        }

        if (EmberArea.Count == 0)
        {
            Ember.SetActive(false);
            return;
        }

        int        index = Random.Range(0, EmberArea.Count);
        Vector3Int nPos  = EmberArea[index];

        Ember.transform.position = TileMgr.Instance.CellToWorld(nPos, floor);
        Ember.GetComponent <SortingGroup>().sortingOrder = TileMgr.GetOrder(Ember.transform.position, nPos);
        Ember.SetActive(true);
    }
Example #2
0
    public override bool StartUp(Vector3Int position, ITilemap tilemap, GameObject go)
    {
        if (go != null && TileMgr.Instance != null)
        {
            int order = TileMgr.GetOrder(go.transform.position, position);
            go.GetComponent <SortingGroup>().sortingOrder = order;
        }

        return(base.StartUp(position, tilemap, go));
    }
Example #3
0
    protected virtual void Start()
    {
        _currento2 = _maxo2;
        _currentHp = _maxHp;
        rbody      = GetComponent <Rigidbody2D>();

        // Sorting Order 수정
        int order = TileMgr.GetOrder(transform.position, _currentTilePos);

        GetComponent <SortingGroup>().sortingOrder = order;
    }
Example #4
0
    IEnumerator MoveTile()
    {
        yield return(null);

        _anim.SetBool("IsRunning", true);
        for (int i = 0; i < _panicMoveCount; i++)
        {
            Vector3Int pPos = TileMgr.Instance.WorldToCell(transform.position, floor);
            Vector3Int nPos;

            while (true)
            {
                int randx = Random.Range(-1, 2);
                int randy = Random.Range(-1, 2);
                nPos = pPos + new Vector3Int(randx, randy, 0);

                if (GameMgr.Instance.GetSurvivorAt(nPos, floor) != null)
                {
                    continue;
                }
                break;
            }

            Vector3 arrivePos = TileMgr.Instance.CellToWorld(nPos, floor);

            float delta = _speed * Time.deltaTime;
            while (Vector3.Distance(arrivePos, transform.position) > delta)
            {
                transform.position = Vector3.MoveTowards(transform.position, arrivePos, delta);
                yield return(null);
            }

            transform.position = arrivePos;
            _currentTilePos    = nPos;

            // Sorting Order 수정
            int order = TileMgr.GetOrder(transform.position, _currentTilePos);
            GetComponent <SortingGroup>().sortingOrder = order;
        }
        _anim.SetBool("IsRunning", false);
        _moveDone = true;
    }
Example #5
0
    public override void Move()
    {
        base.Move();
        float hor = Input.GetAxisRaw("Horizontal"); // 가속도 없는 Raw값 사용
        float ver = Input.GetAxisRaw("Vertical");

        if (CurrentHP <= 0 || CurrentO2 <= 0 || _currentMental <= 0 ||
            playerAct == Action.Carry || playerAct == Action.MoveFloor ||
            playerAct == Action.ActiveUlt || (hor == 0.0f && ver == 0.0f))
        {
            // 이동 종료
            rbody.velocity = Vector3.zero;


            // 애니메이션 종료
            if (_anim != null)
            {
                if (_anim.GetBool("IsRunning"))
                {
                    _anim.SetBool("IsRunning", false);
                    SoundManager_Walk.instance.StopSound();//걷는 소리 정지
                }
            }
            return;
        }

        // 캐릭터 이동
        Vector3 dir = new Vector3(hor, ver, 0.0f);

        dir           /= dir.magnitude;
        rbody.velocity = dir * _movespeed;

        _currentTilePos = TileMgr.Instance.WorldToCell(transform.position, floor);

        // Sorting Order 수정
        int order = TileMgr.GetOrder(transform.position, _currentTilePos);

        GetComponent <SortingGroup>().sortingOrder = order;

        // 이동 방향에 따라 캐릭터 이미지 회전
        bool isRight = hor > 0;

        if (isRight)
        {
            if (_body.rotation.y != 180)
            {
                _body.rotation = new Quaternion(0, 180.0f, 0, transform.rotation.w);
            }
        }
        else
        {
            if (_body.rotation.y != 0)
            {
                _body.rotation = Quaternion.identity;
            }
        }

        // 애니메이션 시작
        if (_anim != null)
        {
            if (!_anim.GetBool("IsRunning"))
            {
                _anim.SetBool("IsRunning", true);
                SoundManager_Walk.instance.PlayWalkSound();//걷는소리 재생
            }
        }

        // 산소 소비
        float o2UseRate = 1.0f;

        if (isInGas)
        {
            o2UseRate *= 1.5f;
        }
        if (playerAct == Action.Rescue)
        {
            o2UseRate *= 1.5f;
        }

        AddO2(-UseO2 * o2UseRate * Time.deltaTime);

        // 트리거 실행
        GameMgr.Instance.OnMovePlayer(currentTilePos, floor);
    }