Esempio n. 1
0
    protected string createFullName(Transform inParent, Transform toChild, byte maxFindCount)
    {
        Transform front    = toChild;
        string    fullName = "";

        //bool success = false;
        for (byte i = 0; i < maxFindCount; i++)
        {
            if (inParent == front)
            {
                //success = true;
                fullName = "~" + fullName;                 //~ == root
                break;
            }

            fullName = "/" + front.name + fullName;

            front = front.parent;
        }

        if (inParent != front)
        {
            DebugWide.LogWarning("unreachable  parent: " + fullName);
        }
        //if (false == success)
        //	return "";


        return(fullName);
    }
Esempio n. 2
0
    public IEnumerator UnityFileLoading()
    {
        string strFilePath = GlobalConstants.ASSET_PATH + "townNode.xml";

        DebugWide.Log("-------------" + strFilePath + "-------------");

        MemoryStream memStream = null;

        {
            UnityEngine.WWW wwwUrl = new UnityEngine.WWW(strFilePath);

            while (!wwwUrl.isDone)
            {
                if (wwwUrl.error != null)
                {
                    DebugWide.Log("error : " + wwwUrl.error.ToString());
                    yield break;
                }
                DebugWide.Log("wwwUrl.progress---" + wwwUrl.progress);
                yield return(null);
            }

            if (wwwUrl.isDone)
            {
                DebugWide.Log("wwwUrl.isDone---size : " + wwwUrl.size);
                DebugWide.Log("wwwUrl.isDone---bytesLength : " + wwwUrl.bytes.Length);
                memStream = new MemoryStream(wwwUrl.bytes);
            }
        }

        _nodeInfo.LoadXMLFromMemory(memStream);          //chamto test

        DebugWide.Log("AsyncLoading complete");
        yield return(memStream);
    }
Esempio n. 3
0
    void Update()
    {
        if (true == _apply)
        {
            Matrix4x4 trs = TRSHelper.ParsingMatrix(_parser, _multiOrder);

            //-----------
            //1. 비행기모양으로 배치된 객체에 적용 : _testTarget
            prev_angles = dest_angles;
            //1. 우주선모양으로 배치된 객체에 적용 : _testTarget
            //this.ApplyMatrixToTransform(_testTarget, trs);
            _testTarget.localRotation = TRSHelper.GetQuaternion(_parser);             //chamto test - Iv쿼터니언 바로 적용

            dest_angles = _testTarget.eulerAngles;
            DebugWide.LogBlue("2: unity angles : " + _testTarget.eulerAngles + "\n");            //chamto test

            //1. 좌표계모양으로 배치된 객체에 적용 : _testAxis
            this.ApplyMatrixToGroupPosition(_testAxis, trs);
            //-----------

            elapsedTime = 0;
            _apply      = false;
        }

        elapsedTime += Time.deltaTime;

        this.Repeat();
    }
Esempio n. 4
0
    public void PreOrderTraversal(string path, Transform data)
    {
        //1. visit
        //DebugWide.LogRed (path +"    "+ data.name); //chamto test
        uint value;

        if (true == _pathToKey.TryGetValue(path, out value))
        {
            //Debug.Assert (false);
            //UnityEngine.Assertions.Assert.IsFalse (true);

            //이미 있는 경로일 경우 자식쪽은 탐색을 중지 한다
            DebugWide.LogRed(path + "  이미 탐색한 경로입니다");
            return;
        }

        _pathToKey.Add(path, this.createKey());
        _keyToData.Add(_pathToKey [path], data);
        _dataToPath.Add(data, path);


        //2. traversal
        Transform[] tfoList = data.GetComponentsInChildren <Transform> (true);
        foreach (Transform child in tfoList)
        {
            if (child != data && child.parent == data)
            {
                this.PreOrderTraversal(path + "/" + child.name, child);
            }
        }
    }
Esempio n. 5
0
    public void TestPrint(string text)
    {
        List <string> list = this._incision(text);

        foreach (string s in list)
        {
            DebugWide.LogBlue(s);
        }
    }
Esempio n. 6
0
 public void TestPrint()
 {
     foreach (Sprite s in _loadedDict.Values)
     {
         DebugWide.LogBlue(s.name);
     }
     foreach (eSPRITE_NAME s in _loadedDict.Keys)
     {
         DebugWide.LogBlue(s);
     }
 }
Esempio n. 7
0
        //무기 휘두르기 : 키입력을 먼저한 쪽이 공격, 늦게한 쪽이 방어가 된다.
        public void Wield_Weapon(uint inputPNum)
        {
            const uint PLAYERNUM_1P = 1;
            const uint PLAYERNUM_2P = 2;

            Judgment.Result jResult = _judgment.GetResult();
            DebugWide.LogGreen(jResult.state_1p + "   " + jResult.state_2p);                      //chamto test

            if (inputPNum == PLAYERNUM_1P)
            {
                if (true == _2pInfo.IsAttacking())
                {
                    //방어 성공시 공격행동으로 전환 시킨다
                    if (Judgment.eState.BlockSucceed == jResult.state_1p)
                    {
                        _1pInfo.NextState(CharacterInfo.eState.Attack);
                        _skillMgr.InsertInterval(inputPNum, SkillMgr.eGestureKind.Attack_Sword);
                    }
                    else
                    {
                        _1pInfo.NextState(CharacterInfo.eState.Block);
                        _skillMgr.InsertInterval(inputPNum, SkillMgr.eGestureKind.Block_Sword);
                    }
                }
                else
                {
                    _1pInfo.NextState(CharacterInfo.eState.Attack);
                    _skillMgr.InsertInterval(inputPNum, SkillMgr.eGestureKind.Attack_Sword);
                }
            }
            if (inputPNum == PLAYERNUM_2P)
            {
                if (true == _1pInfo.IsAttacking())
                {
                    if (Judgment.eState.BlockSucceed == jResult.state_2p)
                    {
                        _2pInfo.NextState(CharacterInfo.eState.Attack);
                        _skillMgr.InsertInterval(inputPNum, SkillMgr.eGestureKind.Attack_Sword);
                    }
                    else
                    {
                        _2pInfo.NextState(CharacterInfo.eState.Block);
                        _skillMgr.InsertInterval(inputPNum, SkillMgr.eGestureKind.Block_Sword);
                    }
                }
                else
                {
                    _2pInfo.NextState(CharacterInfo.eState.Attack);
                    _skillMgr.InsertInterval(inputPNum, SkillMgr.eGestureKind.Attack_Sword);
                }
            }
        }
Esempio n. 8
0
    void OnDrawGizmos()
    {
        if (false == Selection.Contains(_joint.gameObject))
        {
            return;
        }
        Vector3 from, to;

        from = Vector3.zero;
        to   = from;

        //x,y:[-1~0~1]
        //x^2 + y^2 = 1
        const float SPACE_THETA = 0.5f;
        const float DIVISION = 9f;
        float       x = 1f, y = 0;
        float       dir   = -1f;
        float       dirY  = 1f;
        int         theta = 0;

        for (int i = 0; i <= DIVISION * 8; i++)
        {
            //x^2 + y^2 = 1
            y = 1f - (x * x);
            //y = Mathf.Pow (y, 0.5f);
            y  = Mathf.Sqrt(y);
            y *= dirY;

            DebugWide.LogBlue("theta: " + theta + "  x:" + x + "  y:" + y + "   y/x:" + y / x + "   tan:" + Mathf.Tan(theta * Mathf.Deg2Rad) + "   atan:" + Mathf.Atan2(y, x) * Mathf.Rad2Deg);
            //DebugWide.Log(" theta:" + theta + "  x:" + Mathf.Acos(x) * Mathf.Rad2Deg + "  y:" + Mathf.Asin(y) * Mathf.Rad2Deg);
            to.z        += SPACE_THETA;
            to.y         = y / x;
            Gizmos.color = Color.green;
            Gizmos.DrawLine(from, to);
            from = to;

            //------------------------
            //next value setting
            if (theta % 180 == 0 && theta != 0)
            {
                DebugWide.LogRed(theta);
                //x = Mathf.Clamp (x, -1f, 1f);
                //dir = x * -1;
                //x = dir;
                dir  *= -1;
                dirY *= -1f;
            }
            x     += dir * (1f / DIVISION);
            theta += (int)(90 / DIVISION);
        }
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        float value = 0f;

        for (int i = 2; i < 1000; i += 10)
        //for (int i = 10000 - 10 ; i < 10000; i++)  //100
        //for (int i = 1000 - 10 ; i < 1000; i++) //100
        //for (int i = 100 - 10 ; i < 100; i++) //10
        //for (int i = 10 - 10 ; i < 10; i++) //1
        {
            value = (float)i;
            DebugWide.LogBlue(i + ": fast : " + Util.Sqrt_Quick_2(value) + "  1?:" + Mathf.Sqrt(value) * Util.RSqrt_Quick_2(value));
            DebugWide.LogRed("        normal : " + Mathf.Sqrt(value));
        }
    }
Esempio n. 10
0
        //WidUseCoroutine 으로 사용해야 동작함. 유니티코루틴으로는 동작안함
        //ex) CSingleton<WideUseCoroutine>.Instance.StartCoroutine (t.LoadXML (), null, false, "CTableNodeInfo");
        public IEnumerator LoadXML()
        {
            //내부 코루틴 부분
            //------------------------------------------------------------------------
            DebugWide.Log(GlobalConstants.ASSET_PATH + m_strFileName);             //chamto test
            MemoryStream stream = null;

            yield return(ResourceManager.AsyncFileLoading(GlobalConstants.ASSET_PATH + m_strFileName, value => stream = value));

            if (null == stream)
            {
                DebugWide.Log("error : failed LoadFromFile : " + GlobalConstants.ASSET_PATH + m_strFileName);
                yield break;
            }
            this.LoadXMLFromMemory(stream);

            //chamto test
            //PrintValue ();
            //SaveXML ("Assets/StreamingAssets/"+"abc.xml", _data);
        }
Esempio n. 11
0
    IEnumerator WaitForAnimation(float ratio)
    {
        float accu = 0;

        while (float.Epsilon + accu < ratio)
        {
            waiting = true;
            accu   += Time.deltaTime;
            yield return(new WaitForEndOfFrame());
        }

        //_animator.speed = 1;
        AnimatorStateInfo info = _animator.GetCurrentAnimatorStateInfo(0);

        _animator.Play(info.fullPathHash, 0, 0);

        DebugWide.LogBlue("coru");

        waiting = false;
    }
Esempio n. 12
0
    //ex) XML_Manager.AsyncFileLoading(CDefine.ASSET_PATH + m_strFileName, value => stream = value)
    public static IEnumerator AsyncFileLoading(string strFilePath, System.Action <MemoryStream> result = null)
    {
        MemoryStream memStream = null;

                #if SERVER || TOOL
        {
            //CDefine.CommonLog("1__" + strFilePath); //chamto test
            memStream = new MemoryStream(File.ReadAllBytes(strFilePath));
        }
                #elif UNITY_IPHONE || UNITY_ANDROID || UNITY_EDITOR
        {
            UnityEngine.WWW wwwUrl = new UnityEngine.WWW(strFilePath);

            while (!wwwUrl.isDone)
            {
                if (wwwUrl.error != null)
                {
                    DebugWide.LogRed("error : " + wwwUrl.error.ToString());
                    yield break;
                }
                DebugWide.LogGreen("wwwUrl.progress---" + wwwUrl.progress);
                yield return(null);
            }

            if (wwwUrl.isDone)
            {
                DebugWide.LogGreen("wwwUrl.isDone---size : " + wwwUrl.size);
                DebugWide.LogGreen("wwwUrl.isDone---bytesLength : " + wwwUrl.bytes.Length);
                memStream = new MemoryStream(wwwUrl.bytes);
            }
        }
                #endif

        if (null != result)
        {
            result(memStream);
        }
        DebugWide.LogGreen("WWW Loading complete");
        yield return(memStream);
    }
Esempio n. 13
0
    void TouchBegan()
    {
        //NavGraphNode node = _pathFinder._graph.FindNearNode (Input_Unity.GetTouchWorldPos ());
        //Debug.Log ("findNode : "+node); //chamto test


        //chamto test code - layer collision test
        bool option = true;

        option = Physics2D.GetIgnoreLayerCollision(GlobalConstants.Layer.Num.superCat, GlobalConstants.Layer.Num.building);
        Physics2D.IgnoreLayerCollision(GlobalConstants.Layer.Num.superCat, GlobalConstants.Layer.Num.building, true);

        if (this.gameObject.layer != GlobalConstants.Layer.Num.superCat)
        {
            this.gameObject.layer = GlobalConstants.Layer.Num.superCat;
        }
        else
        {
            this.gameObject.layer = GlobalConstants.Layer.Num.default0;
        }

        DebugWide.Log("began");
    }
Esempio n. 14
0
        public void InsertInterval(uint characterNum, eGestureKind eKind)
        {
            ListInterval list          = null;
            float        lastInputTime = 0;

            if (true == _dictInterval.TryGetValue(characterNum, out list))
            {
                lastInputTime = list.lastInputTime;
            }

            GestureInterval gi = new GestureInterval();

            gi.kind     = eKind;
            gi.interval = Time.time - lastInputTime;

            if (null != list)
            {
                list.lastInputTime = Time.time;
            }
            DebugWide.LogBlue(gi.interval + "  : interval");                      //chamto test

            this.InsertInterval(characterNum, gi);
        }
Esempio n. 15
0
        public IEnumerator AniStart_Attack_1_Random(CharDataBundle bundle)
        {
            float time = 3f;

            bundle._gameObject.SetActive(true);
            iTween.Stop(bundle._gameObject);
            bundle._ui.RevertData_All();
            DebugWide.LogBlue("start----- " + Time.time);


            Vector3 start = bundle._gameObject.transform.localPosition;

            Vector3[] list = GetPaths(start);

            _prev_position_ = list [0];

            iTween.MoveTo(bundle._gameObject, iTween.Hash(
                              "time", time
                              , "easetype", "easeOutBack"
                              , "path", list
                              //,"orienttopath",true
                              //,"axis","z"
                              , "islocal", true     //로컬위치값을 사용하겠다는 옵션. 대상객체의 로컬위치값이 (0,0,0)이 되는 문제 있음. 직접 대상객체 로컬위치값을 더해주어야 한다.
                              , "movetopath", false //현재객체에서 첫번째 노드까지 자동으로 경로를 만들겠냐는 옵션. 경로 생성하는데 문제가 있음. 비활성으로 사용해야함
                              //"looktarget",new Vector3(5,-5,7)
                              , "onupdate", "AniUpdate_Attack_1_RandomTT"
                              , "onupdatetarget", gameObject
                              , "onupdateparams", bundle._gameObject.transform
                              ));

            yield return(new WaitForSeconds(time));

            iTween.Stop(bundle._gameObject);
            bundle._gameObject.SetActive(false);
            DebugWide.LogBlue("end----- " + Time.time);
        }
Esempio n. 16
0
    void compute1_Chain1()
    {
        Vector3 dirTo = _targetPos.position - _joint_2.position;

        float degree = Vector3.Angle(_joint_2.forward, dirTo);

        Vector3 up = Vector3.Cross(_joint_2.forward, dirTo);

        _joint_2.transform.Rotate(up, degree, Space.World);


//		Vector3 test = _joint_2.transform.localEulerAngles;
//		if (test.x >= 180f) {
//			test.x -= 180f;
//		}
        //Matrix4x4 m = Matrix4x4.identity;



        //DebugWide.LogBlue (Quaternion.FromToRotation(_joint_2.forward, dirTo).eulerAngles);
        DebugWide.LogBlue("    " + _joint_2.transform.localEulerAngles);
        //_joint_2.transform.localEulerAngles = this.ClampV3 (_joint_2.transform.localEulerAngles, _DOF_Min, _DOF_Max);
        //DebugWide.LogBlue ("     "+_joint_2.transform.localEulerAngles);
    }
Esempio n. 17
0
 void OnCollisionExit(Collision col)
 {
     DebugWide.LogBlue("OnCollisionExit:  " + col.gameObject.name);
 }
Esempio n. 18
0
    public static TouchPhase GetTouchEvent()
    {
        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            if (Input.touchCount > 0)
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    DebugWide.LogWhite("Update : TouchPhase.Began");                      //chamto test
                    return(TouchPhase.Began);
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)
                {
                    DebugWide.LogWhite("Update : TouchPhase.Moved");                      //chamto test
                    return(TouchPhase.Moved);
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Ended)
                {
                    DebugWide.LogWhite("Update : TouchPhase.Ended");                      //chamto test
                    return(TouchPhase.Ended);
                }
                else
                {
                    DebugWide.LogWhite("Update : Exception Input Event : " + Input.GetTouch(0).phase);
                    return(Input.GetTouch(0).phase);
                }
            }
        }
        else if (Application.platform == RuntimePlatform.OSXEditor)
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (false == f_isEditorDraging)
                {
                    //DebugWide.LogWhite ("______________ MouseButtonDown ______________"); //chamto test

                    f_isEditorDraging = true;

                    return(TouchPhase.Began);
                }
            }

            if (Input.GetMouseButtonUp(0))                      //mouse Up

            //DebugWide.LogWhite ("______________ MouseButtonUp ______________"); //chamto test
            {
                f_isEditorDraging = false;

                return(TouchPhase.Ended);
            }

            //else
            if (Input_Unity.GetMouseButtonMove(0))                      //mouse Move

            {
                if (f_isEditorDraging)                          ///mouse Down + Move (Drag)

                //DebugWide.LogWhite ("______________ MouseMoved ______________"); //chamto test

                {
                    return(TouchPhase.Moved);
                }        //if
            }            //if
        }
        return(TouchPhase.Canceled);
    }
Esempio n. 19
0
    void Push_TouchEvent()
    {
        //DebugWide.Log(Input.touchCount);

        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            if (Input.touchCount > 0)
            {
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    //DebugWide.LogError("Update : TouchPhase.Began"); //chamto test
                    Init_PrevTouchMovedPos();
                    m_TouchedObject = SendMessage_TouchObject("TouchBegan", Input.GetTouch(0).position);
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(0).phase == TouchPhase.Stationary)
                {
                    //DebugWide.LogError("Update : TouchPhase.Moved"); //chamto test

                    if (null != m_TouchedObject)
                    {
                        m_TouchedObject.SendMessage("TouchMoved", 0, SendMessageOptions.DontRequireReceiver);
                    }

                    Update_PrevTouchMovedPos();
                }
                else if (Input.GetTouch(0).phase == TouchPhase.Ended)
                {
                    //DebugWide.LogError("Update : TouchPhase.Ended"); //chamto test
                    //checkInput("TouchEnded",Input.GetTouch(0).position);
                    if (null != m_TouchedObject)
                    {
                        m_TouchedObject.SendMessage("TouchEnded", 0, SendMessageOptions.DontRequireReceiver);
                    }
                    m_TouchedObject = null;
                }
                else
                {
                    DebugWide.LogError("Update : Exception Input Event : " + Input.GetTouch(0).phase);
                }
            }
        }
        else if (Application.platform == RuntimePlatform.OSXEditor)
        {
            //Debug.Log("mousedown:" +Input.GetMouseButtonDown(0)+ "  mouseup:" + Input.GetMouseButtonUp(0) + " state:" +Input.GetMouseButton(0)); //chamto test
            if (Input.GetMouseButtonDown(0))
            {
                //Debug.Log ("______________ MouseBottonDown ______________" + m_TouchedObject); //chamto test

                //if(0 == (m_prevMousePosition - Input.mousePosition).sqrMagnitude)
                {                       //mouse Down
                    if (false == f_isEditorDraging)
                    {
                        //Init_PrevTouchMovedPos();
                        m_TouchedObject = SendMessage_TouchObject("TouchBegan", Input.mousePosition);
                        if (null != m_TouchedObject)
                        {
                            f_isEditorDraging = true;
                        }
                    }
                }

                //DebugWide.Log("--------------"); //chamto test
            }

            if (Input.GetMouseButtonUp(0))
            {                   //mouse Up
                                //Debug.Log ("______________ MouseButtonUp ______________" + m_TouchedObject); //chamto test
                f_isEditorDraging = false;

                if (null != m_TouchedObject)
                {
                    m_TouchedObject.SendMessage("TouchEnded", 0, SendMessageOptions.DontRequireReceiver);
                }
                m_TouchedObject = null;
                //checkInput("TouchEnded",Input.mousePosition);
            }

            //else
            if (Input_Unity.GetMouseButtonMove(0))
            {                   //mouse Move
                if (f_isEditorDraging)
                {               ///mouse Down + Move (Drag)
                    //Debug.Log ("______________ MouseMoved ______________" + m_TouchedObject); //chamto test

                    if (null != m_TouchedObject)
                    {
                        m_TouchedObject.SendMessage("TouchMoved", 0, SendMessageOptions.DontRequireReceiver);
                    }

                    //Update_PrevTouchMovedPos();
                }        //if
            }            //if

            //m_prevMousePosition = Input.mousePosition;
        }
    }
Esempio n. 20
0
 void TouchEnded()
 {
     DebugWide.Log("ended");
 }
Esempio n. 21
0
    public void StartCoroutine(IEnumerator routine, coroutineCallBack callBack = null, bool asynchronous = false, string strName = "")
    {
        if (null == routine)
        {
            return;
        }

        coroutineJob job = new coroutineJob();

        if (true == asynchronous)
        {   //********* 비동기 **********
            job.etorRoot         = routine;
            job.etorCurrentDepth = routine;
            job.callBack         = callBack;
            listCoroutine.Add(job);
        }
        else
        {   //********** 동기 **********
            //코루틴 수행
            job.etorRoot         = routine;
            job.etorCurrentDepth = routine;
            //int coroutineCount = 0;

            //float startTime = 0f;
            //float endTime = 0f;
            //float timeElapsed = 0f;
            //while(true)
            int processCount = 1;
            for (int i = 0; i < processCount; i++) //chamto test , while로 무한대로 돌리면 유니티에디터가 정지상태가 됨
            {
                //Time 같은 유니티 전용함수를 쓰면 서버에서 컴파일이 안됨
                //startTime = Time.realtimeSinceStartup;
                //timeElapsed += (endTime - startTime);

                //---------------------------------------------------------------------------------------------------
                if (false == job.etorCurrentDepth.MoveNext())
                {         //******* 현재 코루틴 완료 *******
                    if (job.etorRoot == job.etorCurrentDepth)
                    {     //최상위 부모 코루틴으로 돌아왔을때  콜백호출후, 코루틴 처리를 마친다.
                        if (null != callBack)
                        { //콜백요청이 있다면 처리해 준다.
                            callBack(job.etorCurrentDepth.Current);
                        }

                        DebugWide.Log("현재 코루틴 완료" + "   " + strName);
                        break;
                    }
                    else
                    {
                        processCount++;
                        job.etorCurrentDepth = job.stackPrev.Pop();
                    }
                }
                //---------------------------------------------------------------------------------------------------
                else
                {   //******* 현재 코루틴 진행중 *******
                    processCount++;

                    //DebugWide.Log("현재 코루틴 진행중" + "   " + strName);
                    if (null != job.etorCurrentDepth.Current && job.etorCurrentDepth.Current is IEnumerator)
                    {
                        job.stackPrev.Push(job.etorCurrentDepth);
                        job.etorCurrentDepth = job.etorCurrentDepth.Current as IEnumerator;
                    }
                }//end else

                //System.Threading.Thread.Sleep(10); //while 문에서 CPU계속 점유하는 현상이 있어 넣어봄
                //---------------------------------------------------------------------------------------------------
                //endTime = Time.realtimeSinceStartup;
            } //end while
        }     //end else
    }
Esempio n. 22
0
    static public Matrix4x4 ParsingMatrix(TRSParser parser, string order)
    {
        parser.Parsing(order);

        Matrix4x4 trs = Matrix4x4.identity;

        foreach (TRSParser.Sentences sts in parser)
        {
            if (0 == sts.Count)
            {
                continue;
            }

            switch (sts.kind)
            {
            case TRSParser.Sentences.eKind.Translate:
            {
                trs = trs * TRSHelper.GetTranslate(sts [0].xyz);
            }
            break;

            case TRSParser.Sentences.eKind.Rotate:
            {
                if (TRSParser.Command.eKind.X == sts [0].kind)
                {
                    trs = trs * TRSHelper.GetRotateX(sts [0].degree);
                }
                if (TRSParser.Command.eKind.Y == sts [0].kind)
                {
                    trs = trs * TRSHelper.GetRotateY(sts [0].degree);
                }
                if (TRSParser.Command.eKind.Z == sts [0].kind)
                {
                    trs = trs * TRSHelper.GetRotateZ(sts [0].degree);
                }
            }
            break;

            case TRSParser.Sentences.eKind.Quaternion:
            {
                IvQuat  q     = new IvQuat();
                Vector3 v3Rad = sts [0].xyz * Mathf.Deg2Rad;
                q.Set(v3Rad.z, v3Rad.y, v3Rad.x);
                Matrix4x4 m = q.GetMatrix();
                trs = trs * m;

                //chamto test - print fixedAngles of IvQuat
                Vector3 angles = IvQuat.GetFixedAnglesFrom(ref m);
                angles *= Mathf.Rad2Deg;
                DebugWide.LogRed("1: IvQuat angles : " + angles + "\n");                        //chamto test
            }
            break;

            case TRSParser.Sentences.eKind.Scale:
                trs = trs * TRSHelper.GetScale(sts [0].xyz);
                break;
            }
        }

        return(trs);
    }
Esempio n. 23
0
 void TouchMoved()
 {
     DebugWide.Log("moved");
 }
Esempio n. 24
0
    //void Update ()
    void FixedUpdate()
    {
        //Utility.Line.UpdateDebugLine(transform, this.name+"_destPos", transform.position, _destPos); //chamto test
        //Utility.Line.UpdateDebugLineScale(this.name+"_destPos", transform.localScale);

        if (true == Input_Unity.IsTouch())
        {
            Vector3 touchPos = Input_Unity.GetTouchWorldPos();

            //DebugWide.LogRed(GlobalConstants.Hierarchy.gameViewArea); //chamto test
            if (true == GlobalConstants.Hierarchy.gameViewArea.Contains(touchPos))
            {
                if (Cat.eMove.Super == _moveMode)
                {
                    _pathPos.Clear();
                    _pathPos.Push(touchPos);
                }
                else
                {
                    //_pathPos = _pathFinder.Search(transform.position, Input_Unity.GetTouchWorldPos ());
                    _pathFinder.SearchNonAlloc(transform.position, touchPos, ref _pathPos);

#if UNITY_EDITOR
                    //chamto test
                    //Utility.Line.UpdateDebugLine(transform, this.name+"_path", _pathPos.ToArray(),Color.green, Color.black);
#endif
                }



                _STATE = 1;
                this.State_MoveNext();
            }
        }

        switch (_STATE)
        {
        case 0:         //idle
        {
            _dir      = _destPos - transform.position;
            sumTime1 += Time.deltaTime;
            sumTime2 += Time.deltaTime;

            if (Cat.eArrive.Normal == _arriveMode)
            {
                //--------------------------------
                //normal
                //_rb2d.AddForce (_dir, ForceMode2D.Force); // == force
            }
            if (Cat.eArrive.Good == _arriveMode)
            {
                //--------------------------------
                //서로 나누어 먹는 느낌
//				if(_rb2d.velocity.sqrMagnitude <= 10.8f)
                _rb2d.AddForceAtPosition(_dir, _destPos, ForceMode2D.Impulse);                         //++ force
//				else
//					_rb2d.velocity = Vector2.zero; //cat stop
            }
            if (Cat.eArrive.Grabber == _arriveMode)
            {
                //--------------------------------
                //혼자 먹으려 싸우는 느낌
                _rb2d.MovePosition(_destPos);
            }
        }
        break;

        case 1:         //move to pos
        {
            //DebugWide.LogRed("moveToPos  state-1 : "); //chamto test
            this.State_UpdateMoveToPos();

            if (true == this.State_ArriveOn())
            {
                _STATE = 2;
            }
        }
        break;

        case 2:         //Landing
        {
            if ((null != _pathPos && 0 == _pathPos.Count) ||
                null == _pathPos)
            {
                _STATE = 0;
            }


            if (true == _isContactBuilding)
            {
                if (null != _pathPos && 0 != _pathPos.Count)
                {
                    _STATE = 1;
                    //_isContactBuilding = false;
                    State_MoveNext();
                }
            }
        }
        break;

        case 3:                                                           //falling
        {
            DebugWide.LogRed("falling  state-3 : " + _isContactBuilding); //chamto test
            if (true == _isContactBuilding)
            {
                _STATE = 1;
                //_isContactBuilding = false;
                this.gameObject.layer = GlobalConstants.Layer.Num.superCat;
            }
        }
        break;
        }        //end switch

        this.AniDirection(_destPos - transform.position);
    }
Esempio n. 25
0
        // Update is called once per frame
        void Update()
        {
            _1pInfo.Update_State();
            _2pInfo.Update_State();

            _judgment.Update();
            this.Update_UI();

            //restart
            if (Input.GetKeyUp("v"))
            {
                DebugWide.LogBlue("restart");
            }

            //////////////////////////////////////////////////
            //1p

            //attack
            if (Input.GetKeyUp("q"))
            {
                DebugWide.LogBlue("1p - wield");
                //_1pInfo.NextState (CharacterInfo.eState.Attack);
                this.Wield_Weapon(1);
            }

            //block
//				if (Input.GetKeyUp ("w"))
//				{
//					DebugWide.LogBlue ("1p - block");
//					_1pInfo.NextState (CharacterInfo.eState.Block);
//				}

            //auto mode
            if (Input.GetKeyUp("a"))
            {
                DebugWide.LogBlue("1p - auto");
            }


            //////////////////////////////////////////////////
            //2p

            //attack
            if (Input.GetKeyUp("o"))
            {
                DebugWide.LogBlue("2p - wield1");
                //_2pInfo.NextState (CharacterInfo.eState.Attack);
                this.Wield_Weapon(2);
            }

            //block
//				if (Input.GetKeyUp ("p"))
//				{
//					DebugWide.LogBlue ("2p - block");
//					_2pInfo.NextState (CharacterInfo.eState.Block);
//				}

            //auto mode
            if (Input.GetKeyUp("l"))
            {
                DebugWide.LogBlue("2p - auto");
            }
        }        //end Update
Esempio n. 26
0
    void Update()
    {
        if (true == _Update_perform)
        {
            //code..

            //chamto 20160611
            //각각의 단위가 존재
            //하나는 화면의 세로 픽셀 개수
            //하나는 3d카메라의 월드 세로 길이 (줄여서 월드길이)
            //화면의 픽셀 하나에 대한 월드 길이를 계산할려면?  = 월드길이 / 픽셀 개수
            //전체월드길이에 대하여 픽셀개수로 나누면 하나의 픽셀에 대한 월드길이가 나온다.
            //* 나눗셈은 등분하겠다는 의미임을 생각하자 !
            float pixelPerWorldUnit =
                Camera.main.orthographicSize * 2 / defCameraPixels;

            if (spriteOrientation == SpriteOrientation.MiddleCenter)
            {
                _mesh.vertices = new Vector3[]
                {
                    new Vector3(-spriteSize.x, -spriteSize.y) * pixelPerWorldUnit * 0.5f,                    //left-down 0
                    new Vector3(-spriteSize.x, spriteSize.y) * pixelPerWorldUnit * 0.5f,                     //left-up 1
                    new Vector3(spriteSize.x, -spriteSize.y) * pixelPerWorldUnit * 0.5f,                     //right-down 2
                    new Vector3(spriteSize.x, spriteSize.y) * pixelPerWorldUnit * 0.5f                       //right-up 3
                };
            }
            else if (spriteOrientation == SpriteOrientation.TopLeft)
            {
                _mesh.vertices = new Vector3[]
                {
                    new Vector3(0, -spriteSize.y) * pixelPerWorldUnit,
                    new Vector3(0, -progressBar.y) * pixelPerWorldUnit,
                    new Vector3(spriteSize.x, -spriteSize.y) * pixelPerWorldUnit,
                    new Vector3(spriteSize.x, -progressBar.y) * pixelPerWorldUnit
                };
            }

            _mesh.triangles = new int[] { 0, 1, 3, 0, 3, 2 };

            float texWidth  = _renderer.sharedMaterial.mainTexture.width;
            float texHeight = _renderer.sharedMaterial.mainTexture.height;

            //opengl의 텍스쳐좌표 원점은 dirextx와 달리 좌하단이다.
            //유니티는 opengl의 텍스쳐좌표 방식을 사용하는것 같다.
            //유니티의 월드좌표계는  dirextx의 왼손좌표계를 사용한다.
            //텍스쳐좌표가 좌하단에서 부터 상단으로 증가되므로 텍스쳐가 뒤집혀 보이게 된다.
            //이 때문에 세로축 uv값에 역수(1-uv)를 취하여 상/하를 다시 뒤집는다.
            Vector2 texelPerUvUnit = new Vector2(1f / texWidth, 1f / texHeight);

            _mesh.uv = new Vector2[]
            {
                new Vector2(texelPerUvUnit.x * spriteTopLeft.x,
                            1f - (texelPerUvUnit.y * (spriteTopLeft.y + spriteSize.y))),                        //left-up 1

                new Vector2(texelPerUvUnit.x * spriteTopLeft.x,
                            1f - (texelPerUvUnit.y * (spriteTopLeft.y + progressBar.y))),                                                       //left-down 0

                new Vector2(texelPerUvUnit.x * (spriteTopLeft.x + spriteSize.x),
                            1f - (texelPerUvUnit.y * (spriteTopLeft.y + spriteSize.y))),                        //right-up 3

                new Vector2(texelPerUvUnit.x * (spriteTopLeft.x + spriteSize.x),
                            1f - (texelPerUvUnit.y * (spriteTopLeft.y + progressBar.y)))                                        //right-down 2
            };

            //_mesh.uv [0].y += progressBar.y;
            //_mesh.uv [3].y += progressBar.y;

            //----
//			_mesh.uv = new Vector2[]
//			{
//				new Vector2(0,0),
//				new Vector2(0,1 + 0.2f), //top
//				new Vector2(1,0),
//				new Vector2(1,1 + 0.2f)  //top
//			};

            foreach (Vector2 v2 in _mesh.uv)
            {
                DebugWide.LogBlue(v2);                 //chamto test
            }
            DebugWide.LogBlue("offset " + _renderer.sharedMaterial.mainTextureOffset);
            DebugWide.LogBlue("scale " + _renderer.sharedMaterial.mainTextureScale);
            //----

            _mesh.Optimize();
            _mesh.RecalculateNormals();
            _mesh.RecalculateBounds();


            _Update_perform = false;
        }
    }
Esempio n. 27
0
    void OnTriggerEnter(Collider other)
    {
        DebugWide.LogBlue(other.gameObject.name + "  " + _multi.trgPrcs.status);
        //DebugWide.LogBool (_tPcs.name.Equals("Character"), "animator - " + _tPcs.name + " - trigger Enter : " +  other.tag + "  " + other.name);

        switch (_multi.trgPrcs.status)
        {
        case eCollisionStatus.Hit:
        {
            const float MAX_SCALE     = 2f;
            const float INCREASE_RATE = 0.05f;
            _damageRate += INCREASE_RATE;
            _damageRate  = _damageRate > MAX_SCALE ? MAX_SCALE : _damageRate;
            //DebugWide.LogBlue ("hit  "+_damageRate);
            _head.localScale = new Vector3(_damageRate, _damageRate, _damageRate);
        }
        break;

        case eCollisionStatus.Damage:
        {
            const float MIN_SCALE     = 0.2f;
            const float DECREASE_RATE = 0.05f;
            _damageRate -= DECREASE_RATE;
            _damageRate  = _damageRate < MIN_SCALE ? MIN_SCALE : _damageRate;
            //DebugWide.LogBlue ("damage   "+_damageRate);
            this.PlayDamage(_damageRate, other.transform.position);
        }
        break;

        case eCollisionStatus.Block_Body:
        {
            //_ani.SetInteger ("state", (int)eAniState.Damage);
        }
        break;

        case eCollisionStatus.Block_Weapon:
        {
            //Block_up : Attack_up , Attack_sting
            //Block_middle : Attack_hand , Attack_middle , Attack_down

            switch ((eAniState)_multi.animator.GetInteger("state"))
            {
            case eAniState.Attack_up:
//				case eAniState.Attack_sting:
//
//				case eAniState.Attack_hand:
//				case eAniState.Attack_middle:
//				case eAniState.Attack_down:
            {
                this.PlayBlockWeapon();
            }
            break;
            }


            //_ani.SetInteger ("state", (int)eAniState.Damage);
        }
        break;

        case eCollisionStatus.Block_Objects:
        {
            //DebugWide.LogBlue ("block_objects");
        }
        break;
        }

        //Debug.Log ("---animator status Enter--------"+ _tPcs.name + "  "+_tPcs.DetectedStatus()); //chamto test
    }
Esempio n. 28
0
 void OnCollisionStay(Collision col)
 {
     DebugWide.LogBlue("OnCollisionStay:  " + col.gameObject.name);
 }