コード例 #1
0
        void Update()
        {
            if (currentTool != null)
            {
                if (Input.GetMouseButtonDown(0) && !IsPointerOverUIObject())
                {
                    currentTool.OnMouseDown(Camera.main.ScreenToWorldPoint(Input.mousePosition));
                }

                if (Input.GetMouseButton(0) && !IsPointerOverUIObject())
                {
                    currentTool.OnMouse(Camera.main.ScreenToWorldPoint(Input.mousePosition));
                }

                if (Input.GetMouseButtonUp(0) && !IsPointerOverUIObject())
                {
                    currentTool.OnMouseUp(Camera.main.ScreenToWorldPoint(Input.mousePosition));
                }

                if ((Input.GetMouseButtonDown(0) || Input.GetMouseButton(0) || Input.GetMouseButtonUp(0)) && !IsPointerOverUIObject())
                {
                    currentTool.OnMouseAny(Camera.main.ScreenToWorldPoint(Input.mousePosition));
                }
            }

            MovingPlatformMotor2D newPlatform = motor.connectedPlatform;

            if (platform != null && newPlatform == null)
            {
                GSShip ship = platform.GetComponent <GSShip> ();

                if (ship != null)
                {
                    if (enableCameraZoomOut)
                    {
                        Camera.main.orthographicSize /= 4;
                    }

                    ship.hasCharacter = false;
                }

                platform = null;
            }
            else if (platform == null && newPlatform != null)
            {
                GSShip ship = newPlatform.GetComponent <GSShip> ();

                if (ship != null)
                {
                    if (enableCameraZoomOut)
                    {
                        Camera.main.orthographicSize *= 4;
                    }

                    ship.hasCharacter = true;
                }

                platform = newPlatform;
            }
        }
コード例 #2
0
        public override void OnShow()
        {
            GSShip ship = grid.GetComponent <GSShip> ();

            if (ship != null)
            {
                ship.maxMass += extraMass;
            }
        }
コード例 #3
0
        public void RegisterShip(GSShip ship)
        {
            if (this.ship == null)
            {
                this.ship = ship;

                Initialize();
            }
        }
コード例 #4
0
        public override void OnShow()
        {
            GSShip ship = grid.GetComponent <GSShip> ();

            if (ship != null)
            {
                ship.propulsionForce += extraPropulsion;
            }
        }
コード例 #5
0
        void Update()
        {
            GSShip ship = GSSingleton.instance.ship;

            if (ship != null)
            {
                Rigidbody2D body          = ship.GetComponent <Rigidbody2D> ();
                Vector2     position      = ship.transform.position;
                Vector2     barrierCenter = transform.position;

                float halfWidth  = width / 2;
                float halfHeight = height / 2;

                if (position.x < barrierCenter.x - halfWidth && body.velocity.x < 0)
                {
                    body.velocity = new Vector2(0, body.velocity.y);
                    // body.AddForce (FORCE * Vector2.right * Mathf.Exp(barrierCenter.x - halfWidth - position.x));
                }

                if (position.y < barrierCenter.y - halfHeight && body.velocity.y < 0)
                {
                    body.velocity = new Vector2(body.velocity.x, 0);
                    //body.AddForce (FORCE * Vector2.up * Mathf.Exp(barrierCenter.y - halfHeight - position.y));
                }

                if (position.x > barrierCenter.x + halfWidth && body.velocity.x > 0)
                {
                    body.velocity = new Vector2(0, body.velocity.y);
                    //body.AddForce (FORCE * Vector2.left * Mathf.Exp(position.x - (barrierCenter.x + halfWidth)));
                }

                if (position.y > barrierCenter.y + halfHeight && body.velocity.y > 0)
                {
                    body.velocity = new Vector2(body.velocity.x, 0);
                    //body.AddForce (FORCE * Vector2.down * Mathf.Exp(position.y - (barrierCenter.y + halfHeight)));
                }
            }
        }
コード例 #6
0
ファイル: Upgrade.cs プロジェクト: belzecue/gridlike-Unity
		public void _Inject(GSCharacter character, GSShip ship) {
			this.character = character;
			this.ship = ship;
		}