예제 #1
0
    private void fireArrow(float distance)
    {
        GameObject clone = Instantiate(projectile, spawnPoint.position, spawnPoint.rotation) as GameObject;

        ArrowProperties props = new ArrowProperties();

        props.id          = nextArrowId;
        props.maxDistance = distance;
        props.isTrigger   = arrowsPassThroughAll;
        clone.SendMessage("setUp", props);

        nextArrowId++;

        // Set the velocity of the projectile in the local down direction of the player,
        // because thats the direction he faces
        clone.rigidbody2D.velocity = (-1 * transform.up) * arrowSpeed;

        changeTeleportArrowNode(shotArrows.AddLast(clone.GetComponent <Arrow>()));

        // Make sure we dont have too many arrows that we can teleport to
        while (shotArrows.Count > numberOfPossibleTeleportArrows)
        {
            shotArrows.RemoveFirst();
        }
    }
예제 #2
0
 // Start is called before the first frame update
 protected virtual void Start()
 {
     player                = GameManager.Instance.player;
     spriteRenderer        = GetComponent <SpriteRenderer>();
     properties            = player.arrow.arrowProperties;
     spriteRenderer.sprite = properties.sprite;
 }
예제 #3
0
    public void setUp(ArrowProperties properties)
    {
        maxDistance = properties.maxDistance;
        damage      = properties.damage;

        startPoint = transform.position;
    }
예제 #4
0
파일: Arrow.cs 프로젝트: frms/game-jams
    public void setUp(ArrowProperties properties)
    {
        id                   = properties.id;
        maxDistance          = properties.maxDistance;
        collider2D.isTrigger = properties.isTrigger;

        inFlight   = true;
        startPoint = transform.position;
    }
예제 #5
0
파일: Player.cs 프로젝트: frms/game-jams
    private void fireArrow(float distance)
    {
        GameObject clone = Instantiate(projectile, spawnPoint.position, spawnPoint.rotation) as GameObject;

        ArrowProperties props = new ArrowProperties();

        props.maxDistance = distance;
        props.damage      = arrowDamage;
        clone.SendMessage("setUp", props);

        clone.GetComponent <Rigidbody2D>().velocity = transform.right * arrowSpeed;
    }