예제 #1
0
    /// <summary>
    /// Creates a gridded mark on the playing field that indicates where the tetromino will fall before it is dropped
    /// </summary>
    public void MarkSnapPosition(Carriable tetro)
    {
        CleanMarkers();
        tetromino = tetro;

        if (tetromino.transform.position.y >= vertices[vertices.Length - 4].y + vertexOffset)
        {
            Transform   parent             = tetromino.GetComponent <Transform>();
            Transform[] childrenWithParent = tetromino.GetComponentsInChildren <Transform>();
            int[]       tempMarkCells      = new int[childrenWithParent.Length - 1];
            int         marksCounter       = 0;

            foreach (Transform child in childrenWithParent)
            {
                if (child != parent)
                {
                    var p = child.gameObject.transform.position;
                    for (int i = 0; i <= (vertices.Length - 4) / gridLevels; i += 4)
                    {
                        if (p.x >= vertices[i].x && p.x <= vertices[i + 3].x && p.z >= vertices[i].z &&
                            p.z <= vertices[i + 3].z)
                        {
                            tempMarkCells[marksCounter] = i + (4 * cellsPerLevel * (gridLevels - 1));
                            marksCounter++;
                        }
                    }
                }
            }

            if (marksCounter == childrenWithParent.Length - 1)
            {
                MarkCell(tempMarkCells);
            }
        }
    }
예제 #2
0
        /// <summary>
        /// Draw Item
        /// </summary>
        /// <param Name="index">item index</param>
        public void DrawItem(int index)
        {
            int       number = 0;
            Carriable item   = data[index];

            if (item == null)
            {
                return;
            }
            int posx = 4 + index % 2 * (288 * GeexEdit.GameWindowWidth / 640 + 32);
            int posy = index / 2 * 32;

            switch (item.GetType().Name.ToString())
            {
            case ("Weapon"):
                number = InGame.Party.WeaponNumber(item.Id);
                break;

            case ("Armor"):
                number = InGame.Party.ArmorNumber(item.Id);
                break;
            }
            this.Contents.Blit(posx + index % 2 * 8, posy + 4, Cache.IconBitmap, Cache.IconSourceRect(item.IconName));
            this.Contents.Font.Color = NormalColor;
            this.Contents.DrawText(posx + 28 * GeexEdit.GameWindowWidth / 640, posy, 212, 32, item.Name, 0);
            this.Contents.DrawText(posx + 240 * GeexEdit.GameWindowWidth / 640, posy, 16, 32, ":", 1);
            this.Contents.DrawText(posx + 256 * GeexEdit.GameWindowWidth / 640, posy, 24, 32, number.ToString(), 2);
        }
예제 #3
0
        /// <summary>
        /// Frame Update (when sell window is active)
        /// </summary>
        void UpdateSell()
        {
            // If B button was pressed
            if (Input.RMTrigger.B)
            {
                // Play cancel SE
                InGame.System.SoundPlay(Data.System.CancelSoundEffect);
                // Change windows to initial mode
                commandWindow.IsActive = true;
                dummyWindow.IsVisible  = true;
                sellWindow.IsActive    = false;
                sellWindow.IsVisible   = false;
                statusWindow.Item      = null;
                // Erase help text
                helpWindow.SetText("");
                return;
            }
            // If C button was pressed
            if (Input.RMTrigger.C)
            {
                // Get item
                item = sellWindow.Item;
                // Set status window item
                statusWindow.Item = item;
                // If item is invalid, or item price is 0 (unable to sell)
                if (item == null || item.Price == 0)
                {
                    // Play buzzer SE
                    InGame.System.SoundPlay(Data.System.BuzzerSoundEffect);
                    return;
                }
                // Play decision SE
                InGame.System.SoundPlay(Data.System.DecisionSoundEffect);
                // Get items in possession count
                int _number = 0;
                switch (item.GetType().Name)
                {
                case "Item":
                    _number = InGame.Party.ItemNumber(item.Id);
                    break;

                case "Weapon":
                    _number = InGame.Party.WeaponNumber(item.Id);
                    break;

                case "Armor":
                    _number = InGame.Party.ArmorNumber(item.Id);
                    break;
                }
                // Maximum quanitity to sell = number of items in possession
                int _max = _number;
                // Change windows to quantity input mode
                sellWindow.IsActive  = false;
                sellWindow.IsVisible = false;
                numberWindow.Set(item, _max, item.Price / 2);
                numberWindow.IsActive  = true;
                numberWindow.IsVisible = true;
                statusWindow.IsVisible = true;
            }
        }
예제 #4
0
    public void ReleaseObject()
    {
        Carriable     carriable   = CarriedObject.GetComponent <Carriable> ();
        float         fator       = (carriable.isHeavy()?1.5f:1);
        SliderJoint2D sliderJoint = GetComponent <SliderJoint2D>();

        sliderJoint.connectedBody = null;
        sliderJoint.enabled       = false;
        if (Crouched)
        {
            CarriedObject.GetComponent <Rigidbody2D> ().velocity = new Vector2(0, 0);
            CarriedObject.transform.rotation = new Quaternion(0, 0, 0, CarriedObject.transform.localRotation.w);
            CarriedObject.transform.position = new Vector2(transform.position.x + facingDirection * transform.localScale.x / 2 + facingDirection * CarriedObject.transform.localScale.x / 2, transform.position.y - transform.localScale.y + CarriedObject.transform.localScale.y + offsetCarryObjHero * fator);
        }
        else
        {
            CarriedObject.GetComponent <Rigidbody2D> ().velocity = new Vector2(rigidBody2D.velocity.x, 0);
            CarriedObject.GetComponent <Rigidbody2D> ().AddForce(new Vector2(fator * facingDirection * 5f, fator * 1f), ForceMode2D.Impulse);
        }
        Carrying                 = false;
        CarriedObject            = null;
        carriable.isBeingCarried = false;
        animator.SetBool("carry", false);

        isHoldingBox = false;
    }
예제 #5
0
    // Inventory Functions
    void ChangeSlot(int newIndex)
    {
        if (_CurrentItem != null) // Store the current item in the inventory
        {
            var gun = _CurrentItem.GetComponent <Gun>();
            if (gun != null)
            {
                gun.Aim(false);
            }
            _CurrentItem.transform.localPosition = _CurrentItem._UnequippedPosition;
            _CurrentItem.gameObject.SetActive(false);
        }

        _CurrentSlotIndex = newIndex;

        if (_CurrentSlotIndex > _InventorySize - 1)
        {
            _CurrentSlotIndex = 0;
        }
        else if (_CurrentSlotIndex < 0)
        {
            _CurrentSlotIndex = _InventorySize - 1;
        }

        // Retrieve the stored item and equip it
        _CurrentItem = _Inventory[_CurrentSlotIndex];
        if (_CurrentItem != null)
        {
            _CurrentItem.gameObject.SetActive(true);
        }
    }
예제 #6
0
    private void CarryObject()
    {
        Carriable carriable    = heroInterac.carriableObject.GetComponent <Carriable> ();
        bool      objIsInFront = heroInterac.carriableObject.transform.position.x * facingDirection > transform.position.x * facingDirection;
        float     fator        = carriable.isHeavy()?1.5f:1f;

        if (carriable != null && !carriable.isBeingCarried && objIsInFront && (!carriable.isHeavy() || this.IsStrong()))
        {
            Vector2    ls   = heroInterac.transform.localScale;
            Vector2    a    = new Vector2(transform.position.x - ls.x / 2, transform.position.y + transform.localScale.y + ls.y + offsetCarryObjHero * fator - ls.y / 2);
            Vector2    b    = new Vector2(transform.position.x + ls.x / 2, transform.position.y + transform.localScale.y + ls.y + offsetCarryObjHero * fator + ls.y / 2);
            Collider2D coll = Physics2D.OverlapArea(a, b);
            if (coll == null)
            {
                Carrying      = true;
                CarriedObject = heroInterac.carriableObject;
                SliderJoint2D sliderJoint = GetComponent <SliderJoint2D> ();
                CarriedObject.transform.rotation = new Quaternion(0, 0, 0, CarriedObject.transform.localRotation.w);
                CarriedObject.transform.position = new Vector2(transform.position.x, transform.position.y + transform.localScale.y + CarriedObject.transform.localScale.y + offsetCarryObjHero * fator);
                sliderJoint.connectedBody        = CarriedObject.GetComponent <Rigidbody2D> ();
                sliderJoint.enabled      = true;
                carriable.isBeingCarried = true;
                StopPush();
                animator.SetBool("carry", true);
            }
        }
    }
예제 #7
0
    protected BothHandsCarriable bothHandsObject; // The object held by both hands (A long weapon for example)

    protected void Start()
    {
        inventory       = new List <Carriable>();
        leftHandObject  = null;
        rightHandObject = null;
        bothHandsObject = null;
    }
예제 #8
0
 /// <summary>
 /// Frame Update (when item window is active)
 /// </summary>
 void UpdateItem()
 {
     // If B button was pressed
     if (Input.RMTrigger.B)
     {
         // Play cancel SE
         InGame.System.SoundPlay(Data.System.CancelSoundEffect);
         // Activate right window
         rightWindow.IsActive = true;
         itemWindow.IsActive  = false;
         itemWindow.Index     = -1;
         return;
     }
     // If C button was pressed
     if (Input.RMTrigger.C)
     {
         // Play equip SE
         InGame.System.SoundPlay(Data.System.EquipSoundEffect);
         // Get currently selected data on the item window
         Carriable _item = itemWindow.Item;
         // Change equipment
         actor.Equip(rightWindow.Index, _item == null ? 0 : _item.Id);
         // Activate right window
         rightWindow.IsActive = true;
         itemWindow.IsActive  = false;
         itemWindow.Index     = -1;
         // Remake right window and item window contents
         rightWindow.Refresh();
         itemWindow.Refresh();
         return;
     }
 }
 /// <summary>
 /// Set Items, Max Quantity, and Price
 /// </summary>
 /// <param Name="item">item</param>
 /// <param Name="max">max quantity</param>
 /// <param Name="price">price</param>
 public void Set(Carriable item, int max, int price)
 {
     this.item   = item;
     this.max    = max;
     this.price  = price;
     this.Number = 1;
     Refresh();
 }
예제 #10
0
 public override void Interact()
 {
     if (player.carrying && player.carrying.tag.Equals("presenceMaskerPart"))
     {
         neededMaskerParts.Remove(player.carrying.name);
         player.carrying.UseCarriable();
         if (neededMaskerParts.Count == 0)
         {
             gm.ShowTextChain(new string[] {
                 "Aaand done! This should fake my presence at the prisoner level.",
                 "Hopefully the lockdown alarms are down once I go out there again. Only one way to find out..."
             });
             substituteCompelete = true;
             gm.UpdateLockdown();
         }
         else
         {
             string t = "I still need ";
             for (int i = 0; i < neededMaskerParts.Count; i++)
             {
                 t += concreteToVague[neededMaskerParts[i]] + " and ";
             }
             t = t.Substring(0, t.Length - 5) + ".";
             gm.ShowText(t);
         }
     }
     else if (!player.carrying && !player.dragging && !tookKeycard)
     {
         GameObject go = Instantiate(keycardPrefab, Vector3.zero, Quaternion.identity);
         Carriable  c  = go.GetComponent <Carriable>();
         c.ForceSetup(player, gm);
         c.Interact(); // picks it up
         gm.ShowTextChain(new string[] {
             "The guards are dead!?",
             "Right, no time, no time. I'll take their keycard and worry about what's happening later."
         });
         tookKeycard = true;
     }
     else if (player.GetGameData("sawl2keypad") != null)
     {
         string t = "I still need ";
         for (int i = 0; i < neededMaskerParts.Count; i++)
         {
             t += concreteToVague[neededMaskerParts[i]] + " and ";
         }
         t = t.Substring(0, t.Length - 5) + ".";
         gm.ShowText(t);
     }
     else if (tookKeycard)
     {
         gm.ShowTextChain(new string[] {
             "What a gruesome sight...",
             "...",
             "Ahem, right. Escape first, sadness second.",
             "Besides that keycard, the guard office doesn't have anything useful."
         });
     }
 }
예제 #11
0
 /// <summary>
 /// Constructor
 /// </summary>
 public WindowShopNumber()
     : base(0, 128, GeexEdit.GameWindowWidth - 272, GeexEdit.GameWindowHeight - 128)
 {
     this.Contents = new Bitmap(Width - 32, Height - 32);
     item          = null;
     max           = 1;
     price         = 0;
     Number        = 1;
 }
예제 #12
0
    public override void OnSLStatePostEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        m_MonoBehaviour.SetMoveVector(new Vector2(0, 0));

        heldObject = m_MonoBehaviour.HeldObject;
        heldObject.Collider2D.enabled = true;
        heldObject.gameObject.layer   = Constants.Layers.ThrownObjects;
        heldObject.Throw(m_MonoBehaviour.direction, m_MonoBehaviour.throwSpeed);
        m_MonoBehaviour.HeldObject = null;
    }
예제 #13
0
    private void DropRightHandObject()
    {
        Carriable carriable = rightHandObject;

        carriable.carried          = false;
        carriable.transform.parent = null;
        carriable.GetComponent <Rigidbody>().isKinematic = false;
        carriable.GetComponent <Rigidbody>().velocity    = this.GetComponent <CharacterController>().velocity;
        rightHandObject = null;
    }
예제 #14
0
    public override void OnSLStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        m_MonoBehaviour.HeldObject = target;

        // Set the sorting order so the object shows on top of Link.
        target.SpriteRenderer.sortingOrder = 2;

        target = null;
        m_MonoBehaviour.CarriableTarget = null;
    }
예제 #15
0
 /// <summary>
 /// Draw Item localName
 /// </summary>
 /// <param Name="item">item</param>
 /// <param Name="x">draw spot x-coordinate</param>
 /// <param Name="y">draw spot y-coordinate</param>
 public void DrawItemName(Carriable item, int x, int y)
 {
     if (item == null)
     {
         return;
     }
     this.Contents.Blit(x, y + 4, Cache.IconBitmap, Cache.IconSourceRect(item.IconName));
     this.Contents.Font.Color = NormalColor;
     this.Contents.DrawText(x + 28, y, 212, 32, item.Name);
 }
예제 #16
0
    private bool RaycastCarriable(out RaycastHit hit, out Carriable carriable)
    {
        if (Physics.Raycast(transform.position, transform.forward, out hit, maxDistance) &&
            FindInHierarchy(hit.collider, out carriable))
        {
            return(true);
        }

        carriable = null;
        return(false);
    }
예제 #17
0
 void DeliverFood(bool stolen)
 {
     if (!stolen)
     {
         Destroy(carriedObject.gameObject);
     }
     carriedObject        = null;
     state                = AntState.SearchForFood;
     spriteRenderer.color = searchingColor;
     ReverseDirection();
     checkedPositions = new List <Vector3>();
 }
예제 #18
0
    public Carriable Take()
    {
        var returnObject = PlacedObject;

        ResetRotationOfPlacedObject();
        PlacedObject = null;
        if (returnObject != null)
        {
            var record = returnObject.CarriableName;
            MusicManager.Instance.songySong.SetClipVolume(0, record);
        }
        return(returnObject);
    }
예제 #19
0
 private void PressPickupButton()
 {
     if (itemHeld)
     {
         DropHeldItem();
     }
     else if (RaycastCarriable(out var hit, out var carriable))
     {
         carriable.PickUp(this, hit);
         heldItem = carriable;
         itemHeld = true;
     }
 }
예제 #20
0
 /*  Pick un an object
  *  toInventory : Is the object put in the inventory ?
  *  hand : the hand in which the Carriable will go, if the object isn't going into the Inventory or isn't a Both Hand Held Carriable
  */
 protected void PickUpObject(Carriable carriable, bool toInventory = false, MyEnum.Hand hand = MyEnum.Hand.None)
 {
     if (toInventory)
     {
         if (inventory.Count < 8 && carriable.hideable)
         {
             carriable.carried = true;
             inventory.Add(carriable);
         }
     }
     else
     {
         if (carriable is BothHandsCarriable)
         {
             BothHandsCarriable cast = (BothHandsCarriable)carriable;
             if (!bothHandsObject && !rightHandObject && !leftHandObject)
             {
                 carriable.carried          = true;
                 carriable.transform.parent = this.gameObject.transform;
                 carriable.GetComponent <Rigidbody>().isKinematic = true;
                 carriable.transform.localPosition = new Vector3(0f, 0f, 1f);
                 bothHandsObject = cast;
             }
         }
         else
         {
             if (hand == MyEnum.Hand.Left)
             {
                 if (!leftHandObject && !bothHandsObject)
                 {
                     carriable.carried          = true;
                     carriable.transform.parent = this.gameObject.transform;
                     carriable.GetComponent <Rigidbody>().isKinematic = true;
                     carriable.transform.localPosition = new Vector3(-1f, 0f, 0f);
                     leftHandObject = carriable;
                 }
             }
             else if (hand == MyEnum.Hand.Right)
             {
                 if (!rightHandObject && !bothHandsObject)
                 {
                     carriable.carried          = true;
                     carriable.transform.parent = this.gameObject.transform;
                     carriable.GetComponent <Rigidbody>().isKinematic = true;
                     carriable.transform.localPosition = new Vector3(1f, 0f, 0f);
                     rightHandObject = carriable;
                 }
             }
         }
     }
 }
예제 #21
0
    void OnTriggerExit2D(Collider2D other)
    {
        Hero hero;

        if ((hero = other.GetComponentInParent <Hero>()) != null)
        {
            hero.transform.SetParent(null);
        }
        GetComponent <Rigidbody2D>().isKinematic = true;
        if (interactiveObject)
        {
            interactiveObject = null;
        }
    }
예제 #22
0
    void FillCarryFrom(int slot)
    {
        GameObject storedObject = storedObjects[slot];

        carrier.ContinueCarry(storedObject);
        storedObjects[slot] = null;
        Debug.Log("fill carry " + slot);

        Carriable carriable = storedObject.GetComponent <Carriable>();

        statsScript.RemoveStatsChange(carriable.statsChangeOnStored);

        InventoryUpdateEvent();
    }
예제 #23
0
        /// <summary>
        /// Determine if Carriable Equippable
        /// </summary>
        /// <param Name="item">Carriable item</param>
        /// <returns>True if carriable parameter is equippable</returns>
        public bool IsEquippable(Carriable item)
        {
            switch (item.GetType().Name.ToString())
            {
            case "Weapon":
                return(IsEquippable((Weapon)item));

            case "Armor":
                return(IsEquippable((Armor)item));

            default:
                return(false);
            }
        }
예제 #24
0
 private void DropHeldItem()
 {
     if (!grid.lookTetrominoAdding)
     {
         heldItem.DropObject();
         grid.TryToSnapPosition(ref heldItem);
         heldItem = null;
         itemHeld = false;
     }
     else
     {
         grid.SetStatusMessage("Wait until last tetromino is down... ");
     }
 }
예제 #25
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (GetComponent <BoxCollider2D>().IsTouching(other))
     {
         GetComponent <Rigidbody2D>().isKinematic = false;
         if (!distJoint.connectedBody &&
             other.gameObject.GetComponent <CarriableLight>() != null)
         {
             if (!other.gameObject.GetComponent <Carriable>().isBeingCarried)
             {
                 interactiveObject = other.GetComponent <CarriableLight>();
                 interObjRigidbody = other.attachedRigidbody;
             }
         }
     }
 }
예제 #26
0
    public override void OnSLStatePostEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        m_MonoBehaviour.SetMoveVector(new Vector2(0, 0));

        target = m_MonoBehaviour.CarriableTarget;
        target.Collider2D.enabled = false;

        // Set sorting order first if Link's facing down.
        if (m_MonoBehaviour.direction == 270)
        {
            target.SpriteRenderer.sortingOrder = 2;
        }

        startPosition = target.transform.position;
        carryPosition = (Vector2)m_MonoBehaviour.CarryPosition.transform.position - target.carryOffset;
    }
예제 #27
0
        protected Carriable BuildCarriable()
        {
            GameObject g = new GameObject();

            Carriable c = g.AddComponent <Carriable>();

            Rigidbody2D      r = g.AddComponent <Rigidbody2D>();
            BoxCollider2D    b = g.AddComponent <BoxCollider2D>();
            PhysicsComponent p = g.AddComponent <PhysicsComponent>();

            c.Inject(b);
            c.Physics = p;
            c.Physics.Inject(r);

            return(c);
        }
예제 #28
0
        /// <summary>
        /// Draw selected item
        /// </summary>
        /// <param Name="index">item index</param>
        public void DrawItem(int index)
        {
            Carriable item = data[index];
            // Get items in possession
            int _number = 0;

            switch (item.GetType().Name.ToString())
            {
            case "Item":
                _number = InGame.Party.ItemNumber(item.Id);
                break;

            case "Weapon":
                _number = InGame.Party.WeaponNumber(item.Id);
                break;

            case "Armor":
                _number = InGame.Party.ArmorNumber(item.Id);
                break;
            }
            // If price is less than money in possession, and amount in possession is
            // not GameParty.MAX_ITEM_NUMBER, then set to normal text Color. Otherwise
            // set to disabled Color
            if (item.Price <= InGame.Party.Gold && _number < GameParty.MAX_ITEM_NUMBER)
            {
                this.Contents.Font.Color = NormalColor;
            }
            else
            {
                this.Contents.Font.Color = DisabledColor;
            }
            int       _x    = 4;
            int       _y    = index * 32;
            Rectangle _rect = new Rectangle(_x, _y, this.Width - 32, 32);

            this.Contents.FillRect(_rect, new Color(0, 0, 0, 0));
            byte _opacity = this.Contents.Font.Color == NormalColor ? (byte)255 : (byte)128;

            this.Contents.Blit(_x, _y + 4, Cache.IconBitmap, Cache.IconSourceRect(item.IconName), _opacity);
            this.Contents.DrawText(_x + 28, _y, 212, 32, item.Name, 0);
            this.Contents.DrawText(_x + 240, _y, 88, 32, item.Price.ToString(), 2);
        }
예제 #29
0
        /// <summary>
        /// Refresh, choose items to draw
        /// </summary>
        public void Refresh()
        {
            if (this.Contents != null)
            {
                this.Contents.Dispose();
                this.Contents = null;
            }
            data.Clear();
            Carriable _item = null;

            foreach (int[] goods_item in shopGoods)
            {
                switch (goods_item[0])
                {
                case 0:
                    _item = Data.Items[goods_item[1]];
                    break;

                case 1:
                    _item = Data.Weapons[goods_item[1]];
                    break;

                case 2:
                    _item = Data.Armors[goods_item[1]];
                    break;
                }
                if (_item != null)
                {
                    data.Add(_item);
                }
            }
            // If item count is not 0, make a bit map and draw all items
            itemMax = data.Count;
            if (itemMax > 0)
            {
                this.Contents = new Bitmap(Width - 32, RowMax * 32);
                for (int i = 0; i < itemMax; i++)
                {
                    DrawItem(i);
                }
            }
        }
예제 #30
0
    public Carriable Place(Carriable objectToPlace)
    {
        var returnObject = PlacedObject;

        PlacedObject = objectToPlace;
        PlacedObject.transform.position = transform.position;
        ResetRotationOfPlacedObject();
        if (objectToPlace != null)
        {
            var record = objectToPlace.GetComponent <Carriable>().CarriableName;
            MusicManager.Instance.songySong.SetClipVolume(1, record);
        }

        if (returnObject != null)
        {
            var record = returnObject.CarriableName;
            MusicManager.Instance.songySong.SetClipVolume(0, record);
        }
        return(returnObject);
    }
예제 #31
0
 /// <summary>
 /// Frame Update (when sell window is active)
 /// </summary>
 void UpdateSell()
 {
     // If B button was pressed
     if (Input.RMTrigger.B)
     {
         // Play cancel SE
         InGame.System.SoundPlay(Data.System.CancelSoundEffect);
         // Change windows to initial mode
         commandWindow.IsActive = true;
         dummyWindow.IsVisible = true;
         sellWindow.IsActive = false;
         sellWindow.IsVisible = false;
         statusWindow.Item = null;
         // Erase help text
         helpWindow.SetText("");
         return;
     }
     // If C button was pressed
     if (Input.RMTrigger.C)
     {
         // Get item
         item = sellWindow.Item;
         // Set status window item
         statusWindow.Item = item;
         // If item is invalid, or item price is 0 (unable to sell)
         if (item == null || item.Price == 0)
         {
             // Play buzzer SE
             InGame.System.SoundPlay(Data.System.BuzzerSoundEffect);
             return;
         }
         // Play decision SE
         InGame.System.SoundPlay(Data.System.DecisionSoundEffect);
         // Get items in possession count
         int _number = 0;
         switch (item.GetType().Name)
         {
             case "Item":
                 _number = InGame.Party.ItemNumber(item.Id);
                 break;
             case "Weapon":
                 _number = InGame.Party.WeaponNumber(item.Id);
                 break;
             case "Armor":
                 _number = InGame.Party.ArmorNumber(item.Id);
                 break;
         }
         // Maximum quanitity to sell = number of items in possession
         int _max = _number;
         // Change windows to quantity input mode
         sellWindow.IsActive = false;
         sellWindow.IsVisible = false;
         numberWindow.Set(item, _max, item.Price / 2);
         numberWindow.IsActive = true;
         numberWindow.IsVisible = true;
         statusWindow.IsVisible = true;
     }
 }
예제 #32
0
 /// <summary>
 /// Frame Update (when buy window is active)
 /// </summary>
 void UpdateBuy()
 {
     // Set status window item
     statusWindow.Item = buyWindow.Item;
     // If B button was pressed
     if (Input.RMTrigger.B)
     {
         // Play cancel SE
         InGame.System.SoundPlay(Data.System.CancelSoundEffect);
         // Change windows to initial mode
         commandWindow.IsActive = true;
         dummyWindow.IsVisible = true;
         buyWindow.IsActive = false;
         buyWindow.IsVisible = false;
         statusWindow.IsVisible = false;
         statusWindow.Item = null;
         // Erase help text
         helpWindow.SetText("");
         return;
     }
     // If C button was pressed
     if (Input.RMTrigger.C)
     {
         // Get item
         item = buyWindow.Item;
         // If item is invalid, or price is higher than money possessed
         if (item == null || item.Price > InGame.Party.Gold)
         {
             // Play buzzer SE
             InGame.System.SoundPlay(Data.System.BuzzerSoundEffect);
             return;
         }
         // Get items in possession count
         int _number = 0;
         switch (item.GetType().Name)
         {
             case "Item":
                 _number = InGame.Party.ItemNumber(item.Id);
                 break;
             case "Weapon":
                 _number = InGame.Party.WeaponNumber(item.Id);
                 break;
             case "Armor":
                 _number = InGame.Party.ArmorNumber(item.Id);
                 break;
         }
         // If 99 items are already in possession
         if (_number == 99)
         {
             // Play buzzer SE
             InGame.System.SoundPlay(Data.System.BuzzerSoundEffect);
             return;
         }
         // Play decision SE
         InGame.System.SoundPlay(Data.System.DecisionSoundEffect);
         // Calculate maximum amount possible to buy
         int _max = item.Price == 0 ? 99 : InGame.Party.Gold / item.Price;
         _max = Math.Min(_max, 99 - _number);
         // Change windows to quantity input mode
         buyWindow.IsActive = false;
         buyWindow.IsVisible = false;
         numberWindow.Set(item, _max, item.Price);
         numberWindow.IsActive = true;
         numberWindow.IsVisible = true;
     }
 }