Example #1
0
    protected override bool OnActivate()
    {
        ammo--;

        Vector3 position = player.transform.position;

        position.x -= placementDelta * player.transform.localScale.x;

        GameObject obj = GameObject.Instantiate(prefab, position, Quaternion.identity);

        Throwable throwable = obj.GetComponent <Throwable>();

        if (throwable)
        {
            throwable.SetDirection(player.transform.localScale.x);
        }

        TrashBag trashBag = obj.GetComponent <TrashBag>();

        if (trashBag)
        {
            trashBag.SetDirection(player.transform.localScale.x);
        }

        if (ammo <= 0)
        {
            OnDeactivate();
        }

        return(ammo <= 0);
    }
Example #2
0
    public void Shoot()
    {
        GameObject tmp    = (GameObject)Instantiate(projectilePrefab, spawnPoint.position, Quaternion.identity);
        Throwable  script = tmp.GetComponent <Throwable>();

        SoundManager.instance.ThrowKnife();

        if (script != null)
        {
            if (collider.offset.x < 0f)
            {
                script.SetDirection(Vector2.left);
            }
            else
            {
                script.SetDirection(Vector2.right);
            }
        }
    }
Example #3
0
 public virtual void Throw(GameObject throwablePrefab, Vector3 spawnPoint)
 {
     if (facingRight)
     {
         GameObject tmp    = (GameObject)Instantiate(throwablePrefab, spawnPoint, Quaternion.identity);
         Throwable  script = tmp.GetComponent <Throwable>();
         if (script != null)
         {
             script.SetDirection(Vector2.right);
         }
     }
     else
     {
         GameObject tmp    = (GameObject)Instantiate(throwablePrefab, spawnPoint, Quaternion.identity);
         Throwable  script = tmp.GetComponent <Throwable>();
         if (script != null)
         {
             script.SetDirection(Vector2.left);
         }
     }
 }