コード例 #1
0
    //gravity--------------------------------------------------------------------------------------------------------------//



    // Use this for initialization
    void Start()
    {
        rb = GetComponent <Rigidbody>();
        tm = GetComponent <TouchMove>();
        //_charaCtrl = GetComponent<CharaCtrl>();
        anim = GetComponentInChildren <Animator>();
    }
コード例 #2
0
    /// <summary>
    /// 加载船上楼梯
    /// </summary>
    public static void LoadShipPutStairBuild(int ID, int DataID, BuildInfo Info)
    {
        if (Info == null)
        {
            return;
        }
        Transform parentT = GetLifeMBornNode(true);

        if (parentT == null)
        {
            return;
        }
        Int2       BornPos   = new Int2(Info.m_cx, Info.m_cy);
        Vector3    local     = RoomMap.GetShipBuildLocalPos(BornPos, ShipBuildType.BuildStair);
        Vector3    world     = Local2WorldPos(local);
        Building   buildlife = LifeFactory.CreateBuilding(Info, DataID, parentT, world, LifeEnvironment.Edit);
        TouchMove  touch     = buildlife.m_thisT.GetChild(0).gameObject.AddComponent <TouchMove>();
        Vector2    size      = new Vector2(Info.m_Shape.width, Info.m_Shape.height);
        CanvasCore Core      = new CanvasCore(ShipBuildType.BuildStair, false, ID, DataID, size);

        touch.InitTouchMoveCore(Core, BornPos, buildlife);

        AddBuildingEditPlugin(touch);
        TouchMoveManager.JointShipBuild(touch);
    }
コード例 #3
0
    /// <summary>
    /// 设置当前选中对象
    /// </summary>
    public static void SetCurTouchMove(TouchMove touch)
    {
        if (null != m_SelTouch)
        {
            if (touch != m_SelTouch)
            {
                //m_SelTouch.ResetPos();
                //m_SelTouch.ShowMoveArrow(false);
                m_SelTouch.ShowTrapRoomUI(false);
                m_SelTouch.DestroyAttackRange();
                m_SelTouch.UnLoadEditEffect();
                //m_SelTouch.LeaveRoom();
            }
        }
        if (touch != null)
        {
            touch.TweenColor();
            touch.LoadEditEffect(TouchMoveState.CanEdit);
            // touch.ShowMoveArrow(true);
        }
        if (touch != m_SelTouch)
        {
            if (m_SelTouch)
            {
                m_PreTouch = m_SelTouch;
                m_SelTouch.StopTweenColor();
            }
        }

        m_SelTouch = touch;
    }
コード例 #4
0
        private void OnTouchEvent(TouchActivityEvent ev)
        {
            for (int i = 0; i < ev.Pointers.Count; ++i)
            {
                TouchActivityEvent.PointerInfo pointer = ev.Pointers[i];

                switch (ev.Action)
                {
                case MotionEventActions.Down:
                case MotionEventActions.PointerDown:
                {
                    TouchDown?.Invoke(this, pointer.X, pointer.Y, pointer.Id);
                    break;
                }

                case MotionEventActions.Up:
                case MotionEventActions.PointerUp:
                {
                    TouchUp?.Invoke(this, pointer.X, pointer.Y, pointer.Id);
                    break;
                }

                case MotionEventActions.Move:
                {
                    TouchMove?.Invoke(this, pointer.X, pointer.Y, pointer.Id);
                    break;
                }
                }
            }
        }
コード例 #5
0
    void BtnSetTransGate_OnClickEventHandler(UIButton sender)
    {
        SetBuildParaStart();
        List <CanvasCore> childrenCore = PutCanvasM.GetChildByCore(m_Core);

        if (childrenCore.Count == 0)
        {
#if UNITY_EDITOR_LOG
            NGUIUtil.DebugLog("房间内未检测到传送门,请调查!!!");
#endif
            return;
        }
        ShipPlan P = ShipPlanDC.GetCurShipPlan();
        if (P == null)
        {
            return;
        }
        foreach (var childCore in childrenCore)
        {
            TouchMove     tm      = PutCanvasM.GetTouchMoveByCore(childCore);
            BuildProperty lifeobj = tm.GetComponent <BuildProperty>();
            if (lifeobj != null && lifeobj.GetModeType() == 1605)
            {
                Building1605 b = lifeobj.GetLife() as Building1605;
                if (b != null)
                {
                    ShipPutInfo Info = P.GetShipBuildInfo(m_Core);
                    b.ShowTranGate(new Int2(Info.shipput_data0, Info.shipput_data1));
                }
            }
        }
    }
コード例 #6
0
 protected void OnTouchMove(TouchMove e)
 {
     if (e.touch.fingerId == m_touchID)
     {
         OnInputDrag(Services.GameManager.MainCamera.ScreenToWorldPoint(e.touch.position));
     }
 }
コード例 #7
0
ファイル: PlaneClickGrid.cs プロジェクト: 741645596/batgame
    /// <summary>
    /// 设置参数(如传送门的传送点)
    /// </summary>
    void SetPara()
    {
        if (RoomMap.CheckRoomGridInBoat(m_roomGridTouchDown))
        {
            TouchMove tm = TouchMoveManager.GetCurTouchMove();
            if (tm)
            {
                Int2       paramPos = m_roomGridTouchDown.SoldierPos;
                CanvasCore buildRoomCoreTouchDown = m_roomGridTouchDown.GetBuildRoom();
                tm.SetBuildParam(buildRoomCoreTouchDown, paramPos.Unit, paramPos.Layer);
                tm.SetBuildParaOver();
                //传送门 这里没获取到

                BuildProperty lifeobj = tm.GetComponent <BuildProperty>();
                if (lifeobj != null && lifeobj.GetModeType() == 1605)
                {
                    Building1605 b1605 = lifeobj.GetLife() as Building1605;
                    if (b1605 != null)
                    {
                        b1605.SetTransGate(paramPos);
                    }
                }
            }
        }
        else
        {
            NGUIUtil.ShowTipWndByKey("88800013");
        }
        m_roomGridTouchDown = null;
    }
コード例 #8
0
    /// <summary>
    /// 加载船上炮弹兵
    /// </summary>
    public static void LoadShipPutSoldier(int ID, int DataID, SoldierInfo Info)
    {
        if (Info == null)
        {
            return;
        }

        Role r = new Role();

        r.CreateSkin(GetLifeMBornNode(true), Info.m_modeltype, Info.m_name, AnimatorState.Stand, true);
        //IGameRole i = GameRoleFactory.Create(GetLifeMBornNode(true), Info.m_modeltype, Info.m_name, AnimatorState.Stand);
        GameObject go = r.RoleSkinCom.tRoot.gameObject;

        go.name = Info.m_name;
        Int2 BornPos = new Int2(Info.CX, Info.CY);

        go.transform.localPosition = RoomMap.GetShipBuildLocalPos(BornPos, ShipBuildType.Soldier);
        go.transform.localPosition = U3DUtil.SetZ(go.transform.localPosition, -2.0f);

        Transform  tRole = go.transform.GetChild(0);
        TouchMove  touch = tRole.gameObject.AddComponent <TouchMove>();
        CanvasCore Core  = new CanvasCore(ShipBuildType.Soldier, false, ID, DataID, Vector2.zero);

        touch.InitTouchMoveCore(Core, BornPos, null);

        AddBuildingEditPlugin(touch);
        if (Info.SoldierTypeID == 100003)   //隐藏蹦蹦
        //RolePropertyM rpm = i.GetBodyComponent<RolePropertyM>();
        {
            r.RoleSkinCom.ShowLeftHand(false);
        }
        TouchMoveManager.JointShipBuild(touch);
    }
コード例 #9
0
ファイル: LineCtrl.cs プロジェクト: kubo-t/test
    //Material[] mats;

    // Use this for initialization
    void Start()
    {
        gameManager = GameObject.Find("GameManager");
        gameManager.GetComponent <GameCtrl> ().lineObjects.Add(this.gameObject);

        this.transform.rotation = Quaternion.Euler(90f, 0f, 0f);

        player   = gameObject.transform.parent.gameObject;
        startPos = player.transform.position;

        lineRenderer = this.GetComponent <LineRenderer> ();

        lineRenderer.numCornerVertices = 5;         //角をなめらかにする度合い

        lineRenderer.SetPosition(0, startPos);
        lineRenderer.SetPosition(1, player.transform.position);

        buttonCtrl = GameObject.Find("ButtonCtrl");
        touchMove  = buttonCtrl.GetComponent <TouchMove> ();

        playerCtrl = player.GetComponent <PlayerCtrl> ();

        /*
         * mats = lineRenderer.materials;
         * mats [0] = material1;
         * mats [1] = material2;
         */
        //lineRenderer.material = material1;
    }
コード例 #10
0
    public void MoveWithRoom(CanvasCore roomCore)
    {
        if (roomCore.m_type != ShipBuildType.BuildRoom)
        {
            return;
        }
        TouchMove         tmParent     = PutCanvasM.GetTouchMoveByCore(roomCore);
        List <CanvasCore> childrenCore = PutCanvasM.GetChildByCore(roomCore);

        if (childrenCore.Count == 0 || roomCore.IsDeckRoom)
        {
            return;
        }
        Transform roomShellT = PutCanvasM.GetTransformByCore(roomCore).parent;

        foreach (var childCore in childrenCore)
        {
            TouchMove tm = PutCanvasM.GetTouchMoveByCore(childCore);
            if (tm != null)
            {
                tm.m_OffsetGrid = tmParent.m_orgPosMapGrid - tm.m_orgPosMapGrid;
            }
            if (PutCanvasM.GetTransformByCore(childCore) != null)
            {
                Transform childShellT = PutCanvasM.GetTransformByCore(childCore).parent;
                childShellT.parent = roomShellT;
            }
        }
    }
コード例 #11
0
ファイル: CanvasCore.cs プロジェクト: 741645596/batgame
    public void RemoveSelf()
    {
        TouchMove tm = TouchMoveManager.GetShipBuild(this);

        if (tm != null)
        {
            tm.DestroyShipBuild();
        }
    }
コード例 #12
0
 internal void OnTouchMove(TouchEventArgs args)
 {
     if (HandleTouchDownEnter)
     {
         TouchState = TouchStates.Touched;
         ChangeVisualState();
     }
     TouchMove?.Invoke(this, args);
 }
コード例 #13
0
        public void OnTouchMoveTest()
        {
            PrivateObject           param0 = null;                                // TODO: Initialize to an appropriate value
            D2DViewControl_Accessor target = new D2DViewControl_Accessor(param0); // TODO: Initialize to an appropriate value
            TouchMove pTouchMove           = null;                                // TODO: Initialize to an appropriate value

            target.OnTouchMove(pTouchMove);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
コード例 #14
0
    /// <summary>
    /// 设置移动到船上
    /// </summary>
    public static void MoveToShip(CanvasCore Core)
    {
        TouchMove tm = GetShipBuild(Core);

        if (tm != null)
        {
            tm.MyCore().IsNewCreate = false;
        }
    }
コード例 #15
0
    public static void ShowRoomGridUI(bool bShow)
    {
        TouchMove tm = TouchMoveManager.GetCurTouchMove();

        if (tm != null)
        {
            tm.ShowTrapRoomUI(bShow);
        }
    }
コード例 #16
0
        public override void TouchesMoved(NSSet touches, UIEvent?evt)
        {
            base.TouchesMoved(touches, evt);

            var    viewPoints = this.GetPointsInView(evt);
            PointF viewPoint  = viewPoints.Length > 0 ? viewPoints[0] : PointF.Zero;
            var    point      = new Point(viewPoint.X, viewPoint.Y);

            TouchMove?.Invoke(this, new TouchEventArgs(point));
        }
コード例 #17
0
    static void BindStair(Int2 grid)
    {
        CanvasCore core = RoomMap.FindCanvasCore(grid, ShipBuildType.BuildRoom);

        if (core != null)
        {
            TouchMove tm = PutCanvasM.GetTouchMoveByCore(core);
            tm.MoveWithRoom(core);
        }
    }
コード例 #18
0
    public static TouchMove GetTouchMoveByCore(CanvasCore core)
    {
        TouchMove tm = TouchMoveManager.GetShipBuild(core);

        if (tm != null)
        {
            return(tm);
        }
        return(null);
    }
コード例 #19
0
    /// <summary>
    /// 新增士兵
    /// </summary>
    public static void CreateSoldierFromWarehouse(int soldierId)
    {
        SoldierInfo infoSoldier = SoldierDC.GetSoldiers(soldierId);

        if (infoSoldier == null)
        {
            return;
        }

        CanvasCore Core     = new CanvasCore(ShipBuildType.Soldier, true, ShipPutInfo.GetNewShipPutId(), infoSoldier.ID, Vector2.zero);
        Int2       BornPos  = new Int2(0, 0);
        bool       isCanPut = PutCanvasM.GetBornPos(Core, ref BornPos);

        if (isCanPut == false)
        {
            NGUIUtil.ShowTipWndByKey("88800007", 1.0f);
            return;
        }

        Transform t_start = GetLifeMBornNode(true);
        Role      r       = new Role();

        r.CreateSkin(t_start, infoSoldier.m_modeltype, infoSoldier.m_name, AnimatorState.Stand, true);
        //IGameRole i = GameRoleFactory.Create(t_start, infoSoldier.m_modeltype, infoSoldier.m_name, AnimatorState.Stand);
        GameObject go = r.RoleSkinCom.tRoot.gameObject;;

        go.name = infoSoldier.m_name;

        Vector3 posMy        = t_start.position;
        Vector3 screenSpace  = Camera.main.WorldToScreenPoint(posMy);
        Vector3 pos          = new Vector3(Screen.width / 2, Screen.height / 1.5f);
        Vector3 posTempmouse = Camera.main.ScreenToWorldPoint(new Vector3(pos.x, pos.y, screenSpace.z));

        posTempmouse = U3DUtil.SetZ(posTempmouse, 0f);
        go.transform.localPosition = Vector3.zero;
        Transform tRole = go.transform.GetChild(0);

        TouchMove touch = tRole.gameObject.AddComponent <TouchMove>();

        tRole.gameObject.transform.parent.localPosition = RoomMap.GetShipBuildLocalPos(BornPos, ShipBuildType.Soldier);

        touch.InitTouchMoveCore(Core, BornPos, null);


        AddBuildingEditPlugin(touch);
        if (infoSoldier.SoldierTypeID == 100003)   //隐藏蹦蹦
        //RolePropertyM rpm = i.GetBodyComponent<RolePropertyM>();
        {
            r.RoleSkinCom.ShowLeftHand(false);
        }
        TouchMoveManager.JointShipBuild(touch);
        TouchMoveManager.SetCurTouchMove(touch);
        touch.WareHouse2Ship(BornPos);
    }
コード例 #20
0
    public static Transform GetTransformByCore(CanvasCore core)
    {
        Transform t  = null;
        TouchMove tm = TouchMoveManager.GetShipBuild(core);

        if (tm != null)
        {
            return(tm.gameObject.transform);
        }
        return(t);
    }
コード例 #21
0
        internal void Internal_OnTouchMove(ref Vector2 pointerPosition, int pointerId)
        {
            Vector2 pos = pointerPosition / _dpiScale;

            bool handled = false;

            TouchMove?.Invoke(ref pos, pointerId, ref handled);
            if (handled)
            {
                return;
            }

            GUI.OnTouchMove(pos, pointerId);
        }
コード例 #22
0
    public static List <TouchMove> GetAllTouchMoves()
    {
        List <TouchMove> tmList = new List <TouchMove>();

        for (int i = 0; i < m_Build.Count; i++)
        {
            TouchMove tm = m_Build[i];
            if (tm)
            {
                tmList.Add(tm);
            }
        }
        return(tmList);
    }
コード例 #23
0
    public static void PutDownNewBuild()
    {
        TouchMove curTouchMove = TouchMoveManager.GetCurTouchMove();

        if (null != curTouchMove)
        {
            if (curTouchMove.MyCore().IsNewCreate)
            {
                bool canput = curTouchMove.MoveBuildUp();
                if (canput == false)
                {
                    curTouchMove.DestroyShipBuild();
                }
            }
        }
    }
コード例 #24
0
    /// <summary>
    /// 新增船只建筑,兵,加入。
    /// </summary>
    public static void JointShipBuild(TouchMove touch)
    {
        if (touch == null || touch.MyCore() == null)
        {
            Debug.LogError("船只摆设数据加入有误,请调查");
            return;
        }

        if (CheckHaveBuild(touch.MyCore()) == false)
        {
            m_Build.Add(touch);
            if (!touch.MyCore().IsNewCreate)
            {
                PutCanvasM.AddNewCore(touch.MyCore(), touch.m_posMapGrid);
            }
        }
    }
コード例 #25
0
        private void FireTouchEvent(Touch i_touch, Vector2 i_startPos = default)
        {
            switch (i_touch.phase)
            {
            case TouchPhase.Began:
                TouchStart?.Invoke(i_touch, i_touch.position);
                break;

            case TouchPhase.Moved:
                TouchMove?.Invoke(i_touch, i_touch.position, i_touch.position - i_startPos);
                break;

            case TouchPhase.Ended:
                TouchEnd?.Invoke(i_touch);
                startPosByTouch.Remove(i_touch);
                allTouches.Remove(i_touch);
                break;
            }
        }
コード例 #26
0
        private void Update()
        {
            bool touchInProgress = currentTouchPhase == TouchPhase.Moved || currentTouchPhase == TouchPhase.Stationary;

            touchPosition = Input.mousePosition;
            if (touchInProgress || boundRect.Contains(touchPosition.Value))
            {
                if (Input.GetMouseButtonDown(0))
                {
                    currentTouchPhase = TouchPhase.Began;
                    TouchStart?.Invoke(currentTouchPhase, touchPosition.Value);
                }

                if (Input.GetMouseButton(0))
                {
                    if (!lastTouchPosition.HasValue)
                    {
                        lastTouchPosition = touchPosition.Value;
                    }

                    TouchDelta        = (touchPosition.Value - lastTouchPosition.Value) / scaleFactor;
                    lastTouchPosition = touchPosition.Value;

                    if (TouchDelta.magnitude > 0)
                    {
                        currentTouchPhase = TouchPhase.Moved;
                        TouchMove?.Invoke(currentTouchPhase, TouchDelta);
                    }
                    else
                    {
                        currentTouchPhase = TouchPhase.Stationary;
                        TouchStationary?.Invoke(currentTouchPhase, touchPosition.Value);
                    }
                }

                if (Input.GetMouseButtonUp(0))
                {
                    lastTouchPosition = null;
                    currentTouchPhase = TouchPhase.Ended;
                    TouchEnd?.Invoke(currentTouchPhase, touchPosition.Value);
                }
            }
        }
コード例 #27
0
    /// <summary>
    /// 放开建筑处理
    /// </summary>
    public bool MoveBuildUp()
    {
        if (m_ExchangeTouch && m_ExchangeTouch != this)
        {
            m_ExchangeTouch.m_posMapGrid    = m_orgPosMapGrid;
            m_ExchangeTouch.m_orgPosMapGrid = m_ExchangeTouch.m_posMapGrid;
            m_ExchangeTouch.UpdateChildmGridWhenUp();

            m_orgPosMapGrid = m_posMapGrid;
            UpdateChildmGridWhenUp();
            SetPosByGrid(true);
            if (!m_ExchangeTouch.MyCore().IsDeckRoom)
            {
                CreateStair(m_Core);
            }
            m_ExchangeTouch = null;
            GenerateDeck();
            return(true);
        }


        bool bCanPut = PutCanvasM.CheckCanTempPut(m_Core, m_posMapGrid);

        if (bCanPut)
        {
            m_orgPosMapGrid = m_posMapGrid;
            UpdateChildmGridWhenUp();
            SetPosByGrid(true);
        }
        else
        {
            m_posMapGrid = m_orgPosMapGrid;
            UpdateChildmGridWhenUp();
            MoveShipBuilding(m_posMapGrid);
            SetPosByGrid(true);
        }
        if (!MyCore().IsDeckRoom)
        {
            CreateStair(m_Core);
        }
        GenerateDeck();
        return(true);
    }
コード例 #28
0
    void BtnDeleteSoldier_OnClickEventHandler(UIButton sender)
    {
        List <CanvasCore> childrenCore = PutCanvasM.GetChildByCore(m_Core);

        if (childrenCore.Count == 0)
        {
            return;
        }

        foreach (var childCore in childrenCore)
        {
            TouchMove tm = PutCanvasM.GetTouchMoveByCore(childCore);
            if (childCore.m_type == ShipBuildType.Soldier)
            {
                tm.DestroyShipBuild();
            }
        }
        PutCanvasM.ShowRoomGridUI(false);
    }
コード例 #29
0
    /// <summary>
    ///  从仓库中创建建筑。
    /// </summary>
    public static void CreateBuildingFromWarehouse(BuildInfo infoBuild)
    {
        if (infoBuild == null)
        {
            return;
        }

        Vector2    size     = new Vector2(infoBuild.m_Shape.width, infoBuild.m_Shape.height);
        CanvasCore Core     = new CanvasCore(ShipBuildType.BuildRoom, true, ShipPutInfo.GetNewShipPutId(), infoBuild.ID, size);
        Int2       BornPos  = new Int2(0, 0);
        bool       isCanPut = PutCanvasM.GetBornPos(Core, ref BornPos);

        if (isCanPut == false)
        {
            NGUIUtil.ShowTipWndByKey("88800007", 1.0f);
            return;
        }

        Transform t_start   = GetLifeMBornNode(true);
        Vector3   local     = RoomMap.GetShipBuildLocalPos(BornPos, ShipBuildType.BuildRoom);
        Vector3   world     = Local2WorldPos(local);
        Building  buildlife = LifeFactory.CreateBuilding(infoBuild, 0, t_start, world, LifeEnvironment.Edit);

        if (buildlife == null)
        {
            return;
        }

        buildlife.ShowEditHp(infoBuild.m_bear);
        TouchMove touch = buildlife.m_thisT.GetChild(0).gameObject.AddComponent <TouchMove>();

        touch.InitTouchMoveCore(Core, BornPos, buildlife);

        AddBuildingEditPlugin(touch);

        GenerateShip.m_vStart = Vector3.zero;

        TouchMoveManager.JointShipBuild(touch);
        TouchMoveManager.SetCurTouchMove(touch);
        touch.WareHouse2Ship(BornPos);
    }
コード例 #30
0
    /// <summary>
    /// 获取建筑对应的gird位置.
    /// </summary>
    /// <returns>The all build grid position.</returns>
    public static List <TouchMove> GetAllBuildOutShape()
    {
        List <TouchMove> tmList = new List <TouchMove>();

        for (int i = 0; i < m_Build.Count; i++)
        {
            TouchMove tm = m_Build[i];
            if (tm && tm.MyCore() != null && tm.MyCore().m_type != ShipBuildType.BuildStair)
            {
                List <Int2> l = tm.MyCore().GetPutRoomGridPos();
                foreach (Int2 item in l)
                {
                    if (item.Layer >= RoomMap.RealMapSize.Layer || item.Unit >= RoomMap.RealMapSize.Unit)
                    {
                        tmList.Add(tm);
                    }
                }
            }
        }
        return(tmList);
    }