예제 #1
0
파일: Gun.cs 프로젝트: tamdoduc/Mr-Grimmick
    // Update is called once per frame
    void Update()
    {
        Vector2 velocity = this.gameObject.GetComponent <Rigidbody2D>().velocity;

        if (velocity.x > 0)
        {
            velocity.x = Mathf.Max(0, velocity.x - Time.deltaTime * 0.1f);
        }
        if (velocity.x < 0)
        {
            velocity.x = Mathf.Min(0, velocity.x + Time.deltaTime * 0.1f);
        }
        this.gameObject.GetComponent <Rigidbody2D>().velocity = velocity;
        time += Time.deltaTime;
        if (time >= timeLoop)
        {
            time           = 0;
            cloneBulletFly = GameObject.Instantiate(bulletFly);
            cloneBulletFly.transform.position = this.gameObject.transform.position - new Vector3(1.26f, -0.5f, 0);
        }
        Vector3 range = this.gameObject.transform.position - posBefore;

        if (Mathf.Abs(range.x) > 0.1f)
        {
            ChangeAnimator();
            posBefore = this.gameObject.transform.position;
        }
        if (range.y > 0)
        {
            posBefore = this.gameObject.transform.position;
        }
    }
    public override void Attack(Vector3 pos, Vector3 rotation)
    {
        base.Attack(pos, rotation);
        BulletFly bullet = PhotonNetwork.Instantiate("Bullet", pos + new Vector3(0, 0.263f, 0), Quaternion.Euler(rotation), 0).GetComponent <BulletFly>();

        bullet.Init(Damage, AttackRange);
    }
예제 #3
0
 public override void Init()
 {
     base.Init();
     BulletObj = transform.Find("Bullet").gameObject;
     HitObj    = transform.Find("Hit").gameObject;
     ObjectObj = transform.Find("Object").gameObject;
     bulletFly = bulletFly.GetComponent <BulletFly>();
     IsHit     = false;
 }
예제 #4
0
 public override void Init()
 {
     fly       = GetComponent <BulletFly>();
     hitObject = transform.Find("hit").gameObject;
 }