根据siki写的愤怒的小鸟之小蓝鸟

有bug但是不会改,能力目前只能到此为止(开摆)

Unity才接触了两个月,C#一年都没有学满……艰难。

using UnityEngine;
using UnityEngine.UI;

//为什么刚体不出现?!!!!!!!!为什么触碰不到地面??!!!!!
//答案:因为复制后刚体脚本被关闭了
//点击的时候分裂成三个
public class bluebird : brid
{
    private Vector3 curpos;//上一帧的位置
    private Vector3 lastpos;//最后一帧的位置
    //private Vector3 cha;//两者的向量差值
    public Vector3[] Frame;//获取每一帧的数组
    private Vector3 direction;
    private Vector3 lastPoint;

    public GameObject blueBird;

    public override void Update()
    //因为bluebrid继承了brid,如果直接写public void Update相当于重写,于是之前写的不算数,
    //所以需要继承并且运行之前的内容
    {
        base.Update();
        direction = (transform.position - lastPoint).normalized;
        lastPoint = transform.position;
    }

    //点击后
    public override void ShowSkill()
    {
        base.ShowSkill();

        Vector3 speedfirst = rg.velocity;//获取速度
                                         // GameObject FirstBird = Instantiate(gameObject, transform.position, transform.rotation);//获取当前位置

        float blueX = transform.position.x;//获取当前x的位置
        float blueY = transform.position.y;//获取当前y的位置

        OnClear();//销毁第一只鸟

        GameObject onebird = Instantiate(gameObject, transform.position, transform.rotation);
        onebird.GetComponent<SpriteRenderer>().enabled = true;
        GameObject twobird = Instantiate(gameObject, transform.position, transform.rotation);
        twobird.GetComponent<SpriteRenderer>().enabled = true;
        GameObject threebird = Instantiate(gameObject, transform.position, transform.rotation);
        threebird.GetComponent<SpriteRenderer>().enabled = true;

        onebird.GetComponent<Rigidbody2D>().AddForce(Quaternion.AngleAxis(5, Vector3.forward) * direction * 8, ForceMode2D.Impulse);
        twobird.GetComponent<Rigidbody2D>().AddForce(direction * 8, ForceMode2D.Impulse);
        threebird.GetComponent<Rigidbody2D>().AddForce(Quaternion.AngleAxis(-5, Vector3.forward) * direction * 8, ForceMode2D.Impulse);

        Destroy(onebird, 4.0f);
        Destroy(twobird, 4.0f);
        Destroy(threebird, 4.0f);
    }

    void OnClear()
    {
        rg.velocity = Vector3.zero;
        Instantiate(boom, transform.position, Quaternion.identity);
        render.enabled = false;
        myTrail.ClearTrails();
    }
}
 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值