コード例 #1
0
    public override bool PickupEvent()
    {
        base.PickupEvent();
        if (objInt().item_id == 458)
        {        //The seed is a sapling
            //Turn it into a seed.
            //objInt().ChangeType(290,objInt().GetItemType());
            objInt().item_id           = 290;
            objInt().WorldDisplayIndex = 290;
            objInt().InvDisplayIndex   = 290;
            AnimationOverlay animo = this.GetComponent <AnimationOverlay>();
            if (animo != null)
            {
                animo.Stop();
            }
            objInt().UpdateAnimation();            //Update the inventory display
            UWHUD.instance.CursorIcon = objInt().GetInventoryDisplay().texture;
            UWCharacter.Instance.ResurrectPosition = Vector3.zero;
            UWCharacter.Instance.ResurrectLevel    = 0;
            objInt().SetWorldDisplay(objInt().GetInventoryDisplay());
            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 9));

            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #2
0
    public override bool PickupEvent()
    {
        base.PickupEvent();
        if (objInt.item_id == 458)
        {        //The seed is a sapling
            //Turn it into a seed.
            objInt.item_id           = 290;
            objInt.WorldDisplayIndex = 290;
            objInt.InvDisplayIndex   = 290;
            AnimationOverlay animo = this.GetComponent <AnimationOverlay>();
            if (animo != null)
            {
                animo.Stop();
            }
            objInt.UpdateAnimation();            //Update the inventory display
            playerUW.CursorIcon        = objInt.GetInventoryDisplay().texture;
            playerUW.ResurrectPosition = Vector3.zero;
            objInt.SetWorldDisplay(objInt.GetInventoryDisplay());
            ml.Add(playerUW.StringControl.GetString(1, 9));

            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #3
0
    public override bool use()
    {
        if (UWCharacter.Instance.playerInventory.ObjectInHand == "")
        {
            if ((objInt().item_id == 290) && (objInt().PickedUp == true))
            {
                //I'll test positioning later. For now just place it at the players position
                //Turn it into a sapling.
                objInt().item_id           = 458;
                objInt().WorldDisplayIndex = 458;
                objInt().InvDisplayIndex   = 458;
                AnimationOverlay animo = this.GetComponent <AnimationOverlay>();
                if (animo != null)
                {
                    animo.Stop();
                }
                objInt().UpdateAnimation();                //Update the inventory display
                objInt().SetWorldDisplay(objInt().GetInventoryDisplay());
                UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 12));


                UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault;
                UWCharacter.Instance.ResurrectPosition = UWCharacter.Instance.transform.position;
                UWCharacter.Instance.ResurrectLevel    = (short)(GameWorldController.instance.LevelNo + 1);
                //int tileX= GameWorldController.instance.Tilemap.visitTileX;
                //int tileY= GameWorldController.instance.Tilemap.visitTileY;
                objInt().gameObject.transform.parent = GameWorldController.instance.DynamicObjectMarker();

                objInt().gameObject.transform.position = GameWorldController.instance.currentTileMap().getTileVector(TileMap.visitTileX, TileMap.visitTileY);
                UWCharacter.Instance.playerInventory.RemoveItemFromEquipment(objInt().gameObject.name);
                UWCharacter.Instance.playerInventory.GetCurrentContainer().RemoveItemFromContainer(objInt().gameObject.name);
                UWCharacter.Instance.playerInventory.Refresh();
                objInt().PickedUp = false;
                GameWorldController.MoveToWorld(objInt());
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            return(ActivateByObject(UWCharacter.Instance.playerInventory.GetGameObjectInHand()));
        }
    }
コード例 #4
0
    public override bool use()
    {
        if (playerUW.playerInventory.ObjectInHand == "")
        {
            if ((objInt.item_id == 290) && (objInt.PickedUp == true))
            {
                //I'll test positioning later. For now just place it at the players position
                //Turn it into a sapling.
                objInt.item_id           = 458;
                objInt.WorldDisplayIndex = 458;
                objInt.InvDisplayIndex   = 458;
                AnimationOverlay animo = this.GetComponent <AnimationOverlay>();
                if (animo != null)
                {
                    animo.Stop();
                }
                objInt.UpdateAnimation();                //Update the inventory display
                objInt.SetWorldDisplay(objInt.GetInventoryDisplay());
                ml.Add(playerUW.StringControl.GetString(1, 12));


                playerUW.CursorIcon                = playerUW.CursorIconDefault;
                playerUW.ResurrectPosition         = playerUW.transform.position;
                objInt.gameObject.transform.parent = null;
                objInt.transform.position          = playerUW.transform.position;     //TODO:Position the tree properly

                playerUW.playerInventory.RemoveItemFromEquipment(objInt.gameObject.name);
                playerUW.playerInventory.GetCurrentContainer().RemoveItemFromContainer(objInt.gameObject.name);
                playerUW.playerInventory.Refresh();

                objInt.PickedUp = false;
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            return(ActivateByObject(playerUW.playerInventory.GetGameObjectInHand()));
        }
    }
コード例 #5
0
ファイル: Player.cs プロジェクト: kallotec/Bonsai
        public void Load(IContentLoader loader)
        {
            Props.Texture = loader.Load <Texture2D>(ContentPaths.SPRITESHEET_MARIO);

            bulletTexture = loader.Load <Texture2D>(ContentPaths.SPRITE_BULLET);

            sfxDie  = loader.Load <SoundEffect>(ContentPaths.SFX_DEATH);
            sfxFire = loader.Load <SoundEffect>(ContentPaths.SFX_FIRE);

            animStanding = new AnimationOverlay(
                name: "standing",
                animType: SpriteAnimationType.SingleFrame,
                origin: SpriteOriginType.TopLeft,
                width: Props.PhysicalRect.Width,
                height: Props.PhysicalRect.Height,
                frames: 1,
                framerateMillisec: 1,
                yOffset: 0);

            animWalking = new AnimationOverlay(
                name: "walking",
                animType: SpriteAnimationType.LoopingAnimation,
                origin: SpriteOriginType.TopLeft,
                width: Props.PhysicalRect.Width,
                height: Props.PhysicalRect.Height,
                frames: 2,
                framerateMillisec: 100,
                yOffset: 20);

            animJetting = new AnimationOverlay(
                name: "jetting",
                animType: SpriteAnimationType.SingleFrame,
                origin: SpriteOriginType.TopLeft,
                width: Props.PhysicalRect.Width,
                height: Props.PhysicalRect.Height,
                frames: 1,
                framerateMillisec: 1,
                yOffset: 40);

            // Default anim
            animCurrent = animWalking;
        }
コード例 #6
0
ファイル: Player.cs プロジェクト: kallotec/Bonsai
        public void Update(GameTime time)
        {
            var kbState = Keyboard.GetState();

            var isRunning = kbState.IsKeyDown(Keys.LeftShift);

            // Movement
            if (kbState.IsKeyDown(Keys.A))
            {
                Props.AddForceX(-acceleration * (isRunning ? runModifier : 1));
            }
            else if (kbState.IsKeyDown(Keys.D))
            {
                Props.AddForceX(acceleration * (isRunning ? runModifier : 1));
            }

            if (kbState.IsKeyDown(Keys.W))
            {
                Props.AddForceY(-acceleration * (isRunning ? runModifier : 1));
            }
            else if (kbState.IsKeyDown(Keys.S))
            {
                Props.AddForceY(acceleration * (isRunning ? runModifier : 1));
            }

            // Anims
            animCurrent.Update(time.ElapsedGameTime.Milliseconds);

            // Ensure correct anim is being used
            if (IsJetPacking)
            {
                if (animCurrent.Name != animJetting.Name)
                {
                    animCurrent = animJetting;
                }
            }
            else if (Props.IsGrounded)
            {
                if (Props.Velocity.X != 0 && animCurrent.Name != animWalking.Name)
                {
                    animCurrent = animWalking;
                }
                else if (Props.Velocity.X == 0 && animCurrent.Name != animStanding.Name)
                {
                    animCurrent = animStanding;
                }
            }
            else
            {
                if (animCurrent.Name != animStanding.Name)
                {
                    animCurrent = animStanding;
                }
            }

            /*
             * // Jump action
             * var canJump = (Props.IsGrounded && Props.Velocity.Y == 0);
             *
             * if (kbState.IsKeyDown(Keys.Space) && canJump)
             * {
             *  Props.AddForceY(-jumpPower, overrideTopSpeed: true);
             *
             *  // raise event
             *  eventBus.QueueNotification(Events.PlayerJumped);
             * }
             *
             * // Jetpack
             * if (kbState.IsKeyDown(Keys.W))
             * {
             *  IsJetPacking = true;
             *  Props.AddForceY(-jetPower, overrideTopSpeed: true);
             * }
             * else
             * {
             *  IsJetPacking = false;
             * }
             */

            // projectiles
            fireListener.Update(time);

            var mouseState = Mouse.GetState();
            var mousePos   = mouseState.Position;

            // aim
            base.Props.Rotation = Bonsai.Framework.Maths.GameMathHelper
                                  .GetDirectionInRadians(this.Position, (camera.CurrentFocus - BonsaiGame.Current.ScreenCenter) + new Vector2(mousePos.X, mousePos.Y));
        }