Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        BtlPlane plane = this.parent;

        if (plane.isUser())
        {
            return;
        }
        if (!plane.isVisble)
        {
            Renderer renderer = gameObject.GetComponent <Renderer>();
            if (null == renderer)
            {
                Debug.LogErrorFormat("BattlePlaneMove获取Renderer失败");
            }
            if (renderer.isVisibleExt(Camera.main))
            {
                //进入摄像头
                plane.isVisble = true;
            }
        }
        else
        {
            //离开镜头,销毁对象
            Renderer renderer = gameObject.GetComponent <Renderer>();
            if (null == renderer)
            {
                Debug.LogErrorFormat("BattlePlaneMove获取Renderer失败");
            }
            if (!renderer.isVisibleExt(Camera.main))
            {
                plane.isVisble = false;
                Destroy(gameObject);
                Global.Instance.btlMgr.btlPlaneMgr.btlPlaneEnemyList.Remove(plane);
                //Debug.LogFormat ("plane cnt:{0}", Global.Instance.btlMgr.btlPlaneMgr.btlPlaneEnemyList.Count);
            }
        }
        BtlMove btlMove = plane.btlMove;

        switch (btlMove.moveTrace)
        {
        case EnumMoveTrace.Line:
            btlMove.movement = new Vector2(btlMove.speed.x * btlMove.direction.x, btlMove.speed.y * btlMove.direction.y);
            break;

        default:
            Debug.LogErrorFormat("战机 移动类型{0}", btlMove.moveTrace);
            break;
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        BtlMove btlMove = this.parent.btlMove;

        switch (btlMove.moveTrace)
        {
        case EnumMoveTrace.Line:        //直线
            float xAbs   = System.Math.Abs(btlMove.direction.x);
            float yAbs   = System.Math.Abs(btlMove.direction.y);
            float sumAbs = xAbs + yAbs;
            sumAbs             = (0 == sumAbs ? 1 : sumAbs);
            btlMove.movement.x = btlMove.speed.x * (btlMove.direction.x < 0 ? -1 : 1) * xAbs / sumAbs;
            btlMove.movement.y = btlMove.speed.y * (btlMove.direction.y < 0 ? -1 : 1) * yAbs / sumAbs;
            break;

        default:
            Debug.LogErrorFormat("子弹 移动类型{0}", btlMove.moveTrace);
            break;
        }
    }
Ejemplo n.º 3
0
 //碰撞对象
 //碰撞后是否消失
 //二次爆炸后 触发新的子弹管理器
 //子弹归属者消失后,子弹是否消失
 //是否暂停
 public BtlBullet()
 {
     this.btlMove = new BtlMove();
     this.camp    = EnumCamp.Red;
 }
Ejemplo n.º 4
0
 public BtlPlane()
 {
     this.btlBulletMgr        = new BtlBulletMgr();
     this.btlMove             = new BtlMove();
     this.btlBulletMgr.parent = this;
 }