示例#1
0
 public void Attack()
 {
     if (Inventory[SelectedSlot].item == null)
     {
         return;
     }
     else if (SelectedItem == null && Inventory[SelectedSlot].item != null)
     {
         SelectedItem = Inventory[SelectedSlot].item.GetComponent <IUseable>();
     }
     if (Inventory[SelectedSlot].item.SelectedItemType == ItemType.BouncyGun || Inventory[SelectedSlot].item.SelectedItemType == ItemType.DuckBazooka)
     {
         AudioSource.PlayClipAtPoint(duckGunSound, Camera.main.transform.position);
         SelectedItem.Use();
     }
     else
     {
         if (Inventory[SelectedSlot].item.SelectedItemType == ItemType.BasicSword)
         {
             AudioSource.PlayClipAtPoint(basicSwordSound, Camera.main.transform.position, 100);
         }
         else
         {
             AudioSource.PlayClipAtPoint(pinballSwordSound, Camera.main.transform.position);
         }
         RaycastHit2D[] hits = Physics2D.CircleCastAll(transform.position + GetComponent <Movement>().Aim.up * 1, 0.5f, Vector2.zero);
         if (hits != null && SelectedItem != null)
         {
             SelectedItem.Use(hits);
         }
     }
 }
示例#2
0
 void Use()
 {
     if (useable != null)
     {
         useable.Use();
     }
 }
 private void Use()
 {
     if (useable != null)
     {
         if (useable.GetType() == "Container" || useable.GetType() == "Lever")
         {
             anim.SetTrigger("sit");
             useable.Use();
             useable = null;
         }
         else //if(useable.GetType() == "Door" || useable.GetType() == "Quest" || useable.GetType() == "Respawn")
         {
             useable.Use();
         }
     }
 }
示例#4
0
 public void OnClick()
 {
     if (useable != null)
     {
         useable.Use();
     }
 }
示例#5
0
        private void TestUse()
        {
            if (!Input.GetMouseButton(0))
            {
                if (used != null)
                {
                    used.UnUse(hand);
                    used = null;
                }
            }

            if (Input.GetMouseButtonDown(0))
            {
                var mainCamera = FindCamera();

                RaycastHit hit = new RaycastHit();
                if (!Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition).origin,
                                     mainCamera.ScreenPointToRay(Input.mousePosition).direction, out hit, 100,
                                     Physics.DefaultRaycastLayers)
                    )
                {
                    return;
                }

                used = hit.collider.gameObject.GetComponentsInParent <MonoBehaviour>().Where(mb => mb is IUseable).FirstOrDefault() as IUseable;

                if (used != null)
                {
                    Debug.Log("Using " + hit.collider.gameObject.name);
                    used.Use(hand);
                }
            }
        }
示例#6
0
 public void Use(IUseable <Item> item)
 {
     try
     {
         if (Check.IsAlive(this) == true)
         {
             item.Use(this);
         }
         else
         {
             throw new InvalidOperationException();
         }
     }
     catch (InvalidOperationException) { }
 }
示例#7
0
    public void UseItem()
    {
        if (slot.MyItem is IUseable)
        {
            IUseable item = slot.MyItem as IUseable;

            if (item.Use())
            {
                RemoveItem(1);
            }
            else if (inventoryManager.DebugMode)
            {
                Debug.Log("Cannot use this " + item + " right now");
            }
        }
    }
示例#8
0
    // Update is called once per frame
    void Update()
    {
        horizontalMove = Input.GetAxisRaw(axisHorizontal) * runSpeed;

        if (Input.GetButtonDown(jumpButton))
        {
            jump = true;
        }

        if (Input.GetAxisRaw(axisVertical) < 0)
        {
            crouch = true;
        }
        else if (Input.GetAxisRaw(axisVertical) > -0.1)
        {
            crouch = false;
        }

        if (Input.GetButtonDown(pickUpButton))
        {
            if (transform.Find("Equipment Slot").childCount == 0)
            {
                Pickup();
            }
            else if (Mathf.Abs(horizontalMove) > 0)
            {
                Throw();
            }
            else
            {
                Drop();
            }
        }
        if (Input.GetButtonDown(useButton))
        {
            if (equipslot.childCount == 1)
            {
                IUseable equipment = equipslot.GetComponentInChildren <IUseable>();
                if (equipment != null)
                {
                    equipment.Use();
                }
            }
        }
    }
示例#9
0
文件: Active.cs 项目: tojatos/NKM
    private void MakeAction(Character characterThatMakesAction, Action action, List <HexCell> cells)
    {
        switch (action)
        {
        case Action.None:
            Console.Instance.DebugLog("Żadna akcja nie jest aktywna!");
            return;

        case Action.UseAbility:
            CharacterOnMap.TryToInvokeJustBeforeFirstAction();
//				Console.GameLog($"ABILITY USE: {((Ability)AbilityToUse).ID}: {string.Join("; ", cells.Select(p => p.Coordinates))}");
            AbilityToUse.Use(cells);
            Console.GameLog($"ABILITY USE: {string.Join("; ", cells.Select(p => p.Coordinates))}");
            break;

        case Action.AttackAndMove:
            if (cells.Count != 1)
            {
                Console.Instance.DebugLog("Próbowano wykonać ruch lub atak na więcej niż jedno pole!");
                return;
            }

            bool isActionSuccessful = MakeAttackAndMoveAction(characterThatMakesAction, cells[0], MoveCells);
            if (!isActionSuccessful)
            {
                return;
            }

            HexCells = null;                    //TODO is this really needed?
            Action   = Action.None;
            characterThatMakesAction.Select();
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
示例#10
0
文件: Hero.cs 项目: jsnelcer/RpgCore
        public void UseItem(IUseable <IEffect> item)
        {
            IEffect eff = item.Use();

            StatsManager.ApplyEffect(eff);
        }
    public static void JumpTo(IUseable useable, Action callback = null)
    {
        var action = callback ?? (() => useable.Use());

        StartJumping(useable.PlayerStandPosition, action, useable, useable.CustomSpeedToPosition).Start();
    }
    public static void MoveTo(IUseable useable, Action callback = null)
    {
        Action action = callback ?? (() => useable.Use());

        StartWalking(useable.PlayerStandPosition, action).Start();
    }