Example #1
0
    public void CalcCoordinates(int index, CharacterCoord[] data)
    {
        SplineData spline = new SplineData();

        for (int i = 0; i < data.Length; ++i)
        {
            int p = index - PLOT_NUM - i + 1;
            if (p < m_plotIndex)
            {
                m_culling.Add(data[i]);
            }
        }

        // 최신 좌표를 설정.
        m_plotIndex = index;

        // 스플라인 곡선을 구해서 보간합니다.
        spline.CalcSpline(m_culling, CULLING_NUM);

        // 구한 스플라인 보간을 좌표 정보로서 저장합니다.
        CharacterCoord plot = new CharacterCoord();

        for (int i = 0; i < spline.GetPlotNum(); ++i)
        {
            spline.GetPoint(i, out plot);
            m_plots.Add(plot);
        }

        // 가장 오래된 좌표를 삭제.
        if (m_culling.Count > PLOT_NUM)
        {
            m_culling.RemoveAt(0);
        }
    }
Example #2
0
    //========================================================================
    // AI에 의한 패드 조작.

    // 목표를 정면으로 향한다.
    protected void updateMoving()
    {
        float turn;

        Vector3 focal_local_pos = this.control.transform.InverseTransformPoint(focus.transform.position);

        focal_local_pos.y = 0.0f;         // 높이는 보지 않는다.

        if (!m_isHost && m_plots.Count > 0)
        {
            CharacterCoord coord = m_plots[0];
            focal_local_pos = new Vector3(coord.x, focal_local_pos.y, coord.z);
            if (m_plots.Count > 0)
            {
                m_plots.RemoveAt(0);
            }
        }

        //float	turn = Random.Range(-90.0f, 90.0f);
        if (Vector3.Dot(Vector3.right, focal_local_pos) > 0)
        {
            turn = Vector3.Angle(focal_local_pos, Vector3.forward);
        }
        else
        {
            turn = -Vector3.Angle(focal_local_pos, Vector3.forward);
        }
        turn = Mathf.Clamp(turn, -90, 90);

        // move_dir에 회전 각도를 넣는다.
        this.getMyController().SetMoveDirection(this.control.getDirection() + turn);
        this.getMyController().acceleration = this.getMyController().maxSpeed;
    }
Example #3
0
    // 이동에 관한 처리.
    protected void  exec_step_move()
    {
        Vector3 new_position = this.controll.getPosition();

        if (m_plots.Count > 0)
        {
            CharacterCoord coord = m_plots[0];
            new_position = new Vector3(coord.x, new_position.y, coord.z);
            m_plots.RemoveAt(0);
        }

        // 순간적으로 멈추기만 했을 때는 걷기 모션이 정지하지 않게 합니다.

        bool is_walking = this.walk_motion.is_walking;

        if (Vector3.Distance(new_position, this.controll.getPosition()) > 0.0f)
        {
            if (this.step.get_current() == STEP.HOUSE_MOVE)
            {
            }
            else
            {
                this.controll.cmdSmoothHeadingTo(new_position);
            }
            this.controll.cmdSetPosition(new_position);

            is_walking = true;
        }
        else
        {
            is_walking = false;
        }

        if (this.walk_motion.is_walking && !is_walking)
        {
            this.walk_motion.timer -= Time.deltaTime;

            if (this.walk_motion.timer <= 0.0f)
            {
                this.walk_motion.is_walking = is_walking;
                this.walk_motion.timer      = STOP_WALK_WAIT;
            }
        }
        else
        {
            this.walk_motion.is_walking = is_walking;
            this.walk_motion.timer      = STOP_WALK_WAIT;
        }

        if (this.walk_motion.is_walking)
        {
            this.playWalkMotion();
        }
        else
        {
            this.stopWalkMotion();
        }
    }
Example #4
0
	public static CharacterCoord	Lerp(CharacterCoord c0, CharacterCoord c1, float rate)
	{
		CharacterCoord	c;
		
		c.x = Mathf.Lerp(c0.x, c1.x, rate);
		c.z = Mathf.Lerp(c0.z, c1.z, rate);
		
		return(c);
	}
Example #5
0
    public void CalcCoordinates(int index, CharacterCoord[] data)
    {
        // 수신한 좌표를 보존.
        do
        {
            // 데이터가 텅빔(만일을 위해).
            if (data.Length <= 0)
            {
                break;
            }

            // 새로운 데이터가 없다.
            if (index <= m_plotIndex)
            {
                break;
            }

            // m_plotIndex ... m_culling[]의 마지막 정점 인덱스.
            // index       ... data[]의 마지막 정점의 인덱스.
            //
            // index - m_plotIndex ... 이번에 새로 추가된 정점의 수.
            //
            int s = data.Length - (index - m_plotIndex);

            if (s < 0)
            {
                break;
            }

            for (int i = s; i < data.Length; i++)
            {
                m_culling.Add(data[i]);
            }

            // m_culling[]의 마지막 정점 인덱스.
            m_plotIndex = index;

            // 스플라인 곡선을 구해서 보간한다.
            SplineData spline = new SplineData();
            spline.CalcSpline(m_culling);

            // 구한 스플라인 보간을 좌표 정보로서 보존한다.
            CharacterCoord plot = new CharacterCoord();
            for (int i = 0; i < spline.GetPlotNum(); ++i)
            {
                spline.GetPoint(i, out plot);

                m_plots.Add(plot);
            }

            // 가장 오래된 좌표를 삭제.
            if (m_culling.Count > PLOT_NUM)
            {
                m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM);
            }
        } while(false);
    }
Example #6
0
    public static CharacterCoord    Lerp(CharacterCoord c0, CharacterCoord c1, float rate)
    {
        CharacterCoord c;

        c.x = Mathf.Lerp(c0.x, c1.x, rate);
        c.z = Mathf.Lerp(c0.z, c1.z, rate);

        return(c);
    }
    public static CharacterCoord    Lerp(CharacterCoord c0, CharacterCoord c1, float rate)
    {
        CharacterCoord c = new CharacterCoord();

        c.x = Mathf.Lerp(c0.x, c1.x, rate);
        c.y = Mathf.Lerp(c0.y, c1.y, rate);

        return(c);
    }
Example #8
0
    public void CalcCoordinates(int index, CharacterCoord[] data)
    {
        // ?섏떊??醫뚰몴瑜?蹂댁〈.
        do
        {
            // ?곗씠?곌? ?낅퉼(留뚯씪???꾪빐).
            if (data.Length <= 0)
            {
                break;
            }

            // ?덈줈???곗씠?곌? ?녿떎.
            if (index <= m_plotIndex)
            {
                break;
            }

            // m_plotIndex ... m_culling[]??留덉?留??뺤젏 ?몃뜳??
            // index       ... data[]??留덉?留??뺤젏???몃뜳??
            //
            // index - m_plotIndex ... ?대쾲???덈줈 異붽????뺤젏????
            //
            int s = data.Length - (index - m_plotIndex);

            if (s < 0)
            {
                break;
            }

            for (int i = s; i < data.Length; i++)
            {
                m_culling.Add(data[i]);
            }

            // m_culling[]??留덉?留??뺤젏 ?몃뜳??
            m_plotIndex = index;

            // ?ㅽ뵆?쇱씤 怨≪꽑??援ы빐??蹂닿컙?쒕떎.
            SplineData spline = new SplineData();
            spline.CalcSpline(m_culling);

            // 援ы븳 ?ㅽ뵆?쇱씤 蹂닿컙??醫뚰몴 ?뺣낫濡쒖꽌 蹂댁〈?쒕떎.
            CharacterCoord plot = new CharacterCoord();
            for (int i = 0; i < spline.GetPlotNum(); ++i)
            {
                spline.GetPoint(i, out plot);

                m_plots.Add(plot);
            }

            // 媛€???ㅻ옒??醫뚰몴瑜???젣.
            if (m_culling.Count > PLOT_NUM)
            {
                m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM);
            }
        } while(false);
    }
Example #9
0
    // 이동에 관한 처리.
    protected void  exec_step_move()
    {
        Vector3 new_position = this.control.getPosition();

        if (m_plots.Count > 0)
        {
            CharacterCoord coord = m_plots[0];
            new_position = new Vector3(coord.x, new_position.y, coord.z);
            m_plots.RemoveAt(0);
        }

        // 한 순간 멈추었을 뿐이라면 걷기 모션을 멈추지 않게 한다.

        bool is_walking = this.walk_motion.is_walking;

        if (Vector3.Distance(new_position, this.control.getPosition()) > 0.0f)
        {
            this.control.cmdSmoothHeadingTo(new_position);
            this.control.cmdSetPosition(new_position);

            is_walking = true;
        }
        else
        {
            is_walking = false;
        }

        if (this.walk_motion.is_walking && !is_walking)
        {
            this.walk_motion.timer -= Time.deltaTime;

            if (this.walk_motion.timer <= 0.0f)
            {
                this.walk_motion.is_walking = is_walking;
                this.walk_motion.timer      = STOP_WALK_WAIT;
            }
        }
        else
        {
            this.walk_motion.is_walking = is_walking;
            this.walk_motion.timer      = STOP_WALK_WAIT;
        }

        if (this.walk_motion.is_walking)
        {
            // 걷기 모션.
            this.control.cmdSetMotion("m001_walk", 0);
        }
        else
        {
            // 멈춤 모션.
            this.control.cmdSetMotion("m002_idle", 0);
        }
    }
    // Update is called once per frame
    void Update()
    {
        //죽음
        if (hp <= 0)
        {
            hp     = 0;
            isDead = true;
            dead();
        }


        rb = GetComponent <Rigidbody2D>();

        // hp 바 표시
        hpBar.SetPosition(1, new Vector3(3.0f * (hp / MAXHP), 0.0f, 0.0f));

        // 애니메이션 처리
        if (tr.position.x - prev_x < -0.0001f)
        {
            animator.SetTrigger("Walk");
        }
        else
        {
            animator.SetTrigger("Idle");
        }

        if (m_plots.Count > 0)
        {
            // 보간한 좌표로 이동
            CharacterCoord coord = m_plots[0];
            transform.position = new Vector3(coord.x, coord.y);

            // 이동했으니 리스트에서 삭제
            m_plots.RemoveAt(0);
        }

        // 좌 우 회전
        // Child컴포넌트만 회전해 다른 영향을 주지 않도록 한다.
        if (!leftFlag && (tr.position.x - prev_x < -0.0001f))
        {
            trChild.localScale = new Vector3(trChild.localScale.x * (-1), trChild.localScale.y, trChild.localScale.z);
            leftFlag           = true;
            rightFlag          = false;
        }
        if (!rightFlag && (tr.position.x - prev_x > 0.0001f))
        {
            trChild.localScale = new Vector3(trChild.localScale.x * (-1), trChild.localScale.y, trChild.localScale.z);
            rightFlag          = true;
            leftFlag           = false;
        }


        prev_x = tr.position.x;
    }
    // 좌표 보간 함수
    public void CalcCoordinates(int index, CharacterCoord[] data)
    {
        // 중복계산 방지
        do
        {
            // 데이터가 비는 경우나
            if (data.Length <= 0)
            {
                break;
            }

            // 계산할 새로운 데이터가 없으면 루프를 탈출
            if (index <= m_plotIndex)
            {
                break;
            }

            // m_plotIndex          m_culling[]의 마지막 점의 인덱스.
            // index                data[]의 마지막 점의 인덱스.
            // 보간할 좌표만 저장한다
            for (int i = 0; i < data.Length; i++)
            {
                if (index - i - (PLOT_NUM - 1) < m_plotIndex)
                {
                    m_culling.Add(data[i]);
                }
            }

            // 최신 좌표 설정
            m_plotIndex = index;

            // 스플라인 곡선을 구해서 보간
            SplineData spline = new SplineData();
            spline.CalcSpline(m_culling);

            // 구한 스플라인 곡선을 좌표 정보로 보존
            CharacterCoord plot = new CharacterCoord();
            for (int i = 0; i < spline.GetPlotNum(); i++)
            {
                spline.GetPoint(i, out plot);
                m_plots.Add(plot);
            }

            // 가장 오래된 좌표를 삭제한다.
            if (m_culling.Count > PLOT_NUM)
            {
                m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM);
            }
        } while (false);
    }
Example #12
0
    void Fire()
    {
        // 발사 된 값을 패킷으로 전달
        Vector3        positionData = firePos.position + firePos.right * 0.2f;
        CharacterCoord packetcoord  = new CharacterCoord(positionData.x, positionData.y);
        float          fireForce    = GetShotPower();
        Quaternion     fireAngle    = firePos.rotation * Quaternion.Euler(0, 0, v);
        int            characterId  = GlobalParam.get().global_account_id;

        // CharacterRoot에 있는 함수 실행
        GameObject.Find("basket").GetComponent <CharacterRoot>().SendAttackCoord(characterId, fireForce, fireAngle, packetcoord);

        // 프리팹 동적 생성
        target_projectile = (GameObject)Instantiate(projectile, positionData, fireAngle);
        target_projectile.GetComponent <BazookaCtrl>().globalId = GlobalParam.get().global_account_id;
    }
Example #13
0
    public void SendAttackCoord(int charId, float fireForce, Quaternion fireAngle, CharacterCoord fireCoord)
    {
        if (network != null)
        {
            // 패킷 데이터 만들기
            AttackData data = new AttackData();
            data.characterId = charId;
            data.fireForce   = fireForce;
            data.fireAngle   = fireAngle;
            data.fireCoord   = fireCoord;

            // 데이터를 UDP송신
            AttackPacket packet = new AttackPacket(data);
            network.SendUnreliableToAll <AttackData>(packet);
        }
    }
    public void SendAttackCoord(int charId, float fireForce, Quaternion fireAngle, CharacterCoord fireCoord)
    {
        if(network != null)
        {
            // 패킷 데이터 만들기
            AttackData data = new AttackData();
            data.characterId = charId;
            data.fireForce = fireForce;
            data.fireAngle = fireAngle;
            data.fireCoord = fireCoord;

            // 데이터를 UDP송신
            AttackPacket packet = new AttackPacket(data);
            network.SendUnreliableToAll<AttackData>(packet);
        }
    }
    void Fire()
    {
        // 발사 된 값을 패킷으로 전달
        Vector3 positionData = firePos.position + firePos.right * 0.2f;
        CharacterCoord packetcoord = new CharacterCoord(positionData.x, positionData.y);
        float fireForce = GetShotPower();
        Quaternion fireAngle = firePos.rotation * Quaternion.Euler(0, 0, v);
        int characterId = GlobalParam.get().global_account_id;

        // CharacterRoot에 있는 함수 실행
        GameObject.Find("basket").GetComponent<CharacterRoot>().SendAttackCoord(characterId, fireForce, fireAngle, packetcoord);

        // 프리팹 동적 생성
        target_projectile = (GameObject)Instantiate (projectile,positionData, fireAngle);
        target_projectile.GetComponent<BazookaCtrl>().globalId = GlobalParam.get().global_account_id;
    }
    // 좌표 보간 함수
    public void CalcCoordinates(int index, CharacterCoord[] data)
    {
        // 중복계산 방지
        do
        {
            // 데이터가 비는 경우나
            if(data.Length <= 0) { break; }

            // 계산할 새로운 데이터가 없으면 루프를 탈출
            if (index <= m_plotIndex) { break; }

            // m_plotIndex          m_culling[]의 마지막 점의 인덱스.
            // index                data[]의 마지막 점의 인덱스.
            // 보간할 좌표만 저장한다
            for(int i = 0; i < data.Length; i++)
            {
                if (index - i - (PLOT_NUM - 1) < m_plotIndex)
                {
                    m_culling.Add(data[i]);
                }
            }

            // 최신 좌표 설정
            m_plotIndex = index;

            // 스플라인 곡선을 구해서 보간
            SplineData spline = new SplineData();
            spline.CalcSpline(m_culling);

            // 구한 스플라인 곡선을 좌표 정보로 보존
            CharacterCoord plot = new CharacterCoord();
            for (int i = 0; i < spline.GetPlotNum(); i++)
            {
                spline.GetPoint(i, out plot);
                m_plots.Add(plot);
            }

            // 가장 오래된 좌표를 삭제한다.
            if (m_culling.Count > PLOT_NUM)
            {
                m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM);
            }
        } while (false);
    }
Example #17
0
    // ---------------------------------------------------------------- //
    // 10 프레임에 1회, 좌표를 네트워크에 전송한다.
    private void sendCharacterCoordinates()
    {
        if (m_network == null)
        {
            return;
        }

        if (this.step != STEP.MOVE)
        {
            return;
        }

        m_send_count = (m_send_count + 1) % SplineData.SEND_INTERVAL;

        if (m_send_count != 0)
        {
            return;
        }

        // 통신용 좌표 송신.
        Vector3        target = this.control.getPosition() + Vector3.left;
        CharacterCoord coord  = new CharacterCoord(target.x, target.z);

        Vector3 diff = m_prev - target;

        if (diff.sqrMagnitude > 0.0001f)
        {
            m_culling.Add(coord);

            AccountData account_data = AccountManager.get().getAccountData(GlobalParam.getInstance().global_account_id);

            CharacterRoot.get().SendCharacterCoord(account_data.avator_id, m_plotIndex, m_culling);
            ++m_plotIndex;

            if (m_culling.Count >= PLOT_NUM)
            {
                m_culling.RemoveAt(0);
            }

            m_prev = target;
        }
    }
Example #18
0
	public override	void	execute()
	{
		base.execute();

		this.resolve_collision();

		this.update_item_queries();

		// ---------------------------------------------------------------- //
		// 다음 상태로 전환할지 체크한다.


		switch(this.step.do_transition()) {

			// 평상 시.
			case STEP.MOVE:
			{
				if(this.control.vital.getHitPoint() <= 0.0f) {

					this.step.set_next(STEP.BATAN_Q);
				}
			}
			break;

			// 근접 공격.
			case STEP.MELEE_ATTACK:
			{
				if(!this.melee_attack.isAttacking()) {

					this.step.set_next(STEP.MOVE);
				}
			}
			break;

			// 아이템 사용.
			case STEP.USE_ITEM:
			{
				if(this.step_use_item.transition_check()) {

					this.ice_timer = ICE_DIGEST_TIME;
				}
			}
			break;

			// 대미지를 받아 날라가는 중.
			case STEP.BLOW_OUT:
			{
				// 일정 거리를 나아가거나 타임아웃으로 종료.

				float	distance = MathUtility.calcDistanceXZ(this.control.getPosition(), this.step_blow_out.center);

				if(distance >= this.step_blow_out.radius || this.step.get_time() > BLOW_OUT_TIME) {

					this.control.cmdSetAcceptDamage(true);
					this.step.set_next(STEP.MOVE);
				}
			}
			break;

			// 체력0.
			case STEP.BATAN_Q:
			{
				if(this.control.getMotion() == "") {

					this.control.cmdSetMotion("m007_out_lp", 1);
					this.step.set_next_delay(STEP.WAIT_RESTART, 1.0f);
				}
			}
			break;

		}

		// ---------------------------------------------------------------- //
		// 상태 전환 시 초기화.

		while(this.step.get_next() != STEP.NONE) {

			switch(this.step.do_initialize()) {

				// 평상 시.	
				case STEP.MOVE:
				{
					this.rigidbody.WakeUp();
					this.move_target = this.transform.position;
					this.heading_target = this.transform.TransformPoint(Vector3.forward);
				}
				break;

				// 근접 공격.
				case STEP.MELEE_ATTACK:
				{
					this.melee_attack.setTarget(this.melee_target);
					this.melee_attack.attack(true);
					this.melee_target = null;
				}
				break;

				// 아이템 사용.
				case STEP.USE_ITEM:
				{
					int		slot_index = this.step_use_item.slot_index;

					if(this.ice_timer > 0.0f) {

						// 아이스를 짧은 간격으로 연속 사용할 때
						// 머리가 지끈지끈해서 회복되지 않는다.
					
						// 아이템을 삭제한다.
						ItemWindow.get().clearItem(Item.SLOT_TYPE.MISC, slot_index);
						this.item_slot.miscs[slot_index].initialize();

						this.startJinJin();
						this.step.set_next(STEP.MOVE);

						SoundManager.getInstance().playSE(Sound.ID.DDG_SE_SYS06);

					} else {

						this.item_slot.miscs[slot_index].is_using = true;

						this.control.cmdSetAcceptDamage(false);

						this.step_use_item.initialize();
					}
				}
				break;

				// 대미지를 받아 날라가는 중.
				case STEP.BLOW_OUT:
				{
					this.rigidbody.Sleep();
					this.control.cmdSetAcceptDamage(false);
				}
				break;

				// 체력 0
				case STEP.BATAN_Q:
				{
					this.rigidbody.Sleep();
					this.control.cmdSetAcceptDamage(false);
					this.control.cmdSetMotion("m006_out", 1);
				}
				break;

				// 리스타트 대기.
				case STEP.WAIT_RESTART:
				{
					this.step_batan_q.tears_effect.destroy();
				}
				break;

				// 외부 제어.
				case STEP.OUTER_CONTROL:
				{
					this.rigidbody.Sleep();
				}
				break;
			}
		}

		// ---------------------------------------------------------------- //
		// 각 상태에서의 실행 처리.

		// 근접 공격.
		// 일단 false로 해두고 이동 입력이 있을 때만.
		// true로 한다.
		this.melee_attack.setHasInput(false);

		GameInput	gi = GameInput.getInstance();

		switch(this.step.do_execution(Time.deltaTime)) {

			// 평상 시.
			case STEP.MOVE:
			{
				this.exec_step_move();

				// ショット.
				if(this.is_shot_enable) {

					this.bullet_shooter.execute(gi.shot.current);

					if(gi.shot.current) {
	
						CharacterRoot.get().SendAttackData(PartyControl.get().getLocalPlayer().getAcountID(), 0);
					}
				}

				// 체력 회복 직후(레인보우컬러 중)는 무적.
				if(this.skin_color_control.isNowHealing()) {

					this.control.cmdSetAcceptDamage(false);

				} else {

					this.control.cmdSetAcceptDamage(true);
				}
			}
			break;

			// 아이템 사용.
			case STEP.USE_ITEM:
			{
				this.step_use_item.execute();
			}
			break;

			// 대미지를 받아 날라가는 중.
			case STEP.BLOW_OUT:
			{
				this.exec_step_blow_out();
			}
			break;

			// 체력0.
			case STEP.BATAN_Q:
			{
				if(this.step.is_acrossing_time(4.0f)) {

					this.step_batan_q.tears_effect = EffectRoot.get().createTearsEffect(this.control.getPosition());

					this.step_batan_q.tears_effect.setParent(this.gameObject);
					this.step_batan_q.tears_effect.setLocalPosition(Vector3.up);
				}
			}
			break;

		}

		// ---------------------------------------------------------------- //

		if(gi.serif_text.trigger_on) {

			this.control.cmdQueryTalk(gi.serif_text.text, true);
		}

		// ---------------------------------------------------------------- //
		// 10 프레임에 한 번 좌표를 네트워크에 보낸다.
		
		{
			do {

				if(this.step.get_current() == STEP.OUTER_CONTROL) {

					break;
				}
				
				m_send_count = (m_send_count + 1)%SplineData.SEND_INTERVAL;
				
				if(m_send_count != 0 && m_culling.Count < PLOT_NUM) {
					
					break;
				}
				
				// 통신용 좌표 송신.
				Vector3 target = this.control.getPosition();
				CharacterCoord coord = new CharacterCoord(target.x, target.z);
				
				Vector3 diff = m_prev - target;
				if (diff.sqrMagnitude > 0.0001f) {
					
					m_culling.Add(coord);

					AccountData	account_data = AccountManager.get().getAccountData(GlobalParam.getInstance().global_account_id);

					CharacterRoot.get().SendCharacterCoord(account_data.avator_id, m_plotIndex, m_culling); 
					++m_plotIndex;
	
					if (m_culling.Count >= PLOT_NUM) {
						
						m_culling.RemoveAt(0);
					}
					
					m_prev = target;
				}
				
			} while(false);
		}

	}
Example #19
0
    public override void    execute()
    {
        base.execute();

        this.resolve_collision();

        this.update_item_queries();

        // ---------------------------------------------------------------- //
        // ?ㅼ쓬 ?곹깭濡??꾪솚?좎? 泥댄겕?쒕떎.


        switch (this.step.do_transition())
        {
        // ?됱긽 ??
        case STEP.MOVE:
        {
            if (this.control.vital.getHitPoint() <= 0.0f)
            {
                this.step.set_next(STEP.BATAN_Q);
            }
        }
        break;

        // 洹쇱젒 怨듦꺽.
        case STEP.MELEE_ATTACK:
        {
            if (!this.melee_attack.isAttacking())
            {
                this.step.set_next(STEP.MOVE);
            }
        }
        break;

        // ?꾩씠???ъ슜.
        case STEP.USE_ITEM:
        {
            if (this.step_use_item.transition_check())
            {
                this.ice_timer = ICE_DIGEST_TIME;
            }
        }
        break;

        // ?€誘몄?瑜?諛쏆븘 ?좊씪媛€??以?
        case STEP.BLOW_OUT:
        {
            // ?쇱젙 嫄곕━瑜??섏븘媛€嫄곕굹 ?€?꾩븘?껋쑝濡?醫낅즺.

            float distance = MathUtility.calcDistanceXZ(this.control.getPosition(), this.step_blow_out.center);

            if (distance >= this.step_blow_out.radius || this.step.get_time() > BLOW_OUT_TIME)
            {
                this.control.cmdSetAcceptDamage(true);
                this.step.set_next(STEP.MOVE);
            }
        }
        break;

        // 泥대젰0.
        case STEP.BATAN_Q:
        {
            if (this.control.getMotion() == "")
            {
                this.control.cmdSetMotion("m007_out_lp", 1);
                this.step.set_next_delay(STEP.WAIT_RESTART, 1.0f);
            }
        }
        break;
        }

        // ---------------------------------------------------------------- //
        // ?곹깭 ?꾪솚 ??珥덇린??

        while (this.step.get_next() != STEP.NONE)
        {
            switch (this.step.do_initialize())
            {
            // ?됱긽 ??
            case STEP.MOVE:
            {
                this.GetComponent <Rigidbody>().WakeUp();
                this.move_target    = this.transform.position;
                this.heading_target = this.transform.TransformPoint(Vector3.forward);
            }
            break;

            // 洹쇱젒 怨듦꺽.
            case STEP.MELEE_ATTACK:
            {
                this.melee_attack.setTarget(this.melee_target);
                this.melee_attack.attack(true);
                this.melee_target = null;
            }
            break;

            // ?꾩씠???ъ슜.
            case STEP.USE_ITEM:
            {
                int slot_index = this.step_use_item.slot_index;

                if (this.ice_timer > 0.0f)
                {
                    // ?꾩씠?ㅻ? 吏㏃? 媛꾧꺽?쇰줈 ?곗냽 ?ъ슜????						// 癒몃━媛€ 吏€?덉??덊빐???뚮났?섏? ?딅뒗??

                    // ?꾩씠?쒖쓣 ??젣?쒕떎.
                    ItemWindow.get().clearItem(Item.SLOT_TYPE.MISC, slot_index);
                    this.item_slot.miscs[slot_index].initialize();

                    this.startJinJin();
                    this.step.set_next(STEP.MOVE);

                    SoundManager.getInstance().playSE(Sound.ID.DDG_SE_SYS06);
                }
                else
                {
                    this.item_slot.miscs[slot_index].is_using = true;

                    this.control.cmdSetAcceptDamage(false);

                    this.step_use_item.initialize();
                }
            }
            break;

            // ?€誘몄?瑜?諛쏆븘 ?좊씪媛€??以?
            case STEP.BLOW_OUT:
            {
                this.GetComponent <Rigidbody>().Sleep();
                this.control.cmdSetAcceptDamage(false);
            }
            break;

            // 泥대젰 0
            case STEP.BATAN_Q:
            {
                this.GetComponent <Rigidbody>().Sleep();
                this.control.cmdSetAcceptDamage(false);
                this.control.cmdSetMotion("m006_out", 1);
            }
            break;

            // 由ъ뒪?€???€湲?
            case STEP.WAIT_RESTART:
            {
                this.step_batan_q.tears_effect.destroy();
            }
            break;

            // ?몃? ?쒖뼱.
            case STEP.OUTER_CONTROL:
            {
                this.GetComponent <Rigidbody>().Sleep();
            }
            break;
            }
        }

        // ---------------------------------------------------------------- //
        // 媛??곹깭?먯꽌???ㅽ뻾 泥섎━.

        // 洹쇱젒 怨듦꺽.
        // ?쇰떒 false濡??대몢怨??대룞 ?낅젰???덉쓣 ?뚮쭔.
        // true濡??쒕떎.
        this.melee_attack.setHasInput(false);

        GameInput gi = GameInput.getInstance();

        switch (this.step.do_execution(Time.deltaTime))
        {
        // ?됱긽 ??
        case STEP.MOVE:
        {
            this.exec_step_move();

            // ?룔깾?껁깉.
            if (this.is_shot_enable)
            {
                this.bullet_shooter.execute(gi.shot.current);

                if (gi.shot.current)
                {
                    CharacterRoot.get().SendAttackData(PartyControl.get().getLocalPlayer().getAcountID(), 0);
                }
            }

            // 泥대젰 ?뚮났 吏곹썑(?덉씤蹂댁슦而щ윭 以???臾댁쟻.
            if (this.skin_color_control.isNowHealing())
            {
                this.control.cmdSetAcceptDamage(false);
            }
            else
            {
                this.control.cmdSetAcceptDamage(true);
            }
        }
        break;

        // ?꾩씠???ъ슜.
        case STEP.USE_ITEM:
        {
            this.step_use_item.execute();
        }
        break;

        // ?€誘몄?瑜?諛쏆븘 ?좊씪媛€??以?
        case STEP.BLOW_OUT:
        {
            this.exec_step_blow_out();
        }
        break;

        // 泥대젰0.
        case STEP.BATAN_Q:
        {
            if (this.step.is_acrossing_time(4.0f))
            {
                this.step_batan_q.tears_effect = EffectRoot.get().createTearsEffect(this.control.getPosition());

                this.step_batan_q.tears_effect.setParent(this.gameObject);
                this.step_batan_q.tears_effect.setLocalPosition(Vector3.up);
            }
        }
        break;
        }

        // ---------------------------------------------------------------- //

        if (gi.serif_text.trigger_on)
        {
            this.control.cmdQueryTalk(gi.serif_text.text, true);
        }

        // ---------------------------------------------------------------- //
        // 10 ?꾨젅?꾩뿉 ??踰?醫뚰몴瑜??ㅽ듃?뚰겕??蹂대궦??

        {
            do
            {
                if (this.step.get_current() == STEP.OUTER_CONTROL)
                {
                    break;
                }

                m_send_count = (m_send_count + 1) % SplineData.SEND_INTERVAL;

                if (m_send_count != 0 && m_culling.Count < PLOT_NUM)
                {
                    break;
                }

                // ?듭떊??醫뚰몴 ?≪떊.
                Vector3        target = this.control.getPosition();
                CharacterCoord coord  = new CharacterCoord(target.x, target.z);

                Vector3 diff = m_prev - target;
                if (diff.sqrMagnitude > 0.0001f)
                {
                    m_culling.Add(coord);

                    AccountData account_data = AccountManager.get().getAccountData(GlobalParam.getInstance().global_account_id);

                    CharacterRoot.get().SendCharacterCoord(account_data.avator_id, m_plotIndex, m_culling);
                    ++m_plotIndex;

                    if (m_culling.Count >= PLOT_NUM)
                    {
                        m_culling.RemoveAt(0);
                    }

                    m_prev = target;
                }
            } while(false);
        }
    }
 public void SetFirePos(CharacterCoord firePos)
 {
     this.firePos.x = firePos.x;
     this.firePos.y = firePos.y;
 }
Example #21
0
	// ---------------------------------------------------------------- //
	// 10 프레임에 1회, 좌표를 네트워크에 전송한다.
	private void sendCharacterCoordinates()
	{

		if(m_network == null) {
			
			return;
		}
		
		if(this.step != STEP.MOVE) {

			return;
		}
		
		m_send_count = (m_send_count + 1)%SplineData.SEND_INTERVAL;
		
		if(m_send_count != 0) {
			
			return;
		}
		
		// 통신용 좌표 송신.
		Vector3 target = this.control.getPosition() + Vector3.left;
		CharacterCoord coord = new CharacterCoord(target.x, target.z);
		
		Vector3 diff = m_prev - target;
		if (diff.sqrMagnitude > 0.0001f) {
			
			m_culling.Add(coord);
			
			AccountData	account_data = AccountManager.get().getAccountData(GlobalParam.getInstance().global_account_id);
			
			CharacterRoot.get().SendCharacterCoord(account_data.avator_id, m_plotIndex, m_culling); 
			++m_plotIndex;
			
			if (m_culling.Count >= PLOT_NUM) {
				
				m_culling.RemoveAt(0);
			}
			
			m_prev = target;
		}
	}
Example #22
0
 public void             GetPoint(int index, ref CharacterCoord coord)
 {
 }
Example #23
0
 public void             GetPoint(int index, out CharacterCoord coord)
 {
     coord = m_points[index];
 }
Example #24
0
    public override void    execute()
    {
        // 아이템과 캐릭터를 클릭했을 때
        //
        // 클릭한 아이템과 캐릭터의 컬리전에 부딪혔으면
        // 멈춘다.
        //
        if (this.move_target_item != "")
        {
            if (this.move_target_item == this.collision)
            {
                this.move_target = this.controll.getPosition();
            }
        }

        // ---------------------------------------------------------------- //
        // 조정이 끝난 쿼리 실행.

        base.execute_queries();

        // ---------------------------------------------------------------- //
        // 다음 상태로 이동할지 체크한다.

        switch (this.step.do_transition())
        {
        case STEP.MOVE:
        {
        }
        break;

        case STEP.WAIT_QUERY:
        {
            if (this.controll.queries.Count <= 0)
            {
                this.step.set_next(STEP.MOVE);
            }
        }
        break;
        }

        // ---------------------------------------------------------------- //
        // 상태 전환 시 초기화.

        while (this.step.get_next() != STEP.NONE)
        {
            switch (this.step.do_initialize())
            {
            case STEP.OUTER_CONTROL:
            {
                this.rigidbody.Sleep();
            }
            break;

            case STEP.MOVE:
            {
                this.move_target = this.transform.position;
            }
            break;

            case STEP.HOUSE_MOVE:
            {
                this.initialize_step_house_move();
            }
            break;
            }
        }

        // ---------------------------------------------------------------- //
        // 각 상태에서의 실행 결과.

        switch (this.step.do_execution(Time.deltaTime))
        {
        case STEP.MOVE:
        {
            this.exec_step_move();
        }
        break;

        case STEP.HOUSE_MOVE:
        {
            this.execute_step_house_move();
        }
        break;
        }


        this.collision = "";

        // ---------------------------------------------------------------- //

        GameInput gi = this.controll.game_input;

        if (gi.serif_text.trigger_on)
        {
            // 어미(장비 아이템 특전).

            ItemFavor item_favor = this.controll.getItemFavor();

            gi.serif_text.text += item_favor.term_word;

            this.controll.cmdQueryTalk(gi.serif_text.text, true);
        }

        // ---------------------------------------------------------------- //
        // 10 프레임에 1회, 좌표를 네트워크로 전송한다(테스트).

        {
            do
            {
                if (GameRoot.get().net_player == null)
                {
                    break;
                }

                if (this.step.get_current() == STEP.OUTER_CONTROL)
                {
                    break;
                }

                m_send_count = (m_send_count + 1) % SplineData.SEND_INTERVAL;

                if (m_send_count != 0)
                {
                    break;
                }

                // 통신용 좌표 송신.
                Vector3        target = this.controll.getPosition() + Vector3.left;
                CharacterCoord coord  = new CharacterCoord(target.x, target.z);

                Vector3 diff = m_prev - target;
                if (diff.sqrMagnitude > 0.0001f)
                {
                    m_culling.Add(coord);

                    //Debug.Log("SendCharacterCoord[index:" + m_plotIndex + "]");
                    CharacterRoot.get().SendCharacterCoord(controll.account_name, m_plotIndex, m_culling);
                    ++m_plotIndex;

                    if (m_culling.Count >= PLOT_NUM)
                    {
                        m_culling.RemoveAt(0);
                    }

                    m_prev = target;
                }
            } while(false);
        }
    }
Example #25
0
	public void		GetPoint(int index, out CharacterCoord coord)
	{
		coord = m_points[index];
	} 
Example #26
0
	public void		GetPoint(int index, ref CharacterCoord coord) {} 
Example #27
0
	// ================================================================ //
	// 
	// 게스트 단말에서의 보스의 이동.
	//
	
	public void CalcCoordinates(int index, CharacterCoord[] data)
	{
		// 수신한 좌표를 보존.
		do {
			
			// 데이터가 빔(만일을 위해).
			if(data.Length <= 0) {
				
				break;
			}
			
			// 새로운 데이터가 없다.
			if(index <= m_plotIndex) {
				
				break;
			}
			
			// m_plotIndex ... m_culling[]의 마지막 정점의 인덱스.
			// index       ... data[]의 마지막 정점의 인덱스.
			//
			// index - m_plotIndex ... 이번에 새로 추가된 정점 수.
			//
			int		s = data.Length - 1 - (index - m_plotIndex);
			
			if(s < 0) {
				
				break;
			}
			
			for(int i = s;i < data.Length;i++) {
				
				m_culling.Add(data[i]);
			}
			
			// m_culling[]의 마지막 정점의 인덱스.
			m_plotIndex = index;
			
			// 스플라인 곡선을 구해서 보간한다.	
			SplineData	spline = new SplineData();
			spline.CalcSpline(m_culling);
			
			// 구한 스플라인 곡선을 좌표 정보로 저장한다.
			CharacterCoord plot = new CharacterCoord();
			for (int i = 0; i < spline.GetPlotNum(); ++i) {
				spline.GetPoint(i, out plot);
				m_plots.Add(plot);
			}
			
			// 가장 오래된 좌표를 삭제한다.
			if (m_culling.Count > PLOT_NUM) {
				
				m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM);
			}
			
		} while(false);
		

		// 수신한 좌표를 저장한다.
		for (int i = 0; i < data.Length; ++i) {
			int p = index - PLOT_NUM - i + 1;
			if (p < m_plotIndex) {
				m_culling.Add(data[i]);
			}
		}
	}
Example #28
0
	public void CalcCoordinates(int index, CharacterCoord[] data)
	{
		// ?섏떊??醫뚰몴瑜?蹂댁〈.
		do {

			// ?곗씠?곌? ?낅퉼(留뚯씪???꾪빐).
			if(data.Length <= 0) {

				break;
			}

			// ?덈줈???곗씠?곌? ?녿떎.
			if(index <= m_plotIndex) {
	
				break;
			}

			// m_plotIndex ... m_culling[]??留덉?留??뺤젏 ?몃뜳??
			// index       ... data[]??留덉?留??뺤젏???몃뜳??
			//
			// index - m_plotIndex ... ?대쾲???덈줈 異붽????뺤젏????
			//
			int		s = data.Length - (index - m_plotIndex);

			if(s < 0) {

				break;
			}

			for(int i = s;i < data.Length;i++) {
	
				m_culling.Add(data[i]);
			}

			// m_culling[]??留덉?留??뺤젏 ?몃뜳??
			m_plotIndex = index;

			// ?ㅽ뵆?쇱씤 怨≪꽑??援ы빐??蹂닿컙?쒕떎.	
			SplineData	spline = new SplineData();
			spline.CalcSpline(m_culling);
			
			// 援ы븳 ?ㅽ뵆?쇱씤 蹂닿컙??醫뚰몴 ?뺣낫濡쒖꽌 蹂댁〈?쒕떎.
			CharacterCoord plot = new CharacterCoord();
			for (int i = 0; i < spline.GetPlotNum(); ++i) {
				spline.GetPoint(i, out plot);

				m_plots.Add(plot);
			}
			
			// 媛€???ㅻ옒??醫뚰몴瑜???젣.
			if (m_culling.Count > PLOT_NUM) {

				m_culling.RemoveRange(0, m_culling.Count - PLOT_NUM);
			}

		} while(false);
	
	}
    /*void OnCollisionEnter2D(Collision2D coll){
        if (coll.collider.tag == "BAZOOKA") {
            // 충돌된 위치 저장
            Vector3 collPos = transform.position;
            Debug.Log ("!!"+collPos);
            Debug.Log ("Player"+tr.position);
        }
    }*/
    // Update is called once per frame
    void Update()
    {
        //죽음
        if (hp <= 0)
        {
            hp = 0;
            isDead = true;
            dead();
        }

        //h = AndroidInput._;
        // 좌 우 이동
        h = Input.GetAxis ("Horizontal");

        // Child컴포넌트만 회전해 다른 영향을 주지 않도록 한다.
        if (!leftFlag && h < -0.1f)
        {
            trChild.Rotate(0, 180.0f, 0);
            leftFlag = true;
            rightFlag = false;
        }
        if (!rightFlag && h > 0.1f)
        {
            trChild.Rotate(0, 180.0f, 0);
            rightFlag = true;
            leftFlag = false;
        }
        tr.Translate (Vector2.right * (h) * movSpeed * Time.deltaTime, Space.Self);

        // 발사각 조절
        v = Input.GetAxis("Vertical");
        firePos.Rotate (0, 0, v);

        // Collider 가 반지름 0.12를 감안하여 접지판정
        Vector2 groundCheck = transform.position + Vector3.down * 0.16f;
        isGrounded = (Physics2D.OverlapPoint(groundCheck) != null) ? true : false;

        // 애니메이션 처리
        if (isGrounded)
        {
            jumpCount = 0;
            if(h != 0){ animator.SetTrigger("Walk"); }
            else { animator.SetTrigger("Idle"); }
        }
        //else { animator.SetTrigger("Jump"); }

        // 점프
        rb = GetComponent<Rigidbody2D> ();
        if (jumpCount < MAX_JUMP_COUNT)
        {
            if (Input.GetKeyDown(KeyCode.X))
            {
                rb.AddForce(transform.up * JUMP_POWER);
                jumpCount++;
            }
        }

        // hp 바 표시
        hpBar.SetPosition(1, new Vector3(3.0f * (hp / MAXHP), 0.0f, 0.0f));

        // 나의 현재 위치를 패킷을 만들어 보내기
        do
        {
            // 10프레임마다 송신
            m_send_count = (m_send_count + 1) % SplineData.SEND_INTERVAL;

            if(m_send_count != 0 && m_culling.Count < PLOT_NUM)
            {
                break;
            }

            // 현재 위치 구조체에 담기
            Vector3 positionData = transform.position;
            CharacterCoord coord = new CharacterCoord(positionData.x, positionData.y);

            // 변화량을 체크하여 정지상태일때는 데이터를 보내지 않도록 한다.
            Vector3 diff = m_prev - positionData;
            if (diff.sqrMagnitude > 0.0001f)
            {
                // 좌표를 자료구조에 보존
                m_culling.Add(coord);

                // CharacterRoot에 있는 함수 실행
                GameObject.Find("basket").GetComponent<CharacterRoot>().SendCharacterCoord(globalId, m_plotIndex, m_culling);

                // 인덱스 증가
                ++m_plotIndex;

                // 가장 오래된 좌표 삭제
                if(m_culling.Count >= PLOT_NUM)
                {
                    m_culling.RemoveAt(0);
                }

                // 위치 변화량 초기화
                m_prev = positionData;
            }

        } while (false);
    }
Example #30
0
	public void CalcCoordinates(int index, CharacterCoord[] data)
	{
		SplineData	spline = new SplineData();
		
		for (int i = 0; i < data.Length; ++i) {
			int p = index - PLOT_NUM - i + 1;
			if (p < m_plotIndex) {
				m_culling.Add(data[i]);
			}
		}
		
		// 최신 좌표를 설정.
		m_plotIndex = index;
		
		// 스플라인 곡선을 구해서 보간합니다.	
		spline.CalcSpline(m_culling, CULLING_NUM);
		
		// 구한 스플라인 보간을 좌표 정보로서 저장합니다.
		CharacterCoord plot = new CharacterCoord();
		for (int i = 0; i < spline.GetPlotNum(); ++i) {
			spline.GetPoint(i, out plot);
			m_plots.Add(plot);
		}
		
		// 가장 오래된 좌표를 삭제.
		if (m_culling.Count > PLOT_NUM) {
			m_culling.RemoveAt(0);
		}
	}
Example #31
0
    public void CalcSpline(List <CharacterCoord> dPoint, int cullingNum)
    {
        m_points.Clear();

        Vector3 ps = Vector3.zero;
        Vector3 pe = Vector3.zero;

        Vector3 vs = Vector3.zero;
        Vector3 ve = Vector3.zero;

        if (dPoint.Count == 0)
        {
        }
        else if (dPoint.Count == 1)
        {
            ps = dPoint[dPoint.Count - 1].ToVector3();
            pe = ps;

            vs = Vector3.zero;
            ve = Vector3.zero;
        }
        else if (dPoint.Count == 2)
        {
            ps = dPoint[dPoint.Count - 2].ToVector3();
            pe = dPoint[dPoint.Count - 1].ToVector3();

            vs = ps - pe;
            ve = vs;
        }
        else if (dPoint.Count == 3)
        {
            ps = dPoint[dPoint.Count - 2].ToVector3();
            pe = dPoint[dPoint.Count - 1].ToVector3();

            vs = (dPoint[dPoint.Count - 2].ToVector3() - dPoint[dPoint.Count - 3].ToVector3());

            Vector3 v0 = (dPoint[dPoint.Count - 2].ToVector3() - dPoint[dPoint.Count - 3].ToVector3());
            Vector3 v1 = (dPoint[dPoint.Count - 1].ToVector3() - dPoint[dPoint.Count - 2].ToVector3());

            Vector3 v2 = v1 + (v1 - v0);

            ve = v2;
        }
        else if (dPoint.Count >= 4)
        {
            ps = dPoint[dPoint.Count - 2].ToVector3();
            pe = dPoint[dPoint.Count - 1].ToVector3();

            vs = (dPoint[dPoint.Count - 2].ToVector3() - dPoint[dPoint.Count - 3].ToVector3());

            Vector3 v0 = (dPoint[dPoint.Count - 3].ToVector3() - dPoint[dPoint.Count - 4].ToVector3());
            Vector3 v1 = (dPoint[dPoint.Count - 2].ToVector3() - dPoint[dPoint.Count - 3].ToVector3());
            Vector3 v2 = (dPoint[dPoint.Count - 1].ToVector3() - dPoint[dPoint.Count - 2].ToVector3());

            Vector3 dv0 = v1 - v0;
            Vector3 dv1 = v2 - v1;

            Vector3 dv2 = dv1 + (dv1 - dv0);

            Vector3 v3 = v2 + dv2;

            ve = v3;
        }

        SimpleSpline.Curve spline = new SimpleSpline.Curve();

        spline.appendCV(ps, vs * 0.5f);
        spline.appendCV(pe, ve * 0.5f);

        SimpleSpline.Tracer tracer = new SimpleSpline.Tracer();

        tracer.attach(spline);

        float total_dist = spline.calcTotalDistance();

        for (int i = 0; i < SEND_INTERVAL; i++)
        {
            float rate = ((float)i) / ((float)SEND_INTERVAL);

            tracer.proceedToDistance(total_dist * rate);

            m_points.Add(CharacterCoord.FromVector3(tracer.getCurrent().position));
        }
    }
 public void SetFirePos(CharacterCoord firePos)
 {
     this.firePos.x = firePos.x;
     this.firePos.y = firePos.y;
 }
Example #33
0
	public override	void	execute()
	{
		base.execute();

		this.resolve_collision();

		this.update_item_queries();

		// ---------------------------------------------------------------- //
		// ?ㅼ쓬 ?곹깭濡??꾪솚?좎? 泥댄겕?쒕떎.


		switch(this.step.do_transition()) {

			// ?됱긽 ??
			case STEP.MOVE:
			{
				if(this.control.vital.getHitPoint() <= 0.0f) {

					this.step.set_next(STEP.BATAN_Q);
				}
			}
			break;

			// 洹쇱젒 怨듦꺽.
			case STEP.MELEE_ATTACK:
			{
				if(!this.melee_attack.isAttacking()) {

					this.step.set_next(STEP.MOVE);
				}
			}
			break;

			// ?꾩씠???ъ슜.
			case STEP.USE_ITEM:
			{
				if(this.step_use_item.transition_check()) {

					this.ice_timer = ICE_DIGEST_TIME;
				}
			}
			break;

			// ?€誘몄?瑜?諛쏆븘 ?좊씪媛€??以?
			case STEP.BLOW_OUT:
			{
				// ?쇱젙 嫄곕━瑜??섏븘媛€嫄곕굹 ?€?꾩븘?껋쑝濡?醫낅즺.

				float	distance = MathUtility.calcDistanceXZ(this.control.getPosition(), this.step_blow_out.center);

				if(distance >= this.step_blow_out.radius || this.step.get_time() > BLOW_OUT_TIME) {

					this.control.cmdSetAcceptDamage(true);
					this.step.set_next(STEP.MOVE);
				}
			}
			break;

			// 泥대젰0.
			case STEP.BATAN_Q:
			{
				if(this.control.getMotion() == "") {

					this.control.cmdSetMotion("m007_out_lp", 1);
					this.step.set_next_delay(STEP.WAIT_RESTART, 1.0f);
				}
			}
			break;

		}

		// ---------------------------------------------------------------- //
		// ?곹깭 ?꾪솚 ??珥덇린??

		while(this.step.get_next() != STEP.NONE) {

			switch(this.step.do_initialize()) {

				// ?됱긽 ??	
				case STEP.MOVE:
				{
					this.GetComponent<Rigidbody>().WakeUp();
					this.move_target = this.transform.position;
					this.heading_target = this.transform.TransformPoint(Vector3.forward);
				}
				break;

				// 洹쇱젒 怨듦꺽.
				case STEP.MELEE_ATTACK:
				{
					this.melee_attack.setTarget(this.melee_target);
					this.melee_attack.attack(true);
					this.melee_target = null;
				}
				break;

				// ?꾩씠???ъ슜.
				case STEP.USE_ITEM:
				{
					int		slot_index = this.step_use_item.slot_index;

					if(this.ice_timer > 0.0f) {

						// ?꾩씠?ㅻ? 吏㏃? 媛꾧꺽?쇰줈 ?곗냽 ?ъ슜????						// 癒몃━媛€ 吏€?덉??덊빐???뚮났?섏? ?딅뒗??
					
						// ?꾩씠?쒖쓣 ??젣?쒕떎.
						ItemWindow.get().clearItem(Item.SLOT_TYPE.MISC, slot_index);
						this.item_slot.miscs[slot_index].initialize();

						this.startJinJin();
						this.step.set_next(STEP.MOVE);

						SoundManager.getInstance().playSE(Sound.ID.DDG_SE_SYS06);

					} else {

						this.item_slot.miscs[slot_index].is_using = true;

						this.control.cmdSetAcceptDamage(false);

						this.step_use_item.initialize();
					}
				}
				break;

				// ?€誘몄?瑜?諛쏆븘 ?좊씪媛€??以?
				case STEP.BLOW_OUT:
				{
					this.GetComponent<Rigidbody>().Sleep();
					this.control.cmdSetAcceptDamage(false);
				}
				break;

				// 泥대젰 0
				case STEP.BATAN_Q:
				{
					this.GetComponent<Rigidbody>().Sleep();
					this.control.cmdSetAcceptDamage(false);
					this.control.cmdSetMotion("m006_out", 1);
				}
				break;

				// 由ъ뒪?€???€湲?
				case STEP.WAIT_RESTART:
				{
					this.step_batan_q.tears_effect.destroy();
				}
				break;

				// ?몃? ?쒖뼱.
				case STEP.OUTER_CONTROL:
				{
					this.GetComponent<Rigidbody>().Sleep();
				}
				break;
			}
		}

		// ---------------------------------------------------------------- //
		// 媛??곹깭?먯꽌???ㅽ뻾 泥섎━.

		// 洹쇱젒 怨듦꺽.
		// ?쇰떒 false濡??대몢怨??대룞 ?낅젰???덉쓣 ?뚮쭔.
		// true濡??쒕떎.
		this.melee_attack.setHasInput(false);

		GameInput	gi = GameInput.getInstance();

		switch(this.step.do_execution(Time.deltaTime)) {

			// ?됱긽 ??
			case STEP.MOVE:
			{
				this.exec_step_move();

				// ?룔깾?껁깉.
				if(this.is_shot_enable) {

					this.bullet_shooter.execute(gi.shot.current);

					if(gi.shot.current) {
	
						CharacterRoot.get().SendAttackData(PartyControl.get().getLocalPlayer().getAcountID(), 0);
					}
				}

				// 泥대젰 ?뚮났 吏곹썑(?덉씤蹂댁슦而щ윭 以???臾댁쟻.
				if(this.skin_color_control.isNowHealing()) {

					this.control.cmdSetAcceptDamage(false);

				} else {

					this.control.cmdSetAcceptDamage(true);
				}
			}
			break;

			// ?꾩씠???ъ슜.
			case STEP.USE_ITEM:
			{
				this.step_use_item.execute();
			}
			break;

			// ?€誘몄?瑜?諛쏆븘 ?좊씪媛€??以?
			case STEP.BLOW_OUT:
			{
				this.exec_step_blow_out();
			}
			break;

			// 泥대젰0.
			case STEP.BATAN_Q:
			{
				if(this.step.is_acrossing_time(4.0f)) {

					this.step_batan_q.tears_effect = EffectRoot.get().createTearsEffect(this.control.getPosition());

					this.step_batan_q.tears_effect.setParent(this.gameObject);
					this.step_batan_q.tears_effect.setLocalPosition(Vector3.up);
				}
			}
			break;

		}

		// ---------------------------------------------------------------- //

		if(gi.serif_text.trigger_on) {

			this.control.cmdQueryTalk(gi.serif_text.text, true);
		}

		// ---------------------------------------------------------------- //
		// 10 ?꾨젅?꾩뿉 ??踰?醫뚰몴瑜??ㅽ듃?뚰겕??蹂대궦??
		
		{
			do {

				if(this.step.get_current() == STEP.OUTER_CONTROL) {

					break;
				}
				
				m_send_count = (m_send_count + 1)%SplineData.SEND_INTERVAL;
				
				if(m_send_count != 0 && m_culling.Count < PLOT_NUM) {
					
					break;
				}
				
				// ?듭떊??醫뚰몴 ?≪떊.
				Vector3 target = this.control.getPosition();
				CharacterCoord coord = new CharacterCoord(target.x, target.z);
				
				Vector3 diff = m_prev - target;
				if (diff.sqrMagnitude > 0.0001f) {
					
					m_culling.Add(coord);

					AccountData	account_data = AccountManager.get().getAccountData(GlobalParam.getInstance().global_account_id);

					CharacterRoot.get().SendCharacterCoord(account_data.avator_id, m_plotIndex, m_culling); 
					++m_plotIndex;
	
					if (m_culling.Count >= PLOT_NUM) {
						
						m_culling.RemoveAt(0);
					}
					
					m_prev = target;
				}
				
			} while(false);
		}

	}
    public static CharacterCoord Lerp(CharacterCoord c0, CharacterCoord c1, float rate)
    {
        CharacterCoord	c = new CharacterCoord();

        c.x = Mathf.Lerp(c0.x, c1.x, rate);
        c.y = Mathf.Lerp(c0.y, c1.y, rate);

        return(c);
    }
Example #35
0
    /*void OnCollisionEnter2D(Collision2D coll){
     *      if (coll.collider.tag == "BAZOOKA") {
     *              // 충돌된 위치 저장
     *              Vector3 collPos = transform.position;
     *              Debug.Log ("!!"+collPos);
     *              Debug.Log ("Player"+tr.position);
     *      }
     * }*/

    // Update is called once per frame
    void Update()
    {
        //죽음
        if (hp <= 0)
        {
            hp     = 0;
            isDead = true;
            dead();
        }

        //h = AndroidInput._;
        // 좌 우 이동
        h = Input.GetAxis("Horizontal");

        // Child컴포넌트만 회전해 다른 영향을 주지 않도록 한다.
        if (!leftFlag && h < -0.1f)
        {
            trChild.Rotate(0, 180.0f, 0);
            leftFlag  = true;
            rightFlag = false;
        }
        if (!rightFlag && h > 0.1f)
        {
            trChild.Rotate(0, 180.0f, 0);
            rightFlag = true;
            leftFlag  = false;
        }
        tr.Translate(Vector2.right * (h) * movSpeed * Time.deltaTime, Space.Self);

        // 발사각 조절
        v = Input.GetAxis("Vertical");
        firePos.Rotate(0, 0, v);

        // Collider 가 반지름 0.12를 감안하여 접지판정
        Vector2 groundCheck = transform.position + Vector3.down * 0.16f;

        isGrounded = (Physics2D.OverlapPoint(groundCheck) != null) ? true : false;

        // 애니메이션 처리
        if (isGrounded)
        {
            jumpCount = 0;
            if (h != 0)
            {
                animator.SetTrigger("Walk");
            }
            else
            {
                animator.SetTrigger("Idle");
            }
        }
        //else { animator.SetTrigger("Jump"); }

        // 점프
        rb = GetComponent <Rigidbody2D> ();
        if (jumpCount < MAX_JUMP_COUNT)
        {
            if (Input.GetKeyDown(KeyCode.X))
            {
                rb.AddForce(transform.up * JUMP_POWER);
                jumpCount++;
            }
        }

        // hp 바 표시
        hpBar.SetPosition(1, new Vector3(3.0f * (hp / MAXHP), 0.0f, 0.0f));


        // 나의 현재 위치를 패킷을 만들어 보내기
        do
        {
            // 10프레임마다 송신
            m_send_count = (m_send_count + 1) % SplineData.SEND_INTERVAL;

            if (m_send_count != 0 && m_culling.Count < PLOT_NUM)
            {
                break;
            }

            // 현재 위치 구조체에 담기
            Vector3        positionData = transform.position;
            CharacterCoord coord        = new CharacterCoord(positionData.x, positionData.y);

            // 변화량을 체크하여 정지상태일때는 데이터를 보내지 않도록 한다.
            Vector3 diff = m_prev - positionData;
            if (diff.sqrMagnitude > 0.0001f)
            {
                // 좌표를 자료구조에 보존
                m_culling.Add(coord);

                // CharacterRoot에 있는 함수 실행
                GameObject.Find("basket").GetComponent <CharacterRoot>().SendCharacterCoord(globalId, m_plotIndex, m_culling);

                // 인덱스 증가
                ++m_plotIndex;

                // 가장 오래된 좌표 삭제
                if (m_culling.Count >= PLOT_NUM)
                {
                    m_culling.RemoveAt(0);
                }

                // 위치 변화량 초기화
                m_prev = positionData;
            }
        } while (false);
    }
Example #36
0
    public override void    execute()
    {
        base.execute();

        this.resolve_collision();

        this.update_item_queries();

        // ---------------------------------------------------------------- //
        // 다음 상태로 전환할지 체크한다.


        switch (this.step.do_transition())
        {
        // 평상 시.
        case STEP.MOVE:
        {
            if (this.control.vital.getHitPoint() <= 0.0f)
            {
                this.step.set_next(STEP.BATAN_Q);
            }
        }
        break;

        // 근접 공격.
        case STEP.MELEE_ATTACK:
        {
            if (!this.melee_attack.isAttacking())
            {
                this.step.set_next(STEP.MOVE);
            }
        }
        break;

        // 아이템 사용.
        case STEP.USE_ITEM:
        {
            if (this.step_use_item.transition_check())
            {
                this.ice_timer = ICE_DIGEST_TIME;
            }
        }
        break;

        // 대미지를 받아 날라가는 중.
        case STEP.BLOW_OUT:
        {
            // 일정 거리를 나아가거나 타임아웃으로 종료.

            float distance = MathUtility.calcDistanceXZ(this.control.getPosition(), this.step_blow_out.center);

            if (distance >= this.step_blow_out.radius || this.step.get_time() > BLOW_OUT_TIME)
            {
                this.control.cmdSetAcceptDamage(true);
                this.step.set_next(STEP.MOVE);
            }
        }
        break;

        // 체력0.
        case STEP.BATAN_Q:
        {
            if (this.control.getMotion() == "")
            {
                this.control.cmdSetMotion("m007_out_lp", 1);
                this.step.set_next_delay(STEP.WAIT_RESTART, 1.0f);
            }
        }
        break;
        }

        // ---------------------------------------------------------------- //
        // 상태 전환 시 초기화.

        while (this.step.get_next() != STEP.NONE)
        {
            switch (this.step.do_initialize())
            {
            // 평상 시.
            case STEP.MOVE:
            {
                this.rigidbody.WakeUp();
                this.move_target    = this.transform.position;
                this.heading_target = this.transform.TransformPoint(Vector3.forward);
            }
            break;

            // 근접 공격.
            case STEP.MELEE_ATTACK:
            {
                this.melee_attack.setTarget(this.melee_target);
                this.melee_attack.attack(true);
                this.melee_target = null;
            }
            break;

            // 아이템 사용.
            case STEP.USE_ITEM:
            {
                int slot_index = this.step_use_item.slot_index;

                if (this.ice_timer > 0.0f)
                {
                    // 아이스를 짧은 간격으로 연속 사용할 때
                    // 머리가 지끈지끈해서 회복되지 않는다.

                    // 아이템을 삭제한다.
                    ItemWindow.get().clearItem(Item.SLOT_TYPE.MISC, slot_index);
                    this.item_slot.miscs[slot_index].initialize();

                    this.startJinJin();
                    this.step.set_next(STEP.MOVE);

                    SoundManager.getInstance().playSE(Sound.ID.DDG_SE_SYS06);
                }
                else
                {
                    this.item_slot.miscs[slot_index].is_using = true;

                    this.control.cmdSetAcceptDamage(false);

                    this.step_use_item.initialize();
                }
            }
            break;

            // 대미지를 받아 날라가는 중.
            case STEP.BLOW_OUT:
            {
                this.rigidbody.Sleep();
                this.control.cmdSetAcceptDamage(false);
            }
            break;

            // 체력 0
            case STEP.BATAN_Q:
            {
                this.rigidbody.Sleep();
                this.control.cmdSetAcceptDamage(false);
                this.control.cmdSetMotion("m006_out", 1);
            }
            break;

            // 리스타트 대기.
            case STEP.WAIT_RESTART:
            {
                this.step_batan_q.tears_effect.destroy();
            }
            break;

            // 외부 제어.
            case STEP.OUTER_CONTROL:
            {
                this.rigidbody.Sleep();
            }
            break;
            }
        }

        // ---------------------------------------------------------------- //
        // 각 상태에서의 실행 처리.

        // 근접 공격.
        // 일단 false로 해두고 이동 입력이 있을 때만.
        // true로 한다.
        this.melee_attack.setHasInput(false);

        GameInput gi = GameInput.getInstance();

        switch (this.step.do_execution(Time.deltaTime))
        {
        // 평상 시.
        case STEP.MOVE:
        {
            this.exec_step_move();

            // ショット.
            if (this.is_shot_enable)
            {
                this.bullet_shooter.execute(gi.shot.current);

                if (gi.shot.current)
                {
                    CharacterRoot.get().SendAttackData(PartyControl.get().getLocalPlayer().getAcountID(), 0);
                }
            }

            // 체력 회복 직후(레인보우컬러 중)는 무적.
            if (this.skin_color_control.isNowHealing())
            {
                this.control.cmdSetAcceptDamage(false);
            }
            else
            {
                this.control.cmdSetAcceptDamage(true);
            }
        }
        break;

        // 아이템 사용.
        case STEP.USE_ITEM:
        {
            this.step_use_item.execute();
        }
        break;

        // 대미지를 받아 날라가는 중.
        case STEP.BLOW_OUT:
        {
            this.exec_step_blow_out();
        }
        break;

        // 체력0.
        case STEP.BATAN_Q:
        {
            if (this.step.is_acrossing_time(4.0f))
            {
                this.step_batan_q.tears_effect = EffectRoot.get().createTearsEffect(this.control.getPosition());

                this.step_batan_q.tears_effect.setParent(this.gameObject);
                this.step_batan_q.tears_effect.setLocalPosition(Vector3.up);
            }
        }
        break;
        }

        // ---------------------------------------------------------------- //

        if (gi.serif_text.trigger_on)
        {
            this.control.cmdQueryTalk(gi.serif_text.text, true);
        }

        // ---------------------------------------------------------------- //
        // 10 프레임에 한 번 좌표를 네트워크에 보낸다.

        {
            do
            {
                if (this.step.get_current() == STEP.OUTER_CONTROL)
                {
                    break;
                }

                m_send_count = (m_send_count + 1) % SplineData.SEND_INTERVAL;

                if (m_send_count != 0 && m_culling.Count < PLOT_NUM)
                {
                    break;
                }

                // 통신용 좌표 송신.
                Vector3        target = this.control.getPosition();
                CharacterCoord coord  = new CharacterCoord(target.x, target.z);

                Vector3 diff = m_prev - target;
                if (diff.sqrMagnitude > 0.0001f)
                {
                    m_culling.Add(coord);

                    AccountData account_data = AccountManager.get().getAccountData(GlobalParam.getInstance().global_account_id);

                    CharacterRoot.get().SendCharacterCoord(account_data.avator_id, m_plotIndex, m_culling);
                    ++m_plotIndex;

                    if (m_culling.Count >= PLOT_NUM)
                    {
                        m_culling.RemoveAt(0);
                    }

                    m_prev = target;
                }
            } while(false);
        }
    }
Example #37
0
	public override	void	execute()
	{
		// 아이템과 캐릭터를 클릭했을 때
		//
		// 클릭한 아이템과 캐릭터의 컬리전에 부딪혔으면
		// 멈춘다.
		//
		if(this.move_target_item != "") {

			if(this.move_target_item == this.collision) {

				this.move_target = this.controll.getPosition();
			}
		}

		// ---------------------------------------------------------------- //
		// 조정이 끝난 쿼리 실행.

		base.execute_queries();

		// ---------------------------------------------------------------- //
		// 다음 상태로 이동할지 체크한다.

		switch(this.step.do_transition()) {

			case STEP.MOVE:
			{
			}
			break;

			case STEP.WAIT_QUERY:
			{
				if(this.controll.queries.Count <= 0) {

					this.step.set_next(STEP.MOVE);
				}
			}
			break;
		}

		// ---------------------------------------------------------------- //
		// 상태 전환 시 초기화.

		while(this.step.get_next() != STEP.NONE) {

			switch(this.step.do_initialize()) {
	
				case STEP.OUTER_CONTROL:
				{
					this.rigidbody.Sleep();
				}
				break;

				case STEP.MOVE:
				{
					this.move_target = this.transform.position;
				}
				break;

				case STEP.HOUSE_MOVE:
				{
					this.initialize_step_house_move();
				}
				break;
			}
		}

		// ---------------------------------------------------------------- //
		// 각 상태에서의 실행 결과.

		switch(this.step.do_execution(Time.deltaTime)) {

			case STEP.MOVE:
			{
				this.exec_step_move();
			}
			break;

			case STEP.HOUSE_MOVE:
			{
				this.execute_step_house_move();
			}
			break;
		}


		this.collision = "";

		// ---------------------------------------------------------------- //

		GameInput	gi = this.controll.game_input;

		if(gi.serif_text.trigger_on) {

			// 어미(장비 아이템 특전).

			ItemFavor	item_favor = this.controll.getItemFavor();

			gi.serif_text.text += item_favor.term_word;

			this.controll.cmdQueryTalk(gi.serif_text.text, true);
		}

		// ---------------------------------------------------------------- //
		// 10 프레임에 1회, 좌표를 네트워크로 전송한다(테스트).

		{
			do {
	
				if(GameRoot.get().net_player == null) {
	
					break;
				}

				if(this.step.get_current() == STEP.OUTER_CONTROL) {
					break;
				}
	
				m_send_count = (m_send_count + 1)%SplineData.SEND_INTERVAL;
	
				if(m_send_count != 0) {
	
					break;
				}

				// 통신용 좌표 송신.
				Vector3 target = this.controll.getPosition() + Vector3.left;
				CharacterCoord coord = new CharacterCoord(target.x, target.z);

				Vector3 diff = m_prev - target;
				if (diff.sqrMagnitude > 0.0001f) {

					m_culling.Add(coord);

					//Debug.Log("SendCharacterCoord[index:" + m_plotIndex + "]");
					CharacterRoot.get().SendCharacterCoord(controll.account_name, m_plotIndex, m_culling); 
					++m_plotIndex;

					if (m_culling.Count >= PLOT_NUM) {

						m_culling.RemoveAt(0);
					}

					m_prev = target;
				}
	
			} while(false);
		}
	}