Example #1
0
        public void Tick(float deltaTime)
        {
            if (mainPawn != null)
            {
                ActorInstance.Room room     = mainPawn.curRoom;
                IntVector3         logicPos = room.LogicPosition;
                LAYER layer = logicPos.y == -1 ? LAYER.BASEMENT : (logicPos.y == 0 ? LAYER.GROUND : LAYER.UPSTAIRS);
                SetLayer(layer);
                Vector3 pos = new Vector3(bkgCenter.x + logicPos.x * 20, bkgCenter.y + logicPos.z * 20, 0);

                Transform pawnTrans = mainPawn.transform;

                Vector2 delta = room.WorldToLogic(pawnTrans.position);
                pos.x += delta.x * 20;
                pos.y += delta.y * 20;

                Quaternion    pawnRot  = pawnTrans.rotation;
                Quaternion    logicRot = room.WorldToLogic(pawnRot);
                float         yaw      = logicRot.eulerAngles.y;
                RectTransform tran     = mainCharImg.rectTransform;
                Vector3       euler    = tran.rotation.eulerAngles;
                euler.z = -yaw;

                tran.localPosition = pos;
                tran.rotation      = Quaternion.Euler(euler);
                //tran.SetPositionAndRotation(pos, Quaternion.Euler(euler));
            }
        }
Example #2
0
        void SetLayer(LAYER layer)
        {
            if (layer == curLayer)
            {
                return;
            }
            curLayer = layer;
            switch (curLayer)
            {
            case LAYER.BASEMENT:
                minimapImgBasement.enabled = true;
                minimapImgBasement.SetMeshDirty();
                minimapImgGround.enabled   = false;
                minimapImgUpstairs.enabled = false;
                break;

            case LAYER.GROUND:
                minimapImgBasement.enabled = false;
                minimapImgGround.enabled   = true;
                minimapImgGround.SetMeshDirty();
                minimapImgUpstairs.enabled = false;
                break;

            case LAYER.UPSTAIRS:
                minimapImgBasement.enabled = false;
                minimapImgGround.enabled   = false;
                minimapImgUpstairs.enabled = true;
                minimapImgUpstairs.SetMeshDirty();
                break;
            }
        }
Example #3
0
 public void SyncPawn(CharacterPawn pawn)
 {
     mainPawn = pawn;
     if (mainPawn.curRoom != null)
     {
         IntVector3 logicPos = mainPawn.curRoom.LogicPosition;
         LAYER      layer    = logicPos.y == -1 ? LAYER.BASEMENT : (logicPos.y == 0 ? LAYER.GROUND : LAYER.UPSTAIRS);
         SetLayer(layer);
     }
 }