Beispiel #1
0
    IPromise PlayBulletFlyAnimation(Cell from, Cell to)
    {
        Vector3 move = (to.transform.position - from.transform.position);

        var bullet = Instantiate(bulletSample);

        bullet.SetActive(true);
        bullet.transform.position    = from.transform.position;
        bullet.transform.eulerAngles = new Vector3(0, 0, Mathf.Atan2(move.y, move.x) * Mathf.Rad2Deg);

        var bulletLine = Instantiate(lineSample);

        bulletLine.SetActive(true);
        bulletLine.GetComponentInChildren <LineRenderer>().SetPosition(0, from.transform.position + Vector3.back);
        bulletLine.GetComponentInChildren <LineRenderer>().SetPosition(1, to.transform.position + Vector3.back);
        TimeManager.Wait(0.1f).Then(() => {
            Destroy(bulletLine);
        }).Done();

        return(AnimationsManager.Move(bullet.transform, from.transform.position, to.transform.position, 100).Then(() => {
            Destroy(bullet);
        }));
    }