示例#1
0
    void Grid::OnCross(Plane& plane, Plane* old_plane, grid_ptr from, grid_ptr to) {
        // 击毁已有的Plane
        if (NULL != old_plane) {
            float sub_t = 0.0f;
            if (to) {
                using cocos2d::Vec2;
                Vec2 t = Vec2(to->GetPositionX(), to->GetPositionY());
                Vec2 m = Vec2(GetPositionX(), GetPositionY());
                sub_t = t.distance(m) / Config::GetInstance().Plane.FlySpeed;
            }
            // 被击毁飞机回家
            old_plane->GoHome(LGR_KICKOFF, plane.GetActionTime() - sub_t);
        }

    }
示例#2
0
    void Grid::OnArrive(Plane& plane, int reason) {
        Plane* old_place_plane = place_plane;
        // 添加飞机运动动画
        MoveHere(plane, plane.GetSpeed(), 0.0f, reason);

        // 击毁已有的Plane
        if (NULL != old_place_plane) {
            // 被击毁飞机回家
            old_place_plane->GoHome(LGR_KICKOFF, plane.GetActionTime());
        }
        place_plane = &plane;


        arrive_event(plane, old_place_plane);

        // 计算跳跃
        if (Color() == plane.Color() && plane.CanJump() && jump != ID()) {
            // 跳跃动画
            plane.JumpTo(jump);
        }

        // 胜利条件
    }