Esempio n. 1
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public override void moveTo(float x, float y)
        {
            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, this.x, this.y))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, this.x, this.y);
            }

            float oldX = this.x, oldy = this.y;

            this.X = x;
            this.Y = y;

            if (OnMoved != null)
            {
                OnMoved.Invoke(this, oldX, oldy);
            }
        }
Esempio n. 2
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public override void moveTo(float x, float y)
        {
            float oldX = systemCenter.X, oldY = systemCenter.Y;

            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, oldX, oldY))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, oldX, oldY);
            }

            GlVectorR2 moveVector = new GlVectorR2(x - this.systemCenter.X, y - this.systemCenter.Y);

            this.systemCenter = new GlPointR2(x, y);

            foreach (GlFigure F in this.figuresAmount)
            {
                GlPointR2 newCenter = moveVector.fromPointToPoint(F.Center);
                F.moveTo(newCenter.X, newCenter.Y);
            }

            if (OnMoved != null)
            {
                OnMoving.Invoke(this, oldX, oldY);
            }
        }
Esempio n. 3
0
 void Movement()
 {
     if (Input.GetMouseButtonDown(0))
     {
         RaycastHit hit;
         Vector3    mousePos = Input.mousePosition;
         if (Physics.Raycast(Camera.main.ScreenPointToRay(mousePos), out hit, Mathf.Infinity, ~IgnoreMe))
         {
             hasAMoveCommand     = true;
             playerNavMeshTarget = hit.point;
             playerNavMeshAgent.SetDestination(playerNavMeshTarget);
             OnMoveStart?.Invoke(playerNavMeshAgent.destination);
             if (hit.transform.gameObject.GetComponent <WorldInteractive>() != null)
             {
                 interactedObject = hit.transform.gameObject.GetComponent <WorldInteractive>();
             }
         }
     }
     if ((hasAMoveCommand == true) && (playerNavMeshAgent.velocity == Vector3.zero) && (!playerNavMeshAgent.pathPending))
     {
         if (playerNavMeshAgent.remainingDistance < playerNavMeshAgent.stoppingDistance)
         {
             if ((interactedObject != null))
             {
                 //Debug.Log((playerNavMeshAgent.transform.position - interactedObject.transform.position).sqrMagnitude);
                 interactedObject.OnInteract();
                 interactedObject = null;
             }
             hasAMoveCommand = false;
             OnMoveStopped?.Invoke();
         }
     }
 }
Esempio n. 4
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public override void moveTo(float x, float y)
        {
            float oldX = this.Center.X;
            float oldY = this.Center.Y;

            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, oldX, oldY))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, oldX, oldY);
            }

            this.systemCenter = new GlPointR2(x, y);
            updatePointsPosition();

            if (OnMoved != null)
            {
                OnMoved.Invoke(this, oldX, oldY);
            }
        }
Esempio n. 5
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public override void moveTo(float x, float y)
        {
            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, this.polyCenter.X, this.polyCenter.Y))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, this.polyCenter.X, this.polyCenter.Y);
            }

            GlVectorR2 delta = new GlVectorR2(x - polyCenter.X, y - polyCenter.Y);

            for (int i = 0; i < vertexes.Length; i++)
            {
                vertexes[i] = delta.fromPointToPoint(vertexes[i]);
            }

            GlPointR2 OP = new GlPointR2(this.polyCenter);

            this.polyCenter = new GlPointR2(x, y);

            if (OnMoved != null)
            {
                OnMoved.Invoke(this, OP.X, OP.Y);
            }
        }
Esempio n. 6
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public void moveTo(GlPointR2 newBelongsPoint)
        {
            if (newBelongsPoint == null || newBelongsPoint.isNullPoint())
            {
                return;
            }

            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, this.pointOfLine.X, this.pointOfLine.Y))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, this.pointOfLine.X, this.pointOfLine.Y);
            }

            GlPointR2 OP = new GlPointR2(this.PointOfLine);

            this.pointOfLine = newBelongsPoint;

            if (OnMoved != null)
            {
                OnMoved.Invoke(this, OP.X, OP.Y);
            }
        }
Esempio n. 7
0
 private void OnMouseOver()
 {
     if (Input.GetMouseButtonDown(1))
     {
         _isMoving        = true;
         _initialPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         OnMoveStart?.Invoke(this, EventArgs.Empty);
     }
 }
Esempio n. 8
0
 public void NotifyMoveStart(Event eventArgs)
 {
     OnMoveStart?.Invoke(this, eventArgs);
 }
Esempio n. 9
0
 public void NotifyMoveStart(Event e) => OnMoveStart?.Invoke(this, e);
Esempio n. 10
0
 public virtual void Interact(Cell cell)
 {
     OnMoveStart?.Invoke(this);
 }