private IImageTransition getTransition()
        {
            switch (settings.BlendImages)
            {
            case BlendImagesMode.CustomImage:
            {
                Image image;
                try
                {
                    image = ImageHelper.FromFile(settings.CustomImagePath);
                }
                catch (Exception ex)
                {
                    image = ImageHelper.FromFile(settings.DefaultImageName);
                    Logger.Debug(string.Format("Cannot open custom image {0} : {1}",
                                               settings.CustomImagePath, ex.Message));
                }
                CustomImageTransition transition = _imageTransition as CustomImageTransition;
                if (transition == null)
                {
                    _imageTransition = new CustomImageTransition(image);
                }
            }
            break;

            case BlendImagesMode.InAndOut:
            {
                SmoothTransition smooth = _imageTransition as SmoothTransition;
                if (smooth == null)
                {
                    _imageTransition = new SmoothTransition();
                }
            }
            break;

            case BlendImagesMode.OutThenIn:
            {
                OutThenInTransition outThenIn = _imageTransition as OutThenInTransition;
                if (outThenIn == null)
                {
                    _imageTransition = new OutThenInTransition();
                }
            }
            break;

            case BlendImagesMode.None:
            {
                SimpleTransition simple = _imageTransition as SimpleTransition;
                if (simple == null)
                {
                    _imageTransition = new SimpleTransition();
                }
            }
            break;
            }
            return(_imageTransition);
        }
示例#2
0
    protected override void InvokeAction()
    {
        SmoothTransition smoothTransition = gameObject.AddComponent <SmoothTransition>();

        Vector3 startPos = transform.localPosition;
        Vector3 endPos   = transform.localPosition + slideVector;

        smoothTransition.SetupParameters(startPos, endPos, slideSpeed);

        slideVector *= -1;
    }
 public DiagnosticsScene(GraphicsDevice graphicsDevice, ContentManager content)
 {
     fpsMonitor          = new FpsMonitor();
     this.graphicsDevice = graphicsDevice;
     font             = content.Load <SpriteFont>(@"Fonts/diagnosticsFont");
     this.background  = content.Load <Texture2D>(@"Textures/whiteRectangle");
     texts            = new Dictionary <Vector2, string>();
     LargestWidth     = 0;
     LargestHeight    = 0;
     bgTransparency   = new SmoothTransition(0.5f, 0.002f, 0.0f, 0.5f);
     fontTransparency = new SmoothTransition(1.0f, 0.004f, 0.0f, 1.0f);
     isActive         = true;
 }
示例#4
0
    void Awake()
    {
        transform.position = new Vector3(x, y, 0);

        //no animation to start with
        moveAnimation = null;

        ammo = new int[AmmoPickup.NumberOfAmmoTypes];
        Util.Fill(ammo, 0);

        weapons       = new WeaponController[NumberOfWeapons];
        currentWeapon = 1;
    }
示例#5
0
    /**
     * gets called by lean event, when releasing stone from drag and puts it back to parent position or first sets the new parent
     */
    public void OnDeselectOnUp()
    {
        if (_onDeselectParent != null && _onDeselectParent != Parent.GetComponent <CanHoldHookableObject>() &&
            HookableObjectController.IsStoneInColliderOfOnDeselectParent(this, _onDeselectParent)
            )
        {
            HookableObjectController.RemoveStoneFromCanHoldHookableObject(this, Parent);
            HookableObjectController.OnDeselectOnCanHoldHookableObject(this, _onDeselectParent);
        }

        //transform.position =
        SmoothTransition.AddTransition(gameObject,
                                       HookableObjectController.GetParentPositionOfChildStone(Parent.GetComponent <CanHoldHookableObject>(), this),
                                       Game.Instance.transitionTimes.snapBack);
    }
示例#6
0
    protected override void InvokeAction()
    {
        SmoothTransition smoothTransition = gameObject.AddComponent <SmoothTransition>();
        Vector3          startPos         = gameObject.transform.localPosition;

        if (closed)
        {
            smoothTransition.SetupParameters(startPos, gameObject.transform.localPosition + slideVector, openingSlideSpeed);
        }
        else
        {
            smoothTransition.SetupParameters(startPos, gameObject.transform.localPosition - slideVector, closingSlideSpeed);
        }

        closed = !closed;
    }
示例#7
0
    //returns true on success, starts animation
    private bool TryMove()
    {
        Map map = GameManager.instance.GetMap();

        int dx = 0;
        int dy = 0;

        if (Input.GetKey("w"))
        {
            dy = 1;
        }
        if (Input.GetKey("a"))
        {
            dx = -1;
        }
        if (Input.GetKey("s"))
        {
            dy = -1;
        }
        if (Input.GetKey("d"))
        {
            dx = 1;
        }
        if (Input.GetKeyDown("p"))
        {
            GameObject a = Instantiate(GameManager.instance.GetPrefabs().enginePrefab);
            a.GetComponent <EngineObjectController>().Interact(new Coords2(0, 0), this);
        }

        //////changes
        // if(Input.GetKey("y")) SceneManager.LoadScene("Minigame1", LoadSceneMode.Single);
        // if(Input.GetKey("t")) SceneManager.LoadScene("MainScene", LoadSceneMode.Single);
        ///////////


        if ((dx != 0 || dy != 0) && !map.HasCollider(new Coords2(x + dx, y + dy)))
        {
            moveAnimation = new SmoothTransition(new Vector3(x, y, 0.0f), new Vector3(x + dx, y + dy, 0.0f), 0.25f);
            x            += dx;
            y            += dy;


            return(true);
        }

        return(false);
    }
示例#8
0
 public override void OnActivate()
 {
     if (_player != null)
     {
         var transition = SmoothTransition.AddTransition(gameObject, _player.harpoon.transform.position,
                                                         Game.Instance.transitionTimes.itemTransition);
         transition.onExit.AddListener(() =>
         {
             _player.IgniteHarpoon();
             DestroyHookableObject();
         });
     }
     else
     {
         DestroyHookableObject();
     }
 }
示例#9
0
    protected override void InvokeAction()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        // If there is already SmoothTransition on player - remove it.
        // It happenes when player is already moving from one footprint to another
        if (player.GetComponent <SmoothTransition>())
        {
            Destroy(player.GetComponent <SmoothTransition>());
        }

        SmoothTransition smoothTransition = player.AddComponent <SmoothTransition>();

        Vector3 startPos = player.transform.position;
        Vector3 endPos   = new Vector3(transform.position.x, player.transform.position.y, transform.position.z);

        smoothTransition.SetupParameters(startPos, endPos, walkSpeed);
    }
示例#10
0
    // Update is called once per frame
    // player logic
    void Update()
    {
        GameManager gm = GameManager.instance;

        if (!gm.IsPlayerTurn())
        {
            return;
        }

        if (moveAnimation == null)
        {
            if (TryMove())
            {
                EndTurn();
            }
            else if (TryInteract())
            {
                EndTurn();
            }
            else if (TryShoot())
            {
                EndTurn();
            }
        }
        else
        {
            moveAnimation.Update();

            transform.position = moveAnimation.GetInterpolatedPosition();

            if (moveAnimation.IsFinished())
            {
                moveAnimation = null;
                //end turn only after animation has finished
                EndTurn();
            }
        }

        if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            currentWeapon = 0;
        }
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            currentWeapon = 1;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            currentWeapon = 2;
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            currentWeapon = 3;
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            currentWeapon = 4;
        }
        if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            currentWeapon = 5;
        }
        if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            currentWeapon = 6;
        }
        if (Input.GetKeyDown(KeyCode.Alpha7))
        {
            currentWeapon = 7;
        }
        if (Input.GetKeyDown(KeyCode.Alpha8))
        {
            currentWeapon = 8;
        }
        if (Input.GetKeyDown(KeyCode.Alpha9))
        {
            currentWeapon = 9;
        }
    }
示例#11
0
 /**
  * SetPosition sets the position of the hookable object
  *
  * @param position The position to set the hookable object to
  */
 public void SetPosition(Vector3 position)
 {
     //gameObject.transform.position = position;
     SmoothTransition.AddTransition(gameObject, position, Game.Instance.transitionTimes.moveToInventory);
 }
        protected override UIElement InitializeUI(Loader loader, DrawingContext context, int screenWidth, int screenHeight)
        {
            string textFormat      = "testSceneTextFormat";
            string whiteBrush      = "testSceneWhiteBrush";
            string text1background = "testSceneText1background";
            string text2background = "testSceneText2background";
            string text3background = "testSceneText3background";
            string panelBitmap     = "testScenePanelBitmap";

            //string buttonlBitmap = "panelBitmap";

            //context.NewBitmap(buttonlBitmap, loader.LoadBitmapFromFile(@"Textures\button.png"));
            context.NewNinePartsBitmap(panelBitmap, loader.LoadBitmapFromFile(@"Textures\button.png"), 15, 121, 15, 46);
            context.NewSolidBrush(whiteBrush, new RawColor4(1f, 1f, 1f, 1f));
            context.NewSolidBrush(text1background, new RawColor4(0.6f, 0.1f, 0.2f, 1f));
            context.NewSolidBrush(text2background, new RawColor4(0.2f, 0.4f, 0.8f, 1f));
            context.NewSolidBrush(text3background, new RawColor4(0.5f, 0.4f, 0.3f, 1f));
            context.NewTextFormat(textFormat);

            _ui = new UIMultiElementsContainer(Vector2.Zero, new Vector2(screenWidth, screenHeight));

            _panel = new UISequentialContainer(Vector2.Zero, new Vector2(200, 200))
            {
                MainAxis  = UISequentialContainer.Alignment.Center,
                CrossAxis = UISequentialContainer.Alignment.Center,
                //Background = new TextureBackground(panelBitmap)
                Background = new NinePartsTextureBackground(panelBitmap)
            };
            _ui.Add(_panel);

            _text1 = new UIText("X", new Vector2(120, 16), textFormat, whiteBrush)
            {
                Background = new ColorBackground(text1background)
            };
            _text2 = new UIText("Y", new Vector2(120, 16), textFormat, whiteBrush)
            {
                Background = new ColorBackground(text2background)
            };
            _text3 = new UIText("Z", new Vector2(120, 16), textFormat, whiteBrush)
            {
                Background = new ColorBackground(text3background)
            };
            UIElement text4 = new UIText("Click Me!", new Vector2(120, 16), textFormat, whiteBrush);
            UIElement m     = new UIMarginContainer(_text1, 2f);

            UIButton button = new UIButton(text4)
            {
                ReleasedBackground = new ColorBackground(text1background), PressedBackground = new ColorBackground(text2background)
            };

            button.OnClicked += () =>
            {
                MainMenuScene menu = new MainMenuScene();
                Game.ChangeScene(menu);
            };

            _panel.Add(m);
            _panel.Add(_text2);
            _panel.Add(_text3);
            _panel.Add(button);

            _text1.OnClicked += () =>
            {
                Transition transition = new SmoothTransition(_go.Rotation.X, _go.Rotation.X + MathUtil.TwoPi, 2);
                transition.Process += value => _go.SetRotationX(value);
                transition.Process += value => _go.SetRotationY(value);
                transition.Process += value => _go.SetRotationZ(value);
            };
            _text2.OnClicked += () =>
            {
                Transition transition = new SmoothTransition(_go.Rotation.Y, _go.Rotation.Y + MathUtil.TwoPi, 2);
                transition.Process += value => _go.SetRotationY(value);

                //_voice.Stop();
                //_voice.Play();

                _voice2.Stop();
                _voice2.Play();
            };
            _text3.OnClicked += () =>
            {
                Transition transition = new SmoothTransition(_go.Rotation.Z, _go.Rotation.Z + MathUtil.TwoPi, 2);
                transition.Process += value => _go.SetRotationZ(value);

                _voice.Play();
                //_voice2.Play();
            };
            _text1.IsClickable = true;
            _text2.IsClickable = true;
            _text3.IsClickable = true;

            return(_ui);
        }