Ejemplo n.º 1
0
    void OnPointerUpEvent(PointerEventData p, A_TouchDrag source)
    {
        this.constructionCtrl.EventTrigger_OnPointerUpEvent(p, this.hasBeenDragged);

        this.hasBeenDragged = false;
        this.foundBuilding  = false;
    }
Ejemplo n.º 2
0
    /*public void Init (Ship ship){
     *      this.ship = ship;
     * }*/


    void OnPointerDownEvent(PointerEventData p, A_TouchDrag source)
    {
        this.hasBeenDragged = false;
        this.foundBuilding  = false;

        // Convert pointer screen point to ray.
        Ray        ray = Camera.main.ScreenPointToRay(p.position);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 1000))
        {
            if (this.RaycastHitBuilding(hit))
            {
                Building building = hit.collider.transform.GetComponent <Building>();
                this.constructionCtrl.EventTrigger_OnPointerDownEvent(p);
                this.foundBuilding = true;
            }
            else if (this.RaycastHitGround(hit))
            {
                if (this.cameraCtrl.Mode != ViewMode.DECK_VIEW)
                {
                    //this.navigationCtrl.MoveShip (hit.point);
                }
            }
        }
    }
    void TouchDrag_OnPointerUpEvent(PointerEventData p, A_TouchDrag td)
    {
        if (this.state == ConstructionState.PLACING)
        {
            // Disable touch drag on pointer up.
            TouchDrag_Button tdb = (TouchDrag_Button)td;
            tdb.eventTrigger.enabled = false;

            // Drop the building.
            this.DropBuilding(this.selectedBuilding);
        }
    }
    void TouchDrag_OnDragEvent(PointerEventData p, A_TouchDrag td)
    {
        if (this.state == ConstructionState.PLACING)
        {
            Tile targetTile = this.RaycastHitTile(p);

            // Building is being selected, and it has a target tile.
            if (targetTile != null && this.selectedBuilding != null)
            {
                // Only move if base tiles of building has changed.
                if (targetTile != this.selectedBuilding.BaseTile)
                {
                    // Drag the selected building to the tile.
                    this.MoveBuilding(this.selectedBuilding, targetTile);
                }
            }
        }
    }
Ejemplo n.º 5
0
    void OnDragEvent(PointerEventData p, A_TouchDrag source)
    {
        this.hasBeenDragged = true;

        if (this.foundBuilding)
        {
            if (this.constructionCtrl.State == ConstructionState.PLACING)
            {
                this.constructionCtrl.EventTrigger_OnDragEvent(p);
            }
            else
            {
                this.cameraCtrl.Move(p);
            }
        }
        else
        {
            this.cameraCtrl.Move(p);
        }
    }
    void TouchDrag_OnPointerDownEvent(PointerEventData p, A_TouchDrag td)
    {
        if (this.state == ConstructionState.SELECTING)
        {
            // Disable all further construction, except for current button.
            foreach (A_TouchDrag button in this.constructionButtons)
            {
                if (button != td)
                {
                    button.eventTrigger.enabled = false;
                }
            }

            // Create the building passed by the touch drag button.
            TouchDrag_Button tdb = (TouchDrag_Button)td;
            if (tdb != null)
            {
                this.CreateBuilding(tdb.prefabToCreate);
            }
        }
    }